Explorar o código

Show pinned collection on top in collection_action_sheet

Neeraj Gupta %!s(int64=2) %!d(string=hai) anos
pai
achega
0df67d570f
Modificáronse 1 ficheiros con 15 adicións e 6 borrados
  1. 15 6
      lib/ui/collections/collection_action_sheet.dart

+ 15 - 6
lib/ui/collections/collection_action_sheet.dart

@@ -253,18 +253,27 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
       // action can to be performed
       includeCollab: widget.actionType == CollectionActionType.addFiles,
     );
-    collections.removeWhere(
-      (element) => (element.type == CollectionType.favorites ||
-          element.type == CollectionType.uncategorized ||
-          element.isSharedFilesCollection()),
-    );
     collections.sort((first, second) {
       return compareAsciiLowerCaseNatural(
         first.displayName,
         second.displayName,
       );
     });
-    return collections;
+    final List<Collection> pinned = [];
+    final List<Collection> unpinned = [];
+    for (final collection in collections) {
+      if (collection.isSharedFilesCollection() ||
+          collection.type == CollectionType.favorites ||
+          collection.type == CollectionType.uncategorized) {
+        continue;
+      }
+      if (collection.isPinned) {
+        pinned.add(collection);
+      } else {
+        unpinned.add(collection);
+      }
+    }
+    return pinned + unpinned;
   }
 
   void _removeIncomingCollections(List<Collection> items) {