nc-photos/app/lib/controller/account_controller.dart

129 lines
4.1 KiB
Dart
Raw Normal View History

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';
import 'package:nc_photos/controller/collections_controller.dart';
import 'package:nc_photos/controller/files_controller.dart';
2024-01-30 18:31:52 +01:00
import 'package:nc_photos/controller/metadata_controller.dart';
2023-07-03 19:23:42 +02:00
import 'package:nc_photos/controller/persons_controller.dart';
2023-12-13 16:06:13 +01:00
import 'package:nc_photos/controller/places_controller.dart';
2024-01-30 18:31:52 +01:00
import 'package:nc_photos/controller/pref_controller.dart';
import 'package:nc_photos/controller/server_controller.dart';
2023-08-24 17:32:23 +02:00
import 'package:nc_photos/controller/session_controller.dart';
2023-09-11 19:01:47 +02:00
import 'package:nc_photos/controller/sharings_controller.dart';
import 'package:nc_photos/controller/sync_controller.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/event/native_event_relay.dart';
class AccountController {
2024-01-30 18:31:52 +01:00
AccountController({
required this.prefController,
});
void setCurrentAccount(Account account) {
_account = account;
_collectionsController?.dispose();
_collectionsController = null;
2023-06-04 19:14:03 +02:00
_serverController?.dispose();
_serverController = null;
2023-06-10 12:44:02 +02:00
_accountPrefController?.dispose();
_accountPrefController = null;
2023-07-03 19:23:42 +02:00
_personsController?.dispose();
_personsController = null;
_syncController?.dispose();
_syncController = null;
2023-08-24 17:32:23 +02:00
_sessionController?.dispose();
_sessionController = null;
2023-09-11 19:01:47 +02:00
_sharingsController?.dispose();
_sharingsController = null;
_placesController?.dispose();
_placesController = null;
_filesController?.dispose();
_filesController = null;
2024-01-30 18:31:52 +01:00
_metadataController?.dispose();
_metadataController = null;
_nativeEventRelay?.dispose();
_nativeEventRelay = NativeEventRelay(
filesController: filesController,
metadataController: metadataController,
);
}
Account get account => _account!;
CollectionsController get collectionsController =>
_collectionsController ??= CollectionsController(
KiwiContainer().resolve<DiContainer>(),
account: _account!,
serverController: serverController,
);
ServerController get serverController =>
_serverController ??= ServerController(
account: _account!,
);
2023-06-10 12:44:02 +02:00
AccountPrefController get accountPrefController =>
_accountPrefController ??= AccountPrefController(
account: _account!,
);
2023-07-03 19:23:42 +02:00
PersonsController get personsController =>
_personsController ??= PersonsController(
KiwiContainer().resolve<DiContainer>(),
account: _account!,
accountPrefController: accountPrefController,
);
SyncController get syncController => _syncController ??= SyncController(
account: _account!,
);
2023-08-24 17:32:23 +02:00
SessionController get sessionController =>
_sessionController ??= SessionController();
2023-09-11 19:01:47 +02:00
SharingsController get sharingsController =>
_sharingsController ??= SharingsController(
KiwiContainer().resolve(),
account: _account!,
);
2023-12-13 16:06:13 +01:00
PlacesController get placesController =>
_placesController ??= PlacesController(
KiwiContainer().resolve<DiContainer>(),
account: _account!,
);
2024-01-30 18:31:52 +01:00
FilesController get filesController => _filesController ??= FilesController(
KiwiContainer().resolve<DiContainer>(),
account: _account!,
accountPrefController: accountPrefController,
);
2024-01-30 18:31:52 +01:00
MetadataController get metadataController =>
_metadataController ??= MetadataController(
KiwiContainer().resolve(),
account: account,
filesController: filesController,
prefController: prefController,
);
PrefController prefController;
Account? _account;
CollectionsController? _collectionsController;
ServerController? _serverController;
2023-06-10 12:44:02 +02:00
AccountPrefController? _accountPrefController;
2023-07-03 19:23:42 +02:00
PersonsController? _personsController;
SyncController? _syncController;
2023-08-24 17:32:23 +02:00
SessionController? _sessionController;
2023-09-11 19:01:47 +02:00
SharingsController? _sharingsController;
2023-12-13 16:06:13 +01:00
PlacesController? _placesController;
FilesController? _filesController;
2024-01-30 18:31:52 +01:00
MetadataController? _metadataController;
NativeEventRelay? _nativeEventRelay;
}