From 0b529c26298a6a68851211870f26f8bbff41c39d Mon Sep 17 00:00:00 2001 From: aAbed <39409020+TheAabedKhan@users.noreply.github.com> Date: Sun, 6 Aug 2023 10:57:01 +0545 Subject: [PATCH] fix(patches-selector): separate all universal patches to the bottom (#1092) --- assets/i18n/en_US.json | 1 + .../patches_selector_view.dart | 51 ++++++++++++++++--- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index 4a0383ad..a9ac05c3 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -112,6 +112,7 @@ "patchesSelectorView": { "viewTitle": "Select patches", "searchBarHint": "Search patches", + "universalPatches": "Universal patches", "doneButton": "Done", diff --git a/lib/ui/views/patches_selector/patches_selector_view.dart b/lib/ui/views/patches_selector/patches_selector_view.dart index 6359403a..5ee6ad83 100644 --- a/lib/ui/views/patches_selector/patches_selector_view.dart +++ b/lib/ui/views/patches_selector/patches_selector_view.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart' hide SearchBar; import 'package:flutter_i18n/flutter_i18n.dart'; +import 'package:revanced_manager/app/app.locator.dart'; +import 'package:revanced_manager/services/manager_api.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_popup_menu.dart'; @@ -16,6 +18,7 @@ class PatchesSelectorView extends StatefulWidget { class _PatchesSelectorViewState extends State { String _query = ''; + final _managerAPI = locator(); @override Widget build(BuildContext context) { @@ -165,10 +168,10 @@ class _PatchesSelectorViewState extends State { ), ], ), - ...model - .getQueriedPatches(_query) - .map( - (patch) => PatchItem( + ...model.getQueriedPatches(_query).map( + (patch) { + if (patch.compatiblePackages.isNotEmpty) { + return PatchItem( name: patch.name, simpleName: patch.getSimpleName(), description: patch.description, @@ -179,9 +182,45 @@ class _PatchesSelectorViewState extends State { isSelected: model.isSelected(patch), onChanged: (value) => model.selectPatch(patch, value), + ); + } else { + return Container(); + } + }, + ), + if (_managerAPI.areUniversalPatchesEnabled()) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 10.0, + ), + child: I18nText( + 'patchesSelectorView.universalPatches', + ), ), - ) - .toList(), + ...model.getQueriedPatches(_query).map((patch) { + if (patch.compatiblePackages.isEmpty) { + return PatchItem( + name: patch.name, + simpleName: patch.getSimpleName(), + description: patch.description, + packageVersion: model.getAppVersion(), + supportedPackageVersions: + model.getSupportedVersions(patch), + isUnsupported: !isPatchSupported(patch), + isSelected: model.isSelected(patch), + onChanged: (value) => + model.selectPatch(patch, value), + ); + } else { + return Container(); + } + }), + ], + ), + const SizedBox(height: 70.0), ], ), ),