mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 20:36:48 +01:00
fix(mobile): handle shared assets in viewer (#4679)
Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
parent
c653e0f261
commit
2a2c74e081
7 changed files with 60 additions and 24 deletions
|
@ -265,6 +265,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
||||||
if (data.isRemote) buildControlButton(data),
|
if (data.isRemote) buildControlButton(data),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
isOwner: userId == data.ownerId,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -15,6 +15,7 @@ class TopControlAppBar extends HookConsumerWidget {
|
||||||
required this.isPlayingMotionVideo,
|
required this.isPlayingMotionVideo,
|
||||||
required this.onFavorite,
|
required this.onFavorite,
|
||||||
required this.onUploadPressed,
|
required this.onUploadPressed,
|
||||||
|
required this.isOwner,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Asset asset;
|
final Asset asset;
|
||||||
|
@ -25,6 +26,7 @@ class TopControlAppBar extends HookConsumerWidget {
|
||||||
final VoidCallback onAddToAlbumPressed;
|
final VoidCallback onAddToAlbumPressed;
|
||||||
final Function(Asset) onFavorite;
|
final Function(Asset) onFavorite;
|
||||||
final bool isPlayingMotionVideo;
|
final bool isPlayingMotionVideo;
|
||||||
|
final bool isOwner;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
@ -123,11 +125,11 @@ class TopControlAppBar extends HookConsumerWidget {
|
||||||
size: iconSize,
|
size: iconSize,
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
if (asset.isRemote) buildFavoriteButton(a),
|
if (asset.isRemote && isOwner) buildFavoriteButton(a),
|
||||||
if (asset.livePhotoVideoId != null) buildLivePhotoButton(),
|
if (asset.livePhotoVideoId != null) buildLivePhotoButton(),
|
||||||
if (asset.isLocal && !asset.isRemote) buildUploadButton(),
|
if (asset.isLocal && !asset.isRemote) buildUploadButton(),
|
||||||
if (asset.isRemote && !asset.isLocal) buildDownloadButton(),
|
if (asset.isRemote && !asset.isLocal && isOwner) buildDownloadButton(),
|
||||||
if (asset.isRemote) buildAddToAlbumButtom(),
|
if (asset.isRemote && isOwner) buildAddToAlbumButtom(),
|
||||||
buildMoreInfoButton(),
|
buildMoreInfoButton(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,6 +48,7 @@ class GalleryViewerPage extends HookConsumerWidget {
|
||||||
final int initialIndex;
|
final int initialIndex;
|
||||||
final int heroOffset;
|
final int heroOffset;
|
||||||
final bool showStack;
|
final bool showStack;
|
||||||
|
final bool isOwner;
|
||||||
|
|
||||||
GalleryViewerPage({
|
GalleryViewerPage({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -56,6 +57,7 @@ class GalleryViewerPage extends HookConsumerWidget {
|
||||||
required this.totalAssets,
|
required this.totalAssets,
|
||||||
this.heroOffset = 0,
|
this.heroOffset = 0,
|
||||||
this.showStack = false,
|
this.showStack = false,
|
||||||
|
this.isOwner = true,
|
||||||
}) : controller = PageController(initialPage: initialIndex);
|
}) : controller = PageController(initialPage: initialIndex);
|
||||||
|
|
||||||
final PageController controller;
|
final PageController controller;
|
||||||
|
@ -334,6 +336,7 @@ class GalleryViewerPage extends HookConsumerWidget {
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.black.withOpacity(0.4),
|
color: Colors.black.withOpacity(0.4),
|
||||||
child: TopControlAppBar(
|
child: TopControlAppBar(
|
||||||
|
isOwner: isOwner,
|
||||||
isPlayingMotionVideo: isPlayingMotionVideo.value,
|
isPlayingMotionVideo: isPlayingMotionVideo.value,
|
||||||
asset: asset(),
|
asset: asset(),
|
||||||
onMoreInfoPressed: showInfo,
|
onMoreInfoPressed: showInfo,
|
||||||
|
@ -573,6 +576,7 @@ class GalleryViewerPage extends HookConsumerWidget {
|
||||||
label: 'control_bottom_app_bar_share'.tr(),
|
label: 'control_bottom_app_bar_share'.tr(),
|
||||||
tooltip: 'control_bottom_app_bar_share'.tr(),
|
tooltip: 'control_bottom_app_bar_share'.tr(),
|
||||||
),
|
),
|
||||||
|
if (isOwner)
|
||||||
asset().isArchived
|
asset().isArchived
|
||||||
? BottomNavigationBarItem(
|
? BottomNavigationBarItem(
|
||||||
icon: const Icon(Icons.unarchive_rounded),
|
icon: const Icon(Icons.unarchive_rounded),
|
||||||
|
@ -584,24 +588,38 @@ class GalleryViewerPage extends HookConsumerWidget {
|
||||||
label: 'control_bottom_app_bar_archive'.tr(),
|
label: 'control_bottom_app_bar_archive'.tr(),
|
||||||
tooltip: 'control_bottom_app_bar_archive'.tr(),
|
tooltip: 'control_bottom_app_bar_archive'.tr(),
|
||||||
),
|
),
|
||||||
if (stack.isNotEmpty)
|
if (isOwner && stack.isNotEmpty)
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: const Icon(Icons.burst_mode_outlined),
|
icon: const Icon(Icons.burst_mode_outlined),
|
||||||
label: 'control_bottom_app_bar_stack'.tr(),
|
label: 'control_bottom_app_bar_stack'.tr(),
|
||||||
tooltip: 'control_bottom_app_bar_stack'.tr(),
|
tooltip: 'control_bottom_app_bar_stack'.tr(),
|
||||||
),
|
),
|
||||||
|
if (isOwner)
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: const Icon(Icons.delete_outline),
|
icon: const Icon(Icons.delete_outline),
|
||||||
label: 'control_bottom_app_bar_delete'.tr(),
|
label: 'control_bottom_app_bar_delete'.tr(),
|
||||||
tooltip: 'control_bottom_app_bar_delete'.tr(),
|
tooltip: 'control_bottom_app_bar_delete'.tr(),
|
||||||
),
|
),
|
||||||
|
if (!isOwner)
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: const Icon(Icons.download_outlined),
|
||||||
|
label: 'download'.tr(),
|
||||||
|
tooltip: 'download'.tr(),
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
List<Function(int)> actionslist = [
|
List<Function(int)> actionslist = [
|
||||||
(_) => shareAsset(),
|
(_) => shareAsset(),
|
||||||
(_) => handleArchive(asset()),
|
if (isOwner) (_) => handleArchive(asset()),
|
||||||
if (stack.isNotEmpty) (_) => showStackActionItems(),
|
if (isOwner && stack.isNotEmpty) (_) => showStackActionItems(),
|
||||||
(_) => handleDelete(asset()),
|
if (isOwner) (_) => handleDelete(asset()),
|
||||||
|
if (!isOwner)
|
||||||
|
(_) => asset().isLocal
|
||||||
|
? null
|
||||||
|
: ref.watch(imageViewerStateProvider.notifier).downloadAsset(
|
||||||
|
asset(),
|
||||||
|
context,
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
return IgnorePointer(
|
return IgnorePointer(
|
||||||
|
|
|
@ -33,6 +33,7 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
||||||
final bool shrinkWrap;
|
final bool shrinkWrap;
|
||||||
final bool showDragScroll;
|
final bool showDragScroll;
|
||||||
final bool showStack;
|
final bool showStack;
|
||||||
|
final bool isOwner;
|
||||||
|
|
||||||
const ImmichAssetGrid({
|
const ImmichAssetGrid({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -53,6 +54,7 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
||||||
this.shrinkWrap = false,
|
this.shrinkWrap = false,
|
||||||
this.showDragScroll = true,
|
this.showDragScroll = true,
|
||||||
this.showStack = false,
|
this.showStack = false,
|
||||||
|
this.isOwner = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -117,6 +119,7 @@ class ImmichAssetGrid extends HookConsumerWidget {
|
||||||
shrinkWrap: shrinkWrap,
|
shrinkWrap: shrinkWrap,
|
||||||
showDragScroll: showDragScroll,
|
showDragScroll: showDragScroll,
|
||||||
showStack: showStack,
|
showStack: showStack,
|
||||||
|
isOwner: isOwner,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ImmichAssetGridView extends StatefulWidget {
|
||||||
final bool shrinkWrap;
|
final bool shrinkWrap;
|
||||||
final bool showDragScroll;
|
final bool showDragScroll;
|
||||||
final bool showStack;
|
final bool showStack;
|
||||||
|
final bool isOwner;
|
||||||
|
|
||||||
const ImmichAssetGridView({
|
const ImmichAssetGridView({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -58,6 +59,7 @@ class ImmichAssetGridView extends StatefulWidget {
|
||||||
this.shrinkWrap = false,
|
this.shrinkWrap = false,
|
||||||
this.showDragScroll = true,
|
this.showDragScroll = true,
|
||||||
this.showStack = false,
|
this.showStack = false,
|
||||||
|
this.isOwner = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -138,6 +140,7 @@ class ImmichAssetGridViewState extends State<ImmichAssetGridView> {
|
||||||
showStorageIndicator: widget.showStorageIndicator,
|
showStorageIndicator: widget.showStorageIndicator,
|
||||||
heroOffset: widget.heroOffset,
|
heroOffset: widget.heroOffset,
|
||||||
showStack: widget.showStack,
|
showStack: widget.showStack,
|
||||||
|
isOwner: widget.isOwner,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ThumbnailImage extends StatelessWidget {
|
||||||
final int totalAssets;
|
final int totalAssets;
|
||||||
final bool showStorageIndicator;
|
final bool showStorageIndicator;
|
||||||
final bool showStack;
|
final bool showStack;
|
||||||
|
final bool isOwner;
|
||||||
final bool useGrayBoxPlaceholder;
|
final bool useGrayBoxPlaceholder;
|
||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
final bool multiselectEnabled;
|
final bool multiselectEnabled;
|
||||||
|
@ -29,6 +30,7 @@ class ThumbnailImage extends StatelessWidget {
|
||||||
required this.totalAssets,
|
required this.totalAssets,
|
||||||
this.showStorageIndicator = true,
|
this.showStorageIndicator = true,
|
||||||
this.showStack = false,
|
this.showStack = false,
|
||||||
|
this.isOwner = true,
|
||||||
this.useGrayBoxPlaceholder = false,
|
this.useGrayBoxPlaceholder = false,
|
||||||
this.isSelected = false,
|
this.isSelected = false,
|
||||||
this.multiselectEnabled = false,
|
this.multiselectEnabled = false,
|
||||||
|
@ -181,6 +183,7 @@ class ThumbnailImage extends StatelessWidget {
|
||||||
totalAssets: totalAssets,
|
totalAssets: totalAssets,
|
||||||
heroOffset: heroOffset,
|
heroOffset: heroOffset,
|
||||||
showStack: showStack,
|
showStack: showStack,
|
||||||
|
isOwner: isOwner,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ class _$AppRouter extends RootStackRouter {
|
||||||
totalAssets: args.totalAssets,
|
totalAssets: args.totalAssets,
|
||||||
heroOffset: args.heroOffset,
|
heroOffset: args.heroOffset,
|
||||||
showStack: args.showStack,
|
showStack: args.showStack,
|
||||||
|
isOwner: args.isOwner,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -749,6 +750,7 @@ class GalleryViewerRoute extends PageRouteInfo<GalleryViewerRouteArgs> {
|
||||||
required int totalAssets,
|
required int totalAssets,
|
||||||
int heroOffset = 0,
|
int heroOffset = 0,
|
||||||
bool showStack = false,
|
bool showStack = false,
|
||||||
|
bool isOwner = true,
|
||||||
}) : super(
|
}) : super(
|
||||||
GalleryViewerRoute.name,
|
GalleryViewerRoute.name,
|
||||||
path: '/gallery-viewer-page',
|
path: '/gallery-viewer-page',
|
||||||
|
@ -759,6 +761,7 @@ class GalleryViewerRoute extends PageRouteInfo<GalleryViewerRouteArgs> {
|
||||||
totalAssets: totalAssets,
|
totalAssets: totalAssets,
|
||||||
heroOffset: heroOffset,
|
heroOffset: heroOffset,
|
||||||
showStack: showStack,
|
showStack: showStack,
|
||||||
|
isOwner: isOwner,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -773,6 +776,7 @@ class GalleryViewerRouteArgs {
|
||||||
required this.totalAssets,
|
required this.totalAssets,
|
||||||
this.heroOffset = 0,
|
this.heroOffset = 0,
|
||||||
this.showStack = false,
|
this.showStack = false,
|
||||||
|
this.isOwner = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Key? key;
|
final Key? key;
|
||||||
|
@ -787,9 +791,11 @@ class GalleryViewerRouteArgs {
|
||||||
|
|
||||||
final bool showStack;
|
final bool showStack;
|
||||||
|
|
||||||
|
final bool isOwner;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'GalleryViewerRouteArgs{key: $key, initialIndex: $initialIndex, loadAsset: $loadAsset, totalAssets: $totalAssets, heroOffset: $heroOffset, showStack: $showStack}';
|
return 'GalleryViewerRouteArgs{key: $key, initialIndex: $initialIndex, loadAsset: $loadAsset, totalAssets: $totalAssets, heroOffset: $heroOffset, showStack: $showStack, isOwner: $isOwner}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue