2023-04-13 17:32:31 +02:00
|
|
|
import 'package:kiwi/kiwi.dart';
|
|
|
|
import 'package:nc_photos/account.dart';
|
2023-06-10 12:44:02 +02:00
|
|
|
import 'package:nc_photos/controller/account_pref_controller.dart';
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/controller/collections_controller.dart';
|
2023-05-10 18:42:56 +02:00
|
|
|
import 'package:nc_photos/controller/server_controller.dart';
|
2023-04-13 17:32:31 +02:00
|
|
|
import 'package:nc_photos/di_container.dart';
|
|
|
|
|
|
|
|
class AccountController {
|
|
|
|
void setCurrentAccount(Account account) {
|
|
|
|
_account = account;
|
|
|
|
_collectionsController?.dispose();
|
|
|
|
_collectionsController = null;
|
2023-06-04 19:14:03 +02:00
|
|
|
_serverController?.dispose();
|
2023-05-10 18:42:56 +02:00
|
|
|
_serverController = null;
|
2023-06-10 12:44:02 +02:00
|
|
|
_accountPrefController?.dispose();
|
|
|
|
_accountPrefController = null;
|
2023-04-13 17:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Account get account => _account!;
|
|
|
|
|
|
|
|
CollectionsController get collectionsController =>
|
|
|
|
_collectionsController ??= CollectionsController(
|
|
|
|
KiwiContainer().resolve<DiContainer>(),
|
|
|
|
account: _account!,
|
2023-05-10 18:42:56 +02:00
|
|
|
serverController: serverController,
|
|
|
|
);
|
|
|
|
|
|
|
|
ServerController get serverController =>
|
|
|
|
_serverController ??= ServerController(
|
|
|
|
account: _account!,
|
2023-04-13 17:32:31 +02:00
|
|
|
);
|
|
|
|
|
2023-06-10 12:44:02 +02:00
|
|
|
AccountPrefController get accountPrefController =>
|
|
|
|
_accountPrefController ??= AccountPrefController(
|
|
|
|
account: _account!,
|
|
|
|
);
|
|
|
|
|
2023-04-13 17:32:31 +02:00
|
|
|
Account? _account;
|
|
|
|
CollectionsController? _collectionsController;
|
2023-05-10 18:42:56 +02:00
|
|
|
ServerController? _serverController;
|
2023-06-10 12:44:02 +02:00
|
|
|
AccountPrefController? _accountPrefController;
|
2023-04-13 17:32:31 +02:00
|
|
|
}
|