fix(libraries): stabilize alpha and sort controls

This commit is contained in:
edde746
2026-05-17 22:36:15 +02:00
parent c855dba3be
commit 3e0f7b4f86
16 changed files with 393 additions and 112 deletions
+4 -1
View File
@@ -28,7 +28,7 @@ class AlphaJumpHelper {
AlphaJumpHelper._(this.letters, this.letterToIndex, this.letterSizes, this.totalItemCount);
factory AlphaJumpHelper(List<LibraryFirstCharacter> firstCharacters) {
factory AlphaJumpHelper(List<LibraryFirstCharacter> firstCharacters, {bool descending = false}) {
// Collect characters with their sizes.
final entries = <({String letter, int size})>[];
final letterSizes = <String, int>{};
@@ -43,6 +43,9 @@ class AlphaJumpHelper {
// Re-sort by DUCET collation to match the content endpoint's ICU sort order.
entries.sort((a, b) => ducetCompare(a.letter, b.letter));
if (descending) {
entries.setAll(0, entries.reversed.toList());
}
// Build cumulative index map in the corrected order.
final letters = <String>[];