import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/modules/home/models/home_page_state.model.dart'; import 'package:immich_mobile/shared/models/immich_asset.model.dart'; class HomePageStateNotifier extends StateNotifier { HomePageStateNotifier() : super( HomePageState( isMultiSelectEnable: false, selectedItems: {}, selectedDateGroup: {}, ), ); void addSelectedDateGroup(String dateGroupTitle) { state = state.copyWith(selectedDateGroup: {...state.selectedDateGroup, dateGroupTitle}); } void removeSelectedDateGroup(String dateGroupTitle) { var currentDateGroup = state.selectedDateGroup; currentDateGroup.removeWhere((e) => e == dateGroupTitle); state = state.copyWith(selectedDateGroup: currentDateGroup); } void enableMultiSelect(Set selectedItems) { state = state.copyWith(isMultiSelectEnable: true, selectedItems: selectedItems); } void disableMultiSelect() { state = state.copyWith(isMultiSelectEnable: false, selectedItems: {}, selectedDateGroup: {}); } void addSingleSelectedItem(ImmichAsset asset) { state = state.copyWith(selectedItems: {...state.selectedItems, asset}); } void addMultipleSelectedItems(List assets) { state = state.copyWith(selectedItems: {...state.selectedItems, ...assets}); } void removeSingleSelectedItem(ImmichAsset asset) { Set currentList = state.selectedItems; currentList.removeWhere((e) => e.id == asset.id); state = state.copyWith(selectedItems: currentList); } void removeMultipleSelectedItem(List assets) { Set currentList = state.selectedItems; for (ImmichAsset asset in assets) { currentList.removeWhere((e) => e.id == asset.id); } state = state.copyWith(selectedItems: currentList); } } final homePageStateProvider = StateNotifierProvider(((ref) => HomePageStateNotifier()));