11import 'package:flutter/material.dart' ;
22import 'package:piwigo_ng/services/preferences_service.dart' ;
3+ import 'package:piwigo_ng/utils/localizations.dart' ;
4+
5+ enum SortMethods {
6+ nameAsc,
7+ nameDesc,
8+ fileAsc,
9+ fileDesc,
10+ dateCreatedAsc,
11+ dateCreatedDesc,
12+ dateAvailableAsc,
13+ dateAvailableDesc,
14+ rateAsc,
15+ rateDesc,
16+ hitAsc,
17+ hitDesc,
18+ random,
19+ }
20+
21+ extension SortMethodsExtension on SortMethods {
22+ String get label {
23+ switch (this ) {
24+ case SortMethods .nameAsc:
25+ return appStrings.categorySort_nameAscending;
26+ case SortMethods .nameDesc:
27+ return appStrings.categorySort_nameDescending;
28+ case SortMethods .fileAsc:
29+ return appStrings.categorySort_fileNameAscending;
30+ case SortMethods .fileDesc:
31+ return appStrings.categorySort_fileNameDescending;
32+ case SortMethods .dateCreatedAsc:
33+ return appStrings.categorySort_dateCreatedAscending;
34+ case SortMethods .dateCreatedDesc:
35+ return appStrings.categorySort_dateCreatedDescending;
36+ case SortMethods .dateAvailableAsc:
37+ return appStrings.categorySort_datePostedAscending;
38+ case SortMethods .dateAvailableDesc:
39+ return appStrings.categorySort_datePostedDescending;
40+ case SortMethods .rateAsc:
41+ return appStrings.categorySort_ratingScoreAscending;
42+ case SortMethods .rateDesc:
43+ return appStrings.categorySort_ratingScoreDescending;
44+ case SortMethods .hitAsc:
45+ return appStrings.categorySort_visitsAscending;
46+ case SortMethods .hitDesc:
47+ return appStrings.categorySort_visitsDescending;
48+ case SortMethods .random:
49+ return appStrings.categorySort_random;
50+ }
51+ }
52+
53+ String get value {
54+ switch (this ) {
55+ case SortMethods .nameAsc:
56+ return 'name ASC' ;
57+ case SortMethods .nameDesc:
58+ return 'name DESC' ;
59+ case SortMethods .fileAsc:
60+ return 'file ASC' ;
61+ case SortMethods .fileDesc:
62+ return 'file DESC' ;
63+ case SortMethods .dateCreatedAsc:
64+ return 'date_creation ASC' ;
65+ case SortMethods .dateCreatedDesc:
66+ return 'date_creation DESC' ;
67+ case SortMethods .dateAvailableAsc:
68+ return 'date_available ASC' ;
69+ case SortMethods .dateAvailableDesc:
70+ return 'date_available DESC' ;
71+ case SortMethods .rateAsc:
72+ return 'rating_score ASC' ;
73+ case SortMethods .rateDesc:
74+ return 'rating_score DESC' ;
75+ case SortMethods .hitAsc:
76+ return 'hit ASC' ;
77+ case SortMethods .hitDesc:
78+ return 'hit DESC' ;
79+ case SortMethods .random:
80+ return 'random' ;
81+ }
82+ }
83+ }
384
485class Settings {
586 static const String defaultAlbumThumbnailSize = 'medium' ;
687 static const String defaultImageThumbnailSize = 'medium' ;
788 static const String defaultImageFullScreenSize = 'medium' ;
89+ static const SortMethods defaultImageSort = SortMethods .nameAsc;
890 static const bool defaultRemoveMetadata = false ;
991 static const bool defaultCompress = false ;
1092 static const bool defaultDeleteAfterUpload = false ;
@@ -13,6 +95,7 @@ class Settings {
1395 static const int defaultImageRowCount = 4 ;
1496 static const int minImageRowCount = 1 ; // Settings slider min range
1597 static const int maxImageRowCount = 6 ; // Settings slider max range
98+ static const int defaultElementPerPage = 100 ; // API requests
1699 static const double defaultAlbumGridSize = 448.0 ;
17100 static const double defaultUploadQuality = 1.0 ;
18101
@@ -56,4 +139,35 @@ class Settings {
56139 return '' ;
57140 }
58141 }
142+
143+ static SortMethods sortFromValue (value) {
144+ switch (value) {
145+ case 'name ASC' :
146+ return SortMethods .nameAsc;
147+ case 'name DESC' :
148+ return SortMethods .nameDesc;
149+ case 'file ASC' :
150+ return SortMethods .fileAsc;
151+ case 'file DESC' :
152+ return SortMethods .fileDesc;
153+ case 'date_creation ASC' :
154+ return SortMethods .dateCreatedAsc;
155+ case 'date_creation DESC' :
156+ return SortMethods .dateCreatedDesc;
157+ case 'date_available ASC' :
158+ return SortMethods .dateAvailableAsc;
159+ case 'date_available DESC' :
160+ return SortMethods .dateAvailableDesc;
161+ case 'rating_score ASC' :
162+ return SortMethods .rateAsc;
163+ case 'rating_score DESC' :
164+ return SortMethods .rateDesc;
165+ case 'hit ASC' :
166+ return SortMethods .hitAsc;
167+ case 'hit DESC' :
168+ return SortMethods .hitDesc;
169+ default :
170+ return SortMethods .random;
171+ }
172+ }
59173}
0 commit comments