From 1ba93cdd1961c298c4767851c25bb8f6fd109cae Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Wed, 14 Oct 2020 19:07:48 +0900 Subject: [PATCH] fullscreen: rotate & flip in one menu row --- lib/widgets/common/entry_actions.dart | 7 ++-- .../fullscreen/info/metadata_thumbnail.dart | 1 + lib/widgets/fullscreen/overlay/top.dart | 35 +++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/lib/widgets/common/entry_actions.dart b/lib/widgets/common/entry_actions.dart index 5376728b9..2fadd1889 100644 --- a/lib/widgets/common/entry_actions.dart +++ b/lib/widgets/common/entry_actions.dart @@ -30,9 +30,6 @@ class EntryActions { EntryAction.share, EntryAction.delete, EntryAction.rename, - EntryAction.rotateCCW, - EntryAction.rotateCW, - EntryAction.flip, EntryAction.print, ]; @@ -58,9 +55,9 @@ extension ExtraEntryAction on EntryAction { case EntryAction.rename: return 'Rename'; case EntryAction.rotateCCW: - return 'Rotate left'; + return 'Rotate counterclockwise'; case EntryAction.rotateCW: - return 'Rotate right'; + return 'Rotate clockwise'; case EntryAction.flip: return 'Flip horizontally'; case EntryAction.print: diff --git a/lib/widgets/fullscreen/info/metadata_thumbnail.dart b/lib/widgets/fullscreen/info/metadata_thumbnail.dart index f7475e0c2..da9d4507b 100644 --- a/lib/widgets/fullscreen/info/metadata_thumbnail.dart +++ b/lib/widgets/fullscreen/info/metadata_thumbnail.dart @@ -50,6 +50,7 @@ class _MetadataThumbnailsState extends State { future: _loader, builder: (context, snapshot) { if (!snapshot.hasError && snapshot.connectionState == ConnectionState.done && snapshot.data.isNotEmpty) { + // TODO TLAD apply the rotation to Exif thumbnail only, on Android side final turns = (entry.rotationDegrees / 90).round(); final devicePixelRatio = MediaQuery.of(context).devicePixelRatio; return Container( diff --git a/lib/widgets/fullscreen/overlay/top.dart b/lib/widgets/fullscreen/overlay/top.dart index cb7579d2f..a67555a03 100644 --- a/lib/widgets/fullscreen/overlay/top.dart +++ b/lib/widgets/fullscreen/overlay/top.dart @@ -137,6 +137,7 @@ class _TopOverlayRow extends StatelessWidget { key: Key('entry-menu-button'), itemBuilder: (context) => [ ...inAppActions.map(_buildPopupMenuItem), + if (entry.canRotateAndFlip) _buildRotateAndFlipMenuItems(), PopupMenuDivider(), ...externalAppActions.map(_buildPopupMenuItem), if (kDebugMode) ...[ @@ -227,6 +228,40 @@ class _TopOverlayRow extends StatelessWidget { child: child, ); } + + PopupMenuItem _buildRotateAndFlipMenuItems() { + Widget buildDivider() => SizedBox( + height: 16, + child: VerticalDivider( + width: 1, + thickness: 1, + ), + ); + + Widget buildItem(EntryAction action) => Expanded( + child: PopupMenuItem( + value: action, + child: Tooltip( + message: action.getText(), + child: Center(child: Icon(action.getIcon())), + ), + ), + ); + + return PopupMenuItem( + child: Row( + children: [ + buildDivider(), + buildItem(EntryAction.rotateCCW), + buildDivider(), + buildItem(EntryAction.rotateCW), + buildDivider(), + buildItem(EntryAction.flip), + buildDivider(), + ], + ), + ); + } } class _FavouriteToggler extends StatefulWidget {