feat: add chips for patches selection.

This commit is contained in:
Aunali321 2022-11-23 09:48:10 +05:30
parent c5958f1257
commit 6e05120aa5
5 changed files with 58 additions and 22 deletions

View File

@ -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",

View File

@ -67,7 +67,7 @@ class HomeView extends StatelessWidget {
const SizedBox(height: 8),
Row(
children: <Widget>[
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) {

View File

@ -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,7 +141,33 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
padding: const EdgeInsets.symmetric(horizontal: 12.0)
.copyWith(bottom: 80),
child: Column(
children: model
children: [
Row(
children: [
CustomChip(
label:
I18nText('patchesSelectorView.recommended'),
onSelected: (value) {
model.selectRecommendedPatches();
},
),
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(
@ -158,6 +185,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
),
)
.toList(),
],
),
),
),

View File

@ -92,6 +92,11 @@ class PatchesSelectorViewModel extends BaseViewModel {
notifyListeners();
}
void clearPatches() {
selectedPatches.clear();
notifyListeners();
}
void selectPatches() {
locator<PatcherViewModel>().selectedPatches = selectedPatches;
saveSelectedPatches();

View File

@ -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);