1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-04 02:46:47 +01:00
immich/mobile/lib/providers/asset_viewer/render_list.provider.dart
Alex 5806a3ce25
refactor(mobile): widgets (#9291)
* refactor(mobile): widgets

* update
2024-05-06 23:04:21 -05:00

32 lines
1.3 KiB
Dart

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/widgets/asset_grid/asset_grid_data_structure.dart';
import 'package:immich_mobile/providers/app_settings.provider.dart';
import 'package:immich_mobile/services/app_settings.service.dart';
import 'package:immich_mobile/entities/asset.entity.dart';
import 'package:immich_mobile/utils/renderlist_generator.dart';
import 'package:isar/isar.dart';
final renderListProvider =
FutureProvider.family<RenderList, List<Asset>>((ref, assets) {
final settings = ref.watch(appSettingsServiceProvider);
return RenderList.fromAssets(
assets,
GroupAssetsBy.values[settings.getSetting(AppSettingsEnum.groupAssetsBy)],
);
});
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);
});
final renderListQueryProvider = StreamProvider.family<RenderList,
QueryBuilder<Asset, Asset, QAfterSortBy>?>(
(ref, query) =>
query == null ? const Stream.empty() : renderListGenerator(query, ref),
);