@@ -3,11 +3,9 @@ import 'package:easy_localization/easy_localization.dart';
3
3
import 'package:flutter/material.dart' ;
4
4
import 'package:flutter_hooks/flutter_hooks.dart' ;
5
5
import 'package:hooks_riverpod/hooks_riverpod.dart' ;
6
- import 'package:immich_mobile/domain/models/local_album.model.dart' ;
7
6
import 'package:immich_mobile/extensions/build_context_extensions.dart' ;
8
7
import 'package:immich_mobile/providers/album/album.provider.dart' ;
9
8
import 'package:immich_mobile/providers/backup/backup.provider.dart' ;
10
- import 'package:immich_mobile/providers/backup/backup_album.provider.dart' ;
11
9
import 'package:immich_mobile/services/app_settings.service.dart' ;
12
10
import 'package:immich_mobile/utils/hooks/app_settings_update_hook.dart' ;
13
11
import 'package:immich_mobile/widgets/backup/album_info_card.dart' ;
@@ -19,17 +17,12 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
19
17
const BackupAlbumSelectionPage ({super .key});
20
18
@override
21
19
Widget build (BuildContext context, WidgetRef ref) {
22
- final albums = ref.watch (backupAlbumProvider);
23
-
24
- final selectedBackupAlbums = albums
25
- .where ((album) => album.backupSelection == BackupSelection .selected)
26
- .toList ();
27
- final excludedBackupAlbums = albums
28
- .where ((album) => album.backupSelection == BackupSelection .excluded)
29
- .toList ();
20
+ final selectedBackupAlbums = ref.watch (backupProvider).selectedBackupAlbums;
21
+ final excludedBackupAlbums = ref.watch (backupProvider).excludedBackupAlbums;
30
22
final enableSyncUploadAlbum =
31
23
useAppSettingsState (AppSettingsEnum .syncAlbums);
32
24
final isDarkTheme = context.isDarkTheme;
25
+ final albums = ref.watch (backupProvider).availableAlbums;
33
26
34
27
useEffect (
35
28
() {
@@ -92,9 +85,8 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
92
85
93
86
buildSelectedAlbumNameChip () {
94
87
return selectedBackupAlbums.map ((album) {
95
- void removeSelection () {
96
- ref.read (backupAlbumProvider.notifier).deselectAlbum (album);
97
- }
88
+ void removeSelection () =>
89
+ ref.read (backupProvider.notifier).removeAlbumForBackup (album);
98
90
99
91
return Padding (
100
92
padding: const EdgeInsets .only (right: 8.0 ),
@@ -125,7 +117,9 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
125
117
buildExcludedAlbumNameChip () {
126
118
return excludedBackupAlbums.map ((album) {
127
119
void removeSelection () {
128
- ref.read (backupAlbumProvider.notifier).deselectAlbum (album);
120
+ ref
121
+ .watch (backupProvider.notifier)
122
+ .removeExcludedAlbumForBackup (album);
129
123
}
130
124
131
125
return GestureDetector (
@@ -174,131 +168,129 @@ class BackupAlbumSelectionPage extends HookConsumerWidget {
174
168
).tr (),
175
169
elevation: 0 ,
176
170
),
177
- body: SafeArea (
178
- child: CustomScrollView (
179
- physics: const ClampingScrollPhysics (),
180
- slivers: [
181
- SliverToBoxAdapter (
182
- child: Column (
183
- crossAxisAlignment: CrossAxisAlignment .start,
184
- children: [
185
- Padding (
186
- padding: const EdgeInsets .symmetric (
187
- vertical: 8.0 ,
188
- horizontal: 16.0 ,
189
- ),
190
- child: Text (
191
- "backup_album_selection_page_selection_info" ,
192
- style: context.textTheme.titleSmall,
193
- ).tr (),
171
+ body: CustomScrollView (
172
+ physics: const ClampingScrollPhysics (),
173
+ slivers: [
174
+ SliverToBoxAdapter (
175
+ child: Column (
176
+ crossAxisAlignment: CrossAxisAlignment .start,
177
+ children: [
178
+ Padding (
179
+ padding: const EdgeInsets .symmetric (
180
+ vertical: 8.0 ,
181
+ horizontal: 16.0 ,
194
182
),
195
- // Selected Album Chips
183
+ child: Text (
184
+ "backup_album_selection_page_selection_info" ,
185
+ style: context.textTheme.titleSmall,
186
+ ).tr (),
187
+ ),
188
+ // Selected Album Chips
196
189
197
- Padding (
198
- padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
199
- child: Wrap (
200
- children: [
201
- ...buildSelectedAlbumNameChip (),
202
- ...buildExcludedAlbumNameChip (),
203
- ],
204
- ),
190
+ Padding (
191
+ padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
192
+ child: Wrap (
193
+ children: [
194
+ ...buildSelectedAlbumNameChip (),
195
+ ...buildExcludedAlbumNameChip (),
196
+ ],
205
197
),
198
+ ),
206
199
207
- SettingsSwitchListTile (
208
- valueNotifier: enableSyncUploadAlbum,
209
- title: "sync_albums" .tr (),
210
- subtitle: "sync_upload_album_setting_subtitle" .tr (),
211
- contentPadding: const EdgeInsets .symmetric (horizontal: 16 ),
212
- titleStyle: context.textTheme.bodyLarge? .copyWith (
213
- fontWeight: FontWeight .bold,
214
- ),
215
- subtitleStyle: context.textTheme.labelLarge? .copyWith (
216
- color: context.colorScheme.primary,
217
- ),
218
- onChanged: handleSyncAlbumToggle,
200
+ SettingsSwitchListTile (
201
+ valueNotifier: enableSyncUploadAlbum,
202
+ title: "sync_albums" .tr (),
203
+ subtitle: "sync_upload_album_setting_subtitle" .tr (),
204
+ contentPadding: const EdgeInsets .symmetric (horizontal: 16 ),
205
+ titleStyle: context.textTheme.bodyLarge? .copyWith (
206
+ fontWeight: FontWeight .bold,
207
+ ),
208
+ subtitleStyle: context.textTheme.labelLarge? .copyWith (
209
+ color: context.colorScheme.primary,
219
210
),
211
+ onChanged: handleSyncAlbumToggle,
212
+ ),
220
213
221
- ListTile (
222
- title: Text (
223
- "backup_album_selection_page_albums_device" .tr (
224
- namedArgs: {
225
- 'count' : ref
226
- .watch (backupProvider)
227
- .availableAlbums
228
- .length
229
- .toString (),
230
- },
231
- ),
232
- style: context.textTheme.titleSmall,
233
- ),
234
- subtitle: Padding (
235
- padding: const EdgeInsets .symmetric (vertical: 8.0 ),
236
- child: Text (
237
- "backup_album_selection_page_albums_tap" ,
238
- style: context.textTheme.labelLarge? .copyWith (
239
- color: context.primaryColor,
240
- ),
241
- ).tr (),
214
+ ListTile (
215
+ title: Text (
216
+ "backup_album_selection_page_albums_device" .tr (
217
+ namedArgs: {
218
+ 'count' : ref
219
+ .watch (backupProvider)
220
+ .availableAlbums
221
+ .length
222
+ .toString (),
223
+ },
242
224
),
243
- trailing: IconButton (
244
- splashRadius: 16 ,
245
- icon: Icon (
246
- Icons .info,
247
- size: 20 ,
225
+ style: context.textTheme.titleSmall,
226
+ ),
227
+ subtitle: Padding (
228
+ padding: const EdgeInsets .symmetric (vertical: 8.0 ),
229
+ child: Text (
230
+ "backup_album_selection_page_albums_tap" ,
231
+ style: context.textTheme.labelLarge? .copyWith (
248
232
color: context.primaryColor,
249
233
),
250
- onPressed: () {
251
- // show the dialog
252
- showDialog (
253
- context: context,
254
- builder: (BuildContext context) {
255
- return AlertDialog (
256
- shape: RoundedRectangleBorder (
257
- borderRadius: BorderRadius .circular (10 ),
234
+ ).tr (),
235
+ ),
236
+ trailing: IconButton (
237
+ splashRadius: 16 ,
238
+ icon: Icon (
239
+ Icons .info,
240
+ size: 20 ,
241
+ color: context.primaryColor,
242
+ ),
243
+ onPressed: () {
244
+ // show the dialog
245
+ showDialog (
246
+ context: context,
247
+ builder: (BuildContext context) {
248
+ return AlertDialog (
249
+ shape: RoundedRectangleBorder (
250
+ borderRadius: BorderRadius .circular (10 ),
251
+ ),
252
+ elevation: 5 ,
253
+ title: Text (
254
+ 'backup_album_selection_page_selection_info' ,
255
+ style: TextStyle (
256
+ fontSize: 16 ,
257
+ fontWeight: FontWeight .bold,
258
+ color: context.primaryColor,
258
259
),
259
- elevation: 5 ,
260
- title: Text (
261
- 'backup_album_selection_page_selection_info' ,
262
- style: TextStyle (
263
- fontSize: 16 ,
264
- fontWeight: FontWeight .bold,
265
- color: context.primaryColor,
266
- ),
267
- ).tr (),
268
- content: SingleChildScrollView (
269
- child: ListBody (
270
- children: [
271
- const Text (
272
- 'backup_album_selection_page_assets_scatter' ,
273
- style: TextStyle (
274
- fontSize: 14 ,
275
- ),
276
- ).tr (),
277
- ],
278
- ),
260
+ ).tr (),
261
+ content: SingleChildScrollView (
262
+ child: ListBody (
263
+ children: [
264
+ const Text (
265
+ 'backup_album_selection_page_assets_scatter' ,
266
+ style: TextStyle (
267
+ fontSize: 14 ,
268
+ ),
269
+ ).tr (),
270
+ ],
279
271
),
280
- );
281
- },
282
- );
283
- },
284
- ) ,
272
+ ),
273
+ );
274
+ },
275
+ );
276
+ } ,
285
277
),
278
+ ),
286
279
287
- // buildSearchBar(),
288
- ],
289
- ),
290
- ),
291
- SliverLayoutBuilder (
292
- builder: (context, constraints) {
293
- if (constraints.crossAxisExtent > 600 ) {
294
- return buildAlbumSelectionGrid ();
295
- } else {
296
- return buildAlbumSelectionList ();
297
- }
298
- },
280
+ // buildSearchBar(),
281
+ ],
299
282
),
300
- ],
301
- ),
283
+ ),
284
+ SliverLayoutBuilder (
285
+ builder: (context, constraints) {
286
+ if (constraints.crossAxisExtent > 600 ) {
287
+ return buildAlbumSelectionGrid ();
288
+ } else {
289
+ return buildAlbumSelectionList ();
290
+ }
291
+ },
292
+ ),
293
+ ],
302
294
),
303
295
);
304
296
}
0 commit comments