2023-03-25 04:44:53 +01:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2024-05-07 06:04:21 +02:00
|
|
|
import 'package:immich_mobile/widgets/asset_grid/asset_grid_data_structure.dart';
|
2024-05-02 22:59:14 +02:00
|
|
|
import 'package:immich_mobile/providers/app_settings.provider.dart';
|
|
|
|
import 'package:immich_mobile/services/app_settings.service.dart';
|
2024-05-01 04:36:40 +02:00
|
|
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
2023-11-13 16:54:41 +01:00
|
|
|
import 'package:immich_mobile/utils/renderlist_generator.dart';
|
2023-10-22 04:38:07 +02:00
|
|
|
import 'package:isar/isar.dart';
|
2023-03-25 04:44:53 +01:00
|
|
|
|
2023-05-17 19:36:02 +02:00
|
|
|
final renderListProvider =
|
|
|
|
FutureProvider.family<RenderList, List<Asset>>((ref, assets) {
|
|
|
|
final settings = ref.watch(appSettingsServiceProvider);
|
2023-03-25 04:44:53 +01:00
|
|
|
|
2023-05-17 19:36:02 +02:00
|
|
|
return RenderList.fromAssets(
|
|
|
|
assets,
|
2023-03-25 04:44:53 +01:00
|
|
|
GroupAssetsBy.values[settings.getSetting(AppSettingsEnum.groupAssetsBy)],
|
|
|
|
);
|
|
|
|
});
|
2023-10-22 04:38:07 +02:00
|
|
|
|
2024-01-05 22:23:58 +01:00
|
|
|
final renderListProviderWithGrouping =
|
|
|
|
FutureProvider.family<RenderList, (List<Asset>, GroupAssetsBy?)>(
|
|
|
|
(ref, args) {
|
|
|
|
final settings = ref.watch(appSettingsServiceProvider);
|
|
|
|
final grouping = args.$2 ??
|
|
|
|
GroupAssetsBy.values[settings.getSetting(AppSettingsEnum.groupAssetsBy)];
|
|
|
|
return RenderList.fromAssets(args.$1, grouping);
|
|
|
|
});
|
|
|
|
|
2023-10-22 04:38:07 +02:00
|
|
|
final renderListQueryProvider = StreamProvider.family<RenderList,
|
|
|
|
QueryBuilder<Asset, Asset, QAfterSortBy>?>(
|
2023-11-13 16:54:41 +01:00
|
|
|
(ref, query) =>
|
|
|
|
query == null ? const Stream.empty() : renderListGenerator(query, ref),
|
2023-10-22 04:38:07 +02:00
|
|
|
);
|