mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-30 21:13:28 +01:00 
			
		
		
		
	Added App sorting
This commit is contained in:
		| @@ -16,7 +16,23 @@ class _AppsPageState extends State<AppsPage> { | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     var appsProvider = context.watch<AppsProvider>(); | ||||
|     var settingsProvider = context.watch<SettingsProvider>(); | ||||
|     var existingUpdateAppIds = appsProvider.getExistingUpdates(); | ||||
|     var sortedApps = appsProvider.apps.values.toList(); | ||||
|     sortedApps.sort((a, b) { | ||||
|       int result = 0; | ||||
|       if (settingsProvider.sortColumn == SortColumnSettings.authorName) { | ||||
|         result = | ||||
|             (a.app.author + a.app.name).compareTo(b.app.author + b.app.name); | ||||
|       } else if (settingsProvider.sortColumn == SortColumnSettings.nameAuthor) { | ||||
|         result = | ||||
|             (a.app.name + a.app.author).compareTo(b.app.name + b.app.author); | ||||
|       } | ||||
|       return result; | ||||
|     }); | ||||
|     if (settingsProvider.sortOrder == SortOrderSettings.ascending) { | ||||
|       sortedApps = sortedApps.reversed.toList(); | ||||
|     } | ||||
|  | ||||
|     return Scaffold( | ||||
|         floatingActionButton: existingUpdateAppIds.isEmpty | ||||
| @@ -26,10 +42,7 @@ class _AppsPageState extends State<AppsPage> { | ||||
|                     ? null | ||||
|                     : () { | ||||
|                         HapticFeedback.heavyImpact(); | ||||
|                         context | ||||
|                             .read<SettingsProvider>() | ||||
|                             .getInstallPermission() | ||||
|                             .then((_) { | ||||
|                         settingsProvider.getInstallPermission().then((_) { | ||||
|                           appsProvider.downloadAndInstallLatestApp( | ||||
|                               existingUpdateAppIds, context); | ||||
|                         }); | ||||
| @@ -50,7 +63,7 @@ class _AppsPageState extends State<AppsPage> { | ||||
|                         return appsProvider.checkUpdates(); | ||||
|                       }, | ||||
|                       child: ListView( | ||||
|                         children: appsProvider.apps.values | ||||
|                         children: sortedApps | ||||
|                             .map( | ||||
|                               (e) => ListTile( | ||||
|                                 title: Text('${e.app.author}/${e.app.name}'), | ||||
|   | ||||
| @@ -112,6 +112,54 @@ class _SettingsPageState extends State<SettingsPage> { | ||||
|                   const SizedBox( | ||||
|                     height: 16, | ||||
|                   ), | ||||
|                   DropdownButtonFormField( | ||||
|                       decoration: | ||||
|                           const InputDecoration(labelText: 'App Sort By'), | ||||
|                       value: settingsProvider.sortColumn, | ||||
|                       items: const [ | ||||
|                         DropdownMenuItem( | ||||
|                           value: SortColumnSettings.authorName, | ||||
|                           child: Text('Author/Name'), | ||||
|                         ), | ||||
|                         DropdownMenuItem( | ||||
|                           value: SortColumnSettings.nameAuthor, | ||||
|                           child: Text('Name/Author'), | ||||
|                         ), | ||||
|                         DropdownMenuItem( | ||||
|                           value: SortColumnSettings.added, | ||||
|                           child: Text('As Added'), | ||||
|                         ) | ||||
|                       ], | ||||
|                       onChanged: (value) { | ||||
|                         if (value != null) { | ||||
|                           settingsProvider.sortColumn = value; | ||||
|                         } | ||||
|                       }), | ||||
|                   const SizedBox( | ||||
|                     height: 16, | ||||
|                   ), | ||||
|                   DropdownButtonFormField( | ||||
|                       decoration: | ||||
|                           const InputDecoration(labelText: 'App Sort Order'), | ||||
|                       value: settingsProvider.sortOrder, | ||||
|                       items: const [ | ||||
|                         DropdownMenuItem( | ||||
|                           value: SortOrderSettings.ascending, | ||||
|                           child: Text('Ascending'), | ||||
|                         ), | ||||
|                         DropdownMenuItem( | ||||
|                           value: SortOrderSettings.descending, | ||||
|                           child: Text('Descending'), | ||||
|                         ), | ||||
|                       ], | ||||
|                       onChanged: (value) { | ||||
|                         if (value != null) { | ||||
|                           settingsProvider.sortOrder = value; | ||||
|                         } | ||||
|                       }), | ||||
|                   const SizedBox( | ||||
|                     height: 16, | ||||
|                   ), | ||||
|                   Row( | ||||
|                     mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                     children: [ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user