From 8c756182b7ac6a02700ed7ab9b40a6c3e2a90fb1 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Fri, 20 Mar 2020 09:50:11 +0900 Subject: [PATCH] fullscreen: hide editing actions for non editable entries --- lib/model/image_entry.dart | 6 +++--- .../fullscreen/info/basic_section.dart | 2 -- lib/widgets/fullscreen/overlay/top.dart | 20 ++++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/model/image_entry.dart b/lib/model/image_entry.dart index eff354c93..23bdd98cf 100644 --- a/lib/model/image_entry.dart +++ b/lib/model/image_entry.dart @@ -103,11 +103,11 @@ class ImageEntry { bool get isCatalogued => catalogMetadata != null; + bool get canEdit => path != null; + bool get canPrint => !isVideo; - bool get canRename => path != null; - - bool get canRotate => mimeType == MimeTypes.MIME_JPEG || mimeType == MimeTypes.MIME_PNG; + bool get canRotate => canEdit && (mimeType == MimeTypes.MIME_JPEG || mimeType == MimeTypes.MIME_PNG); double get aspectRatio { if (width == 0 || height == 0) return 1; diff --git a/lib/widgets/fullscreen/info/basic_section.dart b/lib/widgets/fullscreen/info/basic_section.dart index d6d6e5601..1e8dde2d6 100644 --- a/lib/widgets/fullscreen/info/basic_section.dart +++ b/lib/widgets/fullscreen/info/basic_section.dart @@ -1,5 +1,3 @@ -import 'dart:collection'; - import 'package:aves/model/image_entry.dart'; import 'package:aves/utils/file_utils.dart'; import 'package:aves/widgets/fullscreen/info/info_page.dart'; diff --git a/lib/widgets/fullscreen/overlay/top.dart b/lib/widgets/fullscreen/overlay/top.dart index 29ecf052b..be7110c4a 100644 --- a/lib/widgets/fullscreen/overlay/top.dart +++ b/lib/widgets/fullscreen/overlay/top.dart @@ -45,15 +45,17 @@ class FullscreenTopOverlay extends StatelessWidget { tooltip: 'Share', ), ), - const SizedBox(width: 8), - OverlayButton( - scale: scale, - child: IconButton( - icon: Icon(OMIcons.delete), - onPressed: () => onActionSelected?.call(FullscreenAction.delete), - tooltip: 'Delete', + if (entry.canEdit) ...[ + const SizedBox(width: 8), + OverlayButton( + scale: scale, + child: IconButton( + icon: Icon(OMIcons.delete), + onPressed: () => onActionSelected?.call(FullscreenAction.delete), + tooltip: 'Delete', + ), ), - ), + ], const SizedBox(width: 8), OverlayButton( scale: scale, @@ -63,7 +65,7 @@ class FullscreenTopOverlay extends StatelessWidget { value: FullscreenAction.info, child: MenuRow(text: 'Info', icon: OMIcons.info), ), - if (entry.canRename) + if (entry.canEdit) PopupMenuItem( value: FullscreenAction.rename, child: MenuRow(text: 'Rename', icon: OMIcons.title),