瀏覽代碼

AlbumSort: Add option in overflow menu for sorting

Neeraj Gupta 2 年之前
父節點
當前提交
e540430c45

+ 3 - 0
lib/generated/intl/messages_en.dart

@@ -1096,6 +1096,9 @@ class MessageLookup extends MessageLookupByLibrary {
         "sorryWeCouldNotGenerateSecureKeysOnThisDevicennplease":
             MessageLookupByLibrary.simpleMessage(
                 "Sorry, we could not generate secure keys on this device.\n\nplease sign up from a different device."),
+        "sortAlbumsBy": MessageLookupByLibrary.simpleMessage("Sort by"),
+        "sortNewestFirst": MessageLookupByLibrary.simpleMessage("Newest first"),
+        "sortOldestFirst": MessageLookupByLibrary.simpleMessage("Oldest first"),
         "sparkleSuccess": MessageLookupByLibrary.simpleMessage("✨ Success"),
         "startBackup": MessageLookupByLibrary.simpleMessage("Start backup"),
         "storage": MessageLookupByLibrary.simpleMessage("Storage"),

+ 30 - 0
lib/generated/l10n.dart

@@ -5233,6 +5233,36 @@ class S {
     );
   }
 
+  /// `Sort by`
+  String get sortAlbumsBy {
+    return Intl.message(
+      'Sort by',
+      name: 'sortAlbumsBy',
+      desc: '',
+      args: [],
+    );
+  }
+
+  /// `Newest first`
+  String get sortNewestFirst {
+    return Intl.message(
+      'Newest first',
+      name: 'sortNewestFirst',
+      desc: '',
+      args: [],
+    );
+  }
+
+  /// `Oldest first`
+  String get sortOldestFirst {
+    return Intl.message(
+      'Oldest first',
+      name: 'sortOldestFirst',
+      desc: '',
+      args: [],
+    );
+  }
+
   /// `Rename`
   String get rename {
     return Intl.message(

+ 3 - 0
lib/l10n/intl_en.arb

@@ -748,6 +748,9 @@
   },
   "deleteAll": "Delete All",
   "renameAlbum": "Rename album",
+  "sortAlbumsBy": "Sort by",
+  "sortNewestFirst": "Newest first",
+  "sortOldestFirst": "Oldest first",
   "rename": "Rename",
   "leaveSharedAlbum": "Leave shared album?",
   "leaveAlbum": "Leave album",

+ 43 - 0
lib/ui/viewer/gallery/gallery_app_bar_widget.dart

@@ -303,6 +303,22 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
         );
       }
       if (widget.collection!.type != CollectionType.favorites) {
+        items.add(
+          PopupMenuItem(
+            value: 6,
+            child: Row(
+              children: [
+                const Icon(Icons.sort_outlined),
+                const Padding(
+                  padding: EdgeInsets.all(8),
+                ),
+                Text(
+                  S.of(context).sortAlbumsBy,
+                ),
+              ],
+            ),
+          ),
+        );
         items.add(
           PopupMenuItem(
             value: 3,
@@ -375,6 +391,8 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
               await _leaveAlbum(context);
             } else if (value == 5) {
               await _deleteBackedUpFiles(context);
+            } else if (value == 6) {
+              await _showSortOption(context);
             } else {
               showToast(context, S.of(context).somethingWentWrong);
             }
@@ -386,6 +404,31 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
     return actions;
   }
 
+  Future<void> _showSortOption(BuildContext bContext) async {
+    final bool? sortByAsc = await showMenu<bool>(
+      context: bContext,
+      position: RelativeRect.fromLTRB(
+        MediaQuery.of(context).size.width,
+        kToolbarHeight + 12,
+        12,
+        0,
+      ),
+      items: [
+        PopupMenuItem(
+          value: false,
+          child: Text(S.of(context).sortNewestFirst),
+        ),
+        PopupMenuItem(
+          value: true,
+          child: Text(S.of(context).sortOldestFirst),
+        ),
+      ],
+    );
+    if (sortByAsc != null) {
+      showShortToast(context, "coming soon");
+    }
+  }
+
   Future<void> _trashCollection() async {
     final collectionWithThumbnail =
         await CollectionsService.instance.getCollectionsWithThumbnails();