2021-12-03 18:31:27 +01:00
|
|
|
import 'package:nc_photos/app_db.dart';
|
|
|
|
import 'package:nc_photos/entity/album.dart';
|
|
|
|
import 'package:nc_photos/entity/face.dart';
|
2022-01-25 11:08:13 +01:00
|
|
|
import 'package:nc_photos/entity/favorite.dart';
|
2021-12-03 18:31:27 +01:00
|
|
|
import 'package:nc_photos/entity/file.dart';
|
2022-05-05 16:06:47 +02:00
|
|
|
import 'package:nc_photos/entity/local_file.dart';
|
2021-12-03 18:31:27 +01:00
|
|
|
import 'package:nc_photos/entity/person.dart';
|
|
|
|
import 'package:nc_photos/entity/share.dart';
|
|
|
|
import 'package:nc_photos/entity/sharee.dart';
|
2022-01-28 20:34:38 +01:00
|
|
|
import 'package:nc_photos/entity/tag.dart';
|
2022-01-29 12:31:32 +01:00
|
|
|
import 'package:nc_photos/entity/tagged_file.dart';
|
2021-12-07 19:42:25 +01:00
|
|
|
import 'package:nc_photos/or_null.dart';
|
2021-12-03 18:31:27 +01:00
|
|
|
import 'package:nc_photos/pref.dart';
|
|
|
|
|
|
|
|
enum DiType {
|
|
|
|
albumRepo,
|
|
|
|
faceRepo,
|
|
|
|
fileRepo,
|
|
|
|
personRepo,
|
|
|
|
shareRepo,
|
|
|
|
shareeRepo,
|
2022-01-25 11:08:13 +01:00
|
|
|
favoriteRepo,
|
2022-01-28 20:34:38 +01:00
|
|
|
tagRepo,
|
2022-01-29 12:31:32 +01:00
|
|
|
taggedFileRepo,
|
2022-05-05 16:06:47 +02:00
|
|
|
localFileRepo,
|
2021-12-03 18:31:27 +01:00
|
|
|
appDb,
|
|
|
|
pref,
|
|
|
|
}
|
|
|
|
|
|
|
|
class DiContainer {
|
|
|
|
const DiContainer({
|
|
|
|
AlbumRepo? albumRepo,
|
|
|
|
FaceRepo? faceRepo,
|
|
|
|
FileRepo? fileRepo,
|
|
|
|
PersonRepo? personRepo,
|
|
|
|
ShareRepo? shareRepo,
|
|
|
|
ShareeRepo? shareeRepo,
|
2022-01-25 11:08:13 +01:00
|
|
|
FavoriteRepo? favoriteRepo,
|
2022-01-28 20:34:38 +01:00
|
|
|
TagRepo? tagRepo,
|
2022-01-29 12:31:32 +01:00
|
|
|
TaggedFileRepo? taggedFileRepo,
|
2022-05-05 16:06:47 +02:00
|
|
|
LocalFileRepo? localFileRepo,
|
2021-12-03 18:31:27 +01:00
|
|
|
AppDb? appDb,
|
|
|
|
Pref? pref,
|
|
|
|
}) : _albumRepo = albumRepo,
|
|
|
|
_faceRepo = faceRepo,
|
|
|
|
_fileRepo = fileRepo,
|
|
|
|
_personRepo = personRepo,
|
|
|
|
_shareRepo = shareRepo,
|
|
|
|
_shareeRepo = shareeRepo,
|
2022-01-25 11:08:13 +01:00
|
|
|
_favoriteRepo = favoriteRepo,
|
2022-01-28 20:34:38 +01:00
|
|
|
_tagRepo = tagRepo,
|
2022-01-29 12:31:32 +01:00
|
|
|
_taggedFileRepo = taggedFileRepo,
|
2022-05-05 16:06:47 +02:00
|
|
|
_localFileRepo = localFileRepo,
|
2021-12-03 18:31:27 +01:00
|
|
|
_appDb = appDb,
|
|
|
|
_pref = pref;
|
|
|
|
|
|
|
|
static bool has(DiContainer contianer, DiType type) {
|
|
|
|
switch (type) {
|
|
|
|
case DiType.albumRepo:
|
|
|
|
return contianer._albumRepo != null;
|
|
|
|
case DiType.faceRepo:
|
|
|
|
return contianer._faceRepo != null;
|
|
|
|
case DiType.fileRepo:
|
|
|
|
return contianer._fileRepo != null;
|
|
|
|
case DiType.personRepo:
|
|
|
|
return contianer._personRepo != null;
|
|
|
|
case DiType.shareRepo:
|
|
|
|
return contianer._shareRepo != null;
|
|
|
|
case DiType.shareeRepo:
|
|
|
|
return contianer._shareeRepo != null;
|
2022-01-25 11:08:13 +01:00
|
|
|
case DiType.favoriteRepo:
|
|
|
|
return contianer._favoriteRepo != null;
|
2022-01-28 20:34:38 +01:00
|
|
|
case DiType.tagRepo:
|
|
|
|
return contianer._tagRepo != null;
|
2022-01-29 12:31:32 +01:00
|
|
|
case DiType.taggedFileRepo:
|
|
|
|
return contianer._taggedFileRepo != null;
|
2022-05-05 16:06:47 +02:00
|
|
|
case DiType.localFileRepo:
|
|
|
|
return contianer._localFileRepo != null;
|
2021-12-03 18:31:27 +01:00
|
|
|
case DiType.appDb:
|
|
|
|
return contianer._appDb != null;
|
|
|
|
case DiType.pref:
|
|
|
|
return contianer._pref != null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-07 19:42:25 +01:00
|
|
|
DiContainer copyWith({
|
|
|
|
OrNull<AlbumRepo>? albumRepo,
|
|
|
|
OrNull<FaceRepo>? faceRepo,
|
|
|
|
OrNull<FileRepo>? fileRepo,
|
|
|
|
OrNull<PersonRepo>? personRepo,
|
|
|
|
OrNull<ShareRepo>? shareRepo,
|
|
|
|
OrNull<ShareeRepo>? shareeRepo,
|
2022-01-25 11:08:13 +01:00
|
|
|
OrNull<FavoriteRepo>? favoriteRepo,
|
2022-01-28 20:34:38 +01:00
|
|
|
OrNull<TagRepo>? tagRepo,
|
2022-01-29 12:31:32 +01:00
|
|
|
OrNull<TaggedFileRepo>? taggedFileRepo,
|
2022-05-05 16:06:47 +02:00
|
|
|
OrNull<LocalFileRepo>? localFileRepo,
|
2021-12-07 19:42:25 +01:00
|
|
|
OrNull<AppDb>? appDb,
|
|
|
|
OrNull<Pref>? pref,
|
|
|
|
}) {
|
|
|
|
return DiContainer(
|
2022-01-22 18:00:53 +01:00
|
|
|
albumRepo: albumRepo == null ? _albumRepo : albumRepo.obj,
|
|
|
|
faceRepo: faceRepo == null ? _faceRepo : faceRepo.obj,
|
|
|
|
fileRepo: fileRepo == null ? _fileRepo : fileRepo.obj,
|
|
|
|
personRepo: personRepo == null ? _personRepo : personRepo.obj,
|
|
|
|
shareRepo: shareRepo == null ? _shareRepo : shareRepo.obj,
|
|
|
|
shareeRepo: shareeRepo == null ? _shareeRepo : shareeRepo.obj,
|
2022-01-25 11:08:13 +01:00
|
|
|
favoriteRepo: favoriteRepo == null ? _favoriteRepo : favoriteRepo.obj,
|
2022-01-28 20:34:38 +01:00
|
|
|
tagRepo: tagRepo == null ? _tagRepo : tagRepo.obj,
|
2022-01-29 12:31:32 +01:00
|
|
|
taggedFileRepo:
|
|
|
|
taggedFileRepo == null ? _taggedFileRepo : taggedFileRepo.obj,
|
2022-05-05 16:06:47 +02:00
|
|
|
localFileRepo: localFileRepo == null ? _localFileRepo : localFileRepo.obj,
|
2022-01-22 18:00:53 +01:00
|
|
|
appDb: appDb == null ? _appDb : appDb.obj,
|
|
|
|
pref: pref == null ? _pref : pref.obj,
|
2021-12-07 19:42:25 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-03 18:31:27 +01:00
|
|
|
AlbumRepo get albumRepo => _albumRepo!;
|
|
|
|
FaceRepo get faceRepo => _faceRepo!;
|
|
|
|
FileRepo get fileRepo => _fileRepo!;
|
|
|
|
PersonRepo get personRepo => _personRepo!;
|
|
|
|
ShareRepo get shareRepo => _shareRepo!;
|
|
|
|
ShareeRepo get shareeRepo => _shareeRepo!;
|
2022-01-25 11:08:13 +01:00
|
|
|
FavoriteRepo get favoriteRepo => _favoriteRepo!;
|
2022-01-28 20:34:38 +01:00
|
|
|
TagRepo get tagRepo => _tagRepo!;
|
2022-01-29 12:31:32 +01:00
|
|
|
TaggedFileRepo get taggedFileRepo => _taggedFileRepo!;
|
2022-05-05 16:06:47 +02:00
|
|
|
LocalFileRepo get localFileRepo => _localFileRepo!;
|
2021-12-03 18:31:27 +01:00
|
|
|
|
|
|
|
AppDb get appDb => _appDb!;
|
|
|
|
Pref get pref => _pref!;
|
|
|
|
|
|
|
|
final AlbumRepo? _albumRepo;
|
|
|
|
final FaceRepo? _faceRepo;
|
|
|
|
final FileRepo? _fileRepo;
|
|
|
|
final PersonRepo? _personRepo;
|
|
|
|
final ShareRepo? _shareRepo;
|
|
|
|
final ShareeRepo? _shareeRepo;
|
2022-01-25 11:08:13 +01:00
|
|
|
final FavoriteRepo? _favoriteRepo;
|
2022-01-28 20:34:38 +01:00
|
|
|
final TagRepo? _tagRepo;
|
2022-01-29 12:31:32 +01:00
|
|
|
final TaggedFileRepo? _taggedFileRepo;
|
2022-05-05 16:06:47 +02:00
|
|
|
final LocalFileRepo? _localFileRepo;
|
2021-12-03 18:31:27 +01:00
|
|
|
|
|
|
|
final AppDb? _appDb;
|
|
|
|
final Pref? _pref;
|
|
|
|
}
|