mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(mobile): add AssetState and proper asset updating (#2270)
* refactor(mobile): add AssetState and proper asset updating * generate files --------- Co-authored-by: Fynn Petersen-Frey <zoodyy@users.noreply.github.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
b970a40b4e
commit
e80d37bf8f
14 changed files with 256 additions and 98 deletions
|
|
@ -6,6 +6,7 @@ import 'package:immich_mobile/modules/album/providers/asset_selection.provider.d
|
|||
import 'package:immich_mobile/routing/router.dart';
|
||||
import 'package:immich_mobile/shared/models/asset.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_image.dart';
|
||||
import 'package:immich_mobile/utils/storage_indicator.dart';
|
||||
|
||||
class AlbumViewerThumbnail extends HookConsumerWidget {
|
||||
final Asset asset;
|
||||
|
|
@ -85,11 +86,7 @@ class AlbumViewerThumbnail extends HookConsumerWidget {
|
|||
right: 10,
|
||||
bottom: 5,
|
||||
child: Icon(
|
||||
asset.isRemote
|
||||
? (asset.isLocal
|
||||
? Icons.cloud_done_outlined
|
||||
: Icons.cloud_outlined)
|
||||
: Icons.cloud_off_outlined,
|
||||
storageIcon(asset),
|
||||
color: Colors.white,
|
||||
size: 18,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ArchiveSelectionNotifier extends StateNotifier<Set<int>> {
|
|||
}
|
||||
|
||||
Future<void> toggleArchive(Asset asset) async {
|
||||
if (!asset.isRemote) return;
|
||||
if (asset.storage == AssetState.local) return;
|
||||
|
||||
_setArchiveForAssetId(asset.id, !_isArchive(asset.id));
|
||||
|
||||
|
|
|
|||
|
|
@ -65,42 +65,44 @@ class ArchivePage extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
Widget buildBottomBar() {
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SizedBox(
|
||||
height: 64,
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
leading: const Icon(
|
||||
Icons.unarchive_rounded,
|
||||
),
|
||||
title:
|
||||
const Text("Unarchive", style: TextStyle(fontSize: 14)),
|
||||
onTap: () {
|
||||
if (selection.value.isNotEmpty) {
|
||||
ref
|
||||
.watch(assetProvider.notifier)
|
||||
.toggleArchive(selection.value, false);
|
||||
return SafeArea(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: SizedBox(
|
||||
height: 64,
|
||||
child: Card(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
leading: const Icon(
|
||||
Icons.unarchive_rounded,
|
||||
),
|
||||
title:
|
||||
const Text("Unarchive", style: TextStyle(fontSize: 14)),
|
||||
onTap: () {
|
||||
if (selection.value.isNotEmpty) {
|
||||
ref
|
||||
.watch(assetProvider.notifier)
|
||||
.toggleArchive(selection.value, false);
|
||||
|
||||
final assetOrAssets =
|
||||
selection.value.length > 1 ? 'assets' : 'asset';
|
||||
ImmichToast.show(
|
||||
context: context,
|
||||
msg:
|
||||
'Moved ${selection.value.length} $assetOrAssets to library',
|
||||
gravity: ToastGravity.CENTER,
|
||||
);
|
||||
}
|
||||
final assetOrAssets =
|
||||
selection.value.length > 1 ? 'assets' : 'asset';
|
||||
ImmichToast.show(
|
||||
context: context,
|
||||
msg:
|
||||
'Moved ${selection.value.length} $assetOrAssets to library',
|
||||
gravity: ToastGravity.CENTER,
|
||||
);
|
||||
}
|
||||
|
||||
selectionEnabledHook.value = false;
|
||||
},
|
||||
)
|
||||
],
|
||||
selectionEnabledHook.value = false;
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class FavoriteSelectionNotifier extends StateNotifier<Set<int>> {
|
|||
}
|
||||
|
||||
Future<void> toggleFavorite(Asset asset) async {
|
||||
if (!asset.isRemote) return; // TODO support local favorite assets
|
||||
|
||||
// TODO support local favorite assets
|
||||
if (asset.storage == AssetState.local) return;
|
||||
_setFavoriteForAssetId(asset.id, !_isFavorite(asset.id));
|
||||
|
||||
await assetNotifier.toggleFavorite(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:immich_mobile/modules/favorite/providers/favorite_provider.dart'
|
|||
import 'package:immich_mobile/routing/router.dart';
|
||||
import 'package:immich_mobile/shared/models/asset.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_image.dart';
|
||||
import 'package:immich_mobile/utils/storage_indicator.dart';
|
||||
|
||||
class ThumbnailImage extends HookConsumerWidget {
|
||||
final Asset asset;
|
||||
|
|
@ -124,11 +125,7 @@ class ThumbnailImage extends HookConsumerWidget {
|
|||
right: 10,
|
||||
bottom: 5,
|
||||
child: Icon(
|
||||
asset.isRemote
|
||||
? (asset.isLocal
|
||||
? Icons.cloud_done_outlined
|
||||
: Icons.cloud_outlined)
|
||||
: Icons.cloud_off_outlined,
|
||||
storageIcon(asset),
|
||||
color: Colors.white,
|
||||
size: 18,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue