From bb79a674ad95ab954cd31d41612ae6af60373f9d Mon Sep 17 00:00:00 2001 From: ashilkn Date: Thu, 15 Sep 2022 16:55:41 +0530 Subject: [PATCH 1/2] non case sensitive sort for albums --- lib/ui/collections_gallery_widget.dart | 4 +++- lib/ui/create_collection_page.dart | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ui/collections_gallery_widget.dart b/lib/ui/collections_gallery_widget.dart index f5da4c785..0d0ecaee7 100644 --- a/lib/ui/collections_gallery_widget.dart +++ b/lib/ui/collections_gallery_widget.dart @@ -115,7 +115,9 @@ class _CollectionsGalleryWidgetState extends State (first, second) { if (sortKey == AlbumSortKey.albumName) { // alphabetical ASC order - return first.collection.name.compareTo(second.collection.name); + return first.collection.name + .toLowerCase() + .compareTo(second.collection.name.toLowerCase()); } else if (sortKey == AlbumSortKey.newestPhoto) { return second.thumbnail.creationTime .compareTo(first.thumbnail.creationTime); diff --git a/lib/ui/create_collection_page.dart b/lib/ui/create_collection_page.dart index f69721e32..3f52554a0 100644 --- a/lib/ui/create_collection_page.dart +++ b/lib/ui/create_collection_page.dart @@ -197,8 +197,8 @@ class _CreateCollectionPageState extends State { } } collectionsWithThumbnail.sort((first, second) { - return (first.collection.name ?? "") - .compareTo((second.collection.name ?? "")); + return (first.collection.name.toLowerCase() ?? "") + .compareTo((second.collection.name.toLowerCase() ?? "")); }); return collectionsWithThumbnail; } @@ -286,7 +286,8 @@ class _CreateCollectionPageState extends State { final dialog = createProgressDialog(context, "Moving files to album..."); await dialog.show(); try { - final int fromCollectionID = widget.selectedFiles.files?.first?.collectionID; + final int fromCollectionID = + widget.selectedFiles.files?.first?.collectionID; await CollectionsService.instance.move( toCollectionID, fromCollectionID, From 2a63b21148899dbfba49e2243d901c58cee36f94 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Fri, 16 Sep 2022 10:15:32 +0530 Subject: [PATCH 2/2] sort albums by lower-case natural sort ordering --- lib/ui/collections_gallery_widget.dart | 9 +++++---- lib/ui/create_collection_page.dart | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ui/collections_gallery_widget.dart b/lib/ui/collections_gallery_widget.dart index 0d0ecaee7..c1dea4fff 100644 --- a/lib/ui/collections_gallery_widget.dart +++ b/lib/ui/collections_gallery_widget.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:photos/core/configuration.dart'; @@ -114,10 +115,10 @@ class _CollectionsGalleryWidgetState extends State collectionsWithThumbnail.sort( (first, second) { if (sortKey == AlbumSortKey.albumName) { - // alphabetical ASC order - return first.collection.name - .toLowerCase() - .compareTo(second.collection.name.toLowerCase()); + return compareAsciiLowerCaseNatural( + first.collection.name, + second.collection.name, + ); } else if (sortKey == AlbumSortKey.newestPhoto) { return second.thumbnail.creationTime .compareTo(first.thumbnail.creationTime); diff --git a/lib/ui/create_collection_page.dart b/lib/ui/create_collection_page.dart index 3f52554a0..1e8f48031 100644 --- a/lib/ui/create_collection_page.dart +++ b/lib/ui/create_collection_page.dart @@ -1,5 +1,6 @@ // @dart=2.9 +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:photos/core/configuration.dart'; @@ -197,8 +198,10 @@ class _CreateCollectionPageState extends State { } } collectionsWithThumbnail.sort((first, second) { - return (first.collection.name.toLowerCase() ?? "") - .compareTo((second.collection.name.toLowerCase() ?? "")); + return compareAsciiLowerCaseNatural( + first.collection.name ?? "", + second.collection.name ?? "", + ); }); return collectionsWithThumbnail; }