diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index f7e4cc4b..ff061624 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -77,6 +77,9 @@ "viewTitle": "Select patches", "searchBarHint": "Search patches", "doneButton": "Done", + "recommended": "Recommended", + "all" : "All", + "none" : "None", "loadPatchesSelection": "Load patches selection", "noSavedPatches": "No saved patches for the selected app\nPress Done to save current selection", "noPatchesFound": "No patches found for the selected app", diff --git a/lib/ui/views/home/home_view.dart b/lib/ui/views/home/home_view.dart index d58598b8..21184fcf 100644 --- a/lib/ui/views/home/home_view.dart +++ b/lib/ui/views/home/home_view.dart @@ -67,7 +67,7 @@ class HomeView extends StatelessWidget { const SizedBox(height: 8), Row( children: [ - DashboardChip( + CustomChip( label: I18nText('homeView.installed'), isSelected: !model.showUpdatableApps, onSelected: (value) { @@ -75,7 +75,7 @@ class HomeView extends StatelessWidget { }, ), const SizedBox(width: 10), - DashboardChip( + CustomChip( label: I18nText('homeView.updatesAvailable'), isSelected: model.showUpdatableApps, onSelected: (value) { diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index 0e824405..66bd71ca 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart'; import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_item.dart'; +import 'package:revanced_manager/ui/widgets/shared/custom_chip.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_popup_menu.dart'; import 'package:revanced_manager/ui/widgets/shared/search_bar.dart'; import 'package:stacked/stacked.dart'; @@ -140,24 +141,51 @@ class _PatchesSelectorViewState extends State { padding: const EdgeInsets.symmetric(horizontal: 12.0) .copyWith(bottom: 80), child: Column( - children: model - .getQueriedPatches(_query) - .map( - (patch) => PatchItem( - name: patch.name, - simpleName: patch.getSimpleName(), - version: patch.version, - description: patch.description, - packageVersion: model.getAppVersion(), - supportedPackageVersions: - model.getSupportedVersions(patch), - isUnsupported: !model.isPatchSupported(patch), - isSelected: model.isSelected(patch), - onChanged: (value) => - model.selectPatch(patch, value), + children: [ + Row( + children: [ + CustomChip( + label: + I18nText('patchesSelectorView.recommended'), + onSelected: (value) { + model.selectRecommendedPatches(); + }, ), - ) - .toList(), + const SizedBox(width: 8), + CustomChip( + label: I18nText('patchesSelectorView.all'), + onSelected: (value) { + model.selectAllPatches(true); + }, + ), + const SizedBox(width: 8), + CustomChip( + label: I18nText('patchesSelectorView.none'), + onSelected: (value) { + model.clearPatches(); + }, + ), + ], + ), + ...model + .getQueriedPatches(_query) + .map( + (patch) => PatchItem( + name: patch.name, + simpleName: patch.getSimpleName(), + version: patch.version, + description: patch.description, + packageVersion: model.getAppVersion(), + supportedPackageVersions: + model.getSupportedVersions(patch), + isUnsupported: !model.isPatchSupported(patch), + isSelected: model.isSelected(patch), + onChanged: (value) => + model.selectPatch(patch, value), + ), + ) + .toList(), + ], ), ), ), diff --git a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart index e872aea6..7ad093ee 100644 --- a/lib/ui/views/patches_selector/patches_selector_viewmodel.dart +++ b/lib/ui/views/patches_selector/patches_selector_viewmodel.dart @@ -92,6 +92,11 @@ class PatchesSelectorViewModel extends BaseViewModel { notifyListeners(); } + void clearPatches() { + selectedPatches.clear(); + notifyListeners(); + } + void selectPatches() { locator().selectedPatches = selectedPatches; saveSelectedPatches(); diff --git a/lib/ui/widgets/shared/custom_chip.dart b/lib/ui/widgets/shared/custom_chip.dart index 61b949fb..7f4bf684 100644 --- a/lib/ui/widgets/shared/custom_chip.dart +++ b/lib/ui/widgets/shared/custom_chip.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; -class DashboardChip extends StatelessWidget { +class CustomChip extends StatelessWidget { final Widget label; final bool isSelected; final Function(bool)? onSelected; - const DashboardChip({ + const CustomChip({ Key? key, required this.label, - required this.isSelected, + this.isSelected = false, this.onSelected, }) : super(key: key);