Skip to content

Commit

Permalink
feat: add chips for patches selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunali321 committed Nov 23, 2022
1 parent c5958f1 commit 6e05120
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 22 deletions.
3 changes: 3 additions & 0 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/views/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ class HomeView extends StatelessWidget {
const SizedBox(height: 8),
Row(
children: <Widget>[
DashboardChip(
CustomChip(
label: I18nText('homeView.installed'),
isSelected: !model.showUpdatableApps,
onSelected: (value) {
model.toggleUpdatableApps(false);
},
),
const SizedBox(width: 10),
DashboardChip(
CustomChip(
label: I18nText('homeView.updatesAvailable'),
isSelected: model.showUpdatableApps,
onSelected: (value) {
Expand Down
62 changes: 45 additions & 17 deletions lib/ui/views/patches_selector/patches_selector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -140,24 +141,51 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
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(),
],
),
),
),
Expand Down
5 changes: 5 additions & 0 deletions lib/ui/views/patches_selector/patches_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class PatchesSelectorViewModel extends BaseViewModel {
notifyListeners();
}

void clearPatches() {
selectedPatches.clear();
notifyListeners();
}

void selectPatches() {
locator<PatcherViewModel>().selectedPatches = selectedPatches;
saveSelectedPatches();
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/widgets/shared/custom_chip.dart
Original file line number Diff line number Diff line change
@@ -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);

Expand Down

0 comments on commit 6e05120

Please sign in to comment.