fullscreen: hide editing actions for non editable entries

This commit is contained in:
Thibault Deckers 2020-03-20 09:50:11 +09:00
parent b48dc4cd56
commit 8c756182b7
3 changed files with 14 additions and 14 deletions

View file

@ -103,11 +103,11 @@ class ImageEntry {
bool get isCatalogued => catalogMetadata != null; bool get isCatalogued => catalogMetadata != null;
bool get canEdit => path != null;
bool get canPrint => !isVideo; bool get canPrint => !isVideo;
bool get canRename => path != null; bool get canRotate => canEdit && (mimeType == MimeTypes.MIME_JPEG || mimeType == MimeTypes.MIME_PNG);
bool get canRotate => mimeType == MimeTypes.MIME_JPEG || mimeType == MimeTypes.MIME_PNG;
double get aspectRatio { double get aspectRatio {
if (width == 0 || height == 0) return 1; if (width == 0 || height == 0) return 1;

View file

@ -1,5 +1,3 @@
import 'dart:collection';
import 'package:aves/model/image_entry.dart'; import 'package:aves/model/image_entry.dart';
import 'package:aves/utils/file_utils.dart'; import 'package:aves/utils/file_utils.dart';
import 'package:aves/widgets/fullscreen/info/info_page.dart'; import 'package:aves/widgets/fullscreen/info/info_page.dart';

View file

@ -45,15 +45,17 @@ class FullscreenTopOverlay extends StatelessWidget {
tooltip: 'Share', tooltip: 'Share',
), ),
), ),
const SizedBox(width: 8), if (entry.canEdit) ...[
OverlayButton( const SizedBox(width: 8),
scale: scale, OverlayButton(
child: IconButton( scale: scale,
icon: Icon(OMIcons.delete), child: IconButton(
onPressed: () => onActionSelected?.call(FullscreenAction.delete), icon: Icon(OMIcons.delete),
tooltip: 'Delete', onPressed: () => onActionSelected?.call(FullscreenAction.delete),
tooltip: 'Delete',
),
), ),
), ],
const SizedBox(width: 8), const SizedBox(width: 8),
OverlayButton( OverlayButton(
scale: scale, scale: scale,
@ -63,7 +65,7 @@ class FullscreenTopOverlay extends StatelessWidget {
value: FullscreenAction.info, value: FullscreenAction.info,
child: MenuRow(text: 'Info', icon: OMIcons.info), child: MenuRow(text: 'Info', icon: OMIcons.info),
), ),
if (entry.canRename) if (entry.canEdit)
PopupMenuItem( PopupMenuItem(
value: FullscreenAction.rename, value: FullscreenAction.rename,
child: MenuRow(text: 'Rename', icon: OMIcons.title), child: MenuRow(text: 'Rename', icon: OMIcons.title),