mirror of
				https://github.com/ImranR98/Obtainium.git
				synced 2025-10-31 13:33:28 +01:00 
			
		
		
		
	Merge pull request #416 from ImranR98/dev
Added a source filter to the Apps page
This commit is contained in:
		| @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; | |||||||
| // ignore: implementation_imports | // ignore: implementation_imports | ||||||
| import 'package:easy_localization/src/localization.dart'; | import 'package:easy_localization/src/localization.dart'; | ||||||
|  |  | ||||||
| const String currentVersion = '0.11.21'; | const String currentVersion = '0.11.22'; | ||||||
| const String currentReleaseTag = | const String currentReleaseTag = | ||||||
|     'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES |     'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES | ||||||
|  |  | ||||||
|   | |||||||
| @@ -56,6 +56,7 @@ class AppsPageState extends State<AppsPage> { | |||||||
|   Widget build(BuildContext context) { |   Widget build(BuildContext context) { | ||||||
|     var appsProvider = context.watch<AppsProvider>(); |     var appsProvider = context.watch<AppsProvider>(); | ||||||
|     var settingsProvider = context.watch<SettingsProvider>(); |     var settingsProvider = context.watch<SettingsProvider>(); | ||||||
|  |     var sourceProvider = SourceProvider(); | ||||||
|     var listedApps = appsProvider.apps.values.toList(); |     var listedApps = appsProvider.apps.values.toList(); | ||||||
|     var currentFilterIsUpdatesOnly = |     var currentFilterIsUpdatesOnly = | ||||||
|         filter.isIdenticalTo(updatesOnlyFilter, settingsProvider); |         filter.isIdenticalTo(updatesOnlyFilter, settingsProvider); | ||||||
| @@ -110,6 +111,11 @@ class AppsPageState extends State<AppsPage> { | |||||||
|               .isEmpty) { |               .isEmpty) { | ||||||
|         return false; |         return false; | ||||||
|       } |       } | ||||||
|  |       if (filter.sourceFilter.isNotEmpty && | ||||||
|  |           sourceProvider.getSource(app.app.url).runtimeType.toString() != | ||||||
|  |               filter.sourceFilter) { | ||||||
|  |         return false; | ||||||
|  |       } | ||||||
|       return true; |       return true; | ||||||
|     }).toList(); |     }).toList(); | ||||||
|  |  | ||||||
| @@ -892,6 +898,19 @@ class AppsPageState extends State<AppsPage> { | |||||||
|                   GeneratedFormSwitch('nonInstalledApps', |                   GeneratedFormSwitch('nonInstalledApps', | ||||||
|                       label: tr('nonInstalledApps'), |                       label: tr('nonInstalledApps'), | ||||||
|                       defaultValue: vals['nonInstalledApps']) |                       defaultValue: vals['nonInstalledApps']) | ||||||
|  |                 ], | ||||||
|  |                 [ | ||||||
|  |                   GeneratedFormDropdown( | ||||||
|  |                       'sourceFilter', | ||||||
|  |                       label: tr('appSource'), | ||||||
|  |                       defaultValue: filter.sourceFilter, | ||||||
|  |                       [ | ||||||
|  |                         MapEntry('', tr('none')), | ||||||
|  |                         ...sourceProvider.sources | ||||||
|  |                             .map((e) => | ||||||
|  |                                 MapEntry(e.runtimeType.toString(), e.name)) | ||||||
|  |                             .toList() | ||||||
|  |                       ]) | ||||||
|                 ] |                 ] | ||||||
|               ], |               ], | ||||||
|               additionalWidgets: [ |               additionalWidgets: [ | ||||||
| @@ -1015,20 +1034,23 @@ class AppsFilter { | |||||||
|   late bool includeUptodate; |   late bool includeUptodate; | ||||||
|   late bool includeNonInstalled; |   late bool includeNonInstalled; | ||||||
|   late Set<String> categoryFilter; |   late Set<String> categoryFilter; | ||||||
|  |   late String sourceFilter; | ||||||
|  |  | ||||||
|   AppsFilter( |   AppsFilter( | ||||||
|       {this.nameFilter = '', |       {this.nameFilter = '', | ||||||
|       this.authorFilter = '', |       this.authorFilter = '', | ||||||
|       this.includeUptodate = true, |       this.includeUptodate = true, | ||||||
|       this.includeNonInstalled = true, |       this.includeNonInstalled = true, | ||||||
|       this.categoryFilter = const {}}); |       this.categoryFilter = const {}, | ||||||
|  |       this.sourceFilter = ''}); | ||||||
|  |  | ||||||
|   Map<String, dynamic> toFormValuesMap() { |   Map<String, dynamic> toFormValuesMap() { | ||||||
|     return { |     return { | ||||||
|       'appName': nameFilter, |       'appName': nameFilter, | ||||||
|       'author': authorFilter, |       'author': authorFilter, | ||||||
|       'upToDateApps': includeUptodate, |       'upToDateApps': includeUptodate, | ||||||
|       'nonInstalledApps': includeNonInstalled |       'nonInstalledApps': includeNonInstalled, | ||||||
|  |       'sourceFilter': sourceFilter | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -1037,6 +1059,7 @@ class AppsFilter { | |||||||
|     authorFilter = values['author']!; |     authorFilter = values['author']!; | ||||||
|     includeUptodate = values['upToDateApps']; |     includeUptodate = values['upToDateApps']; | ||||||
|     includeNonInstalled = values['nonInstalledApps']; |     includeNonInstalled = values['nonInstalledApps']; | ||||||
|  |     sourceFilter = values['sourceFilter']; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool isIdenticalTo(AppsFilter other, SettingsProvider settingsProvider) => |   bool isIdenticalTo(AppsFilter other, SettingsProvider settingsProvider) => | ||||||
| @@ -1044,5 +1067,6 @@ class AppsFilter { | |||||||
|       nameFilter.trim() == other.nameFilter.trim() && |       nameFilter.trim() == other.nameFilter.trim() && | ||||||
|       includeUptodate == other.includeUptodate && |       includeUptodate == other.includeUptodate && | ||||||
|       includeNonInstalled == other.includeNonInstalled && |       includeNonInstalled == other.includeNonInstalled && | ||||||
|       settingsProvider.setEqual(categoryFilter, other.categoryFilter); |       settingsProvider.setEqual(categoryFilter, other.categoryFilter) && | ||||||
|  |       sourceFilter.trim() == other.sourceFilter.trim(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev | |||||||
| # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html | ||||||
| # In Windows, build-name is used as the major, minor, and patch parts | # In Windows, build-name is used as the major, minor, and patch parts | ||||||
| # of the product and file versions while build-number is used as the build suffix. | # of the product and file versions while build-number is used as the build suffix. | ||||||
| version: 0.11.21+143 # When changing this, update the tag in main() accordingly | version: 0.11.22+144 # When changing this, update the tag in main() accordingly | ||||||
|  |  | ||||||
| environment: | environment: | ||||||
|   sdk: '>=2.18.2 <3.0.0' |   sdk: '>=2.18.2 <3.0.0' | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user