mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-03 23:34:25 +02:00
feat: patch options UI.
This commit is contained in:
parent
d46f08a727
commit
8448601b9d
@ -1,8 +1,11 @@
|
|||||||
|
import 'package:expandable/expandable.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:revanced_manager/theme.dart';
|
import 'package:revanced_manager/theme.dart';
|
||||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.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/patchesSelectorView/patch_item.dart';
|
||||||
|
import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_options_fields.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/search_bar.dart';
|
import 'package:revanced_manager/ui/widgets/shared/search_bar.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
|
|
||||||
@ -18,6 +21,7 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
ExpandableController expController = ExpandableController();
|
||||||
return ViewModelBuilder<PatchesSelectorViewModel>.reactive(
|
return ViewModelBuilder<PatchesSelectorViewModel>.reactive(
|
||||||
onModelReady: (model) => model.initialize(),
|
onModelReady: (model) => model.initialize(),
|
||||||
viewModelBuilder: () => PatchesSelectorViewModel(),
|
viewModelBuilder: () => PatchesSelectorViewModel(),
|
||||||
@ -67,25 +71,105 @@ class _PatchesSelectorViewState extends State<PatchesSelectorView> {
|
|||||||
onSelectAll: (value) => model.selectAllPatches(value),
|
onSelectAll: (value) => model.selectAllPatches(value),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
|
//TODO:IMPROVE THIS BAD CODE!!
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: const EdgeInsets.only(bottom: 80),
|
padding: const EdgeInsets.only(bottom: 80),
|
||||||
children: model
|
children: model
|
||||||
.getQueriedPatches(_query)
|
.getQueriedPatches(_query)
|
||||||
.map((patch) => PatchItem(
|
.map((patch) => patch.name
|
||||||
name: patch.name,
|
.contains("custom-branding")
|
||||||
simpleName: patch.getSimpleName(),
|
? ExpandablePanel(
|
||||||
version: patch.version,
|
controller: expController,
|
||||||
description: patch.description,
|
theme: const ExpandableThemeData(
|
||||||
packageVersion: model.getAppVersion(),
|
hasIcon: false,
|
||||||
supportedPackageVersions:
|
tapBodyToExpand: true,
|
||||||
model.getSupportedVersions(patch),
|
tapBodyToCollapse: true,
|
||||||
isUnsupported:
|
tapHeaderToExpand: true,
|
||||||
!model.isPatchSupported(patch),
|
),
|
||||||
isSelected: model.isSelected(patch),
|
header: Column(
|
||||||
onChanged: (value) =>
|
children: [
|
||||||
model.selectPatch(patch, value),
|
GestureDetector(
|
||||||
))
|
onLongPress: () =>
|
||||||
|
expController.toggle(),
|
||||||
|
child: PatchItem(
|
||||||
|
name: patch.name,
|
||||||
|
simpleName: patch.getSimpleName(),
|
||||||
|
description: patch.description,
|
||||||
|
version: patch.version,
|
||||||
|
packageVersion:
|
||||||
|
model.getAppVersion(),
|
||||||
|
supportedPackageVersions: model
|
||||||
|
.getSupportedVersions(patch),
|
||||||
|
isUnsupported: !model
|
||||||
|
.isPatchSupported(patch),
|
||||||
|
isSelected:
|
||||||
|
model.isSelected(patch),
|
||||||
|
onChanged: (value) => model
|
||||||
|
.selectPatch(patch, value),
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: 8.0,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'Long press for additional options.'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
expanded: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 10.0,
|
||||||
|
horizontal: 10,
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.tertiary
|
||||||
|
.withOpacity(0.1),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Patch options",
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const OptionsTextField(
|
||||||
|
hint: "App name"),
|
||||||
|
const OptionsFilePicker(
|
||||||
|
optionName: "Choose a logo",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
collapsed: Container(),
|
||||||
|
)
|
||||||
|
: 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(),
|
.toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_options_fields.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/patch_text_button.dart';
|
import 'package:revanced_manager/ui/widgets/shared/patch_text_button.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
@ -14,19 +15,21 @@ class PatchItem extends StatefulWidget {
|
|||||||
final bool isUnsupported;
|
final bool isUnsupported;
|
||||||
bool isSelected;
|
bool isSelected;
|
||||||
final Function(bool) onChanged;
|
final Function(bool) onChanged;
|
||||||
|
final Widget? child;
|
||||||
|
|
||||||
PatchItem({
|
PatchItem(
|
||||||
Key? key,
|
{Key? key,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.simpleName,
|
required this.simpleName,
|
||||||
required this.description,
|
required this.description,
|
||||||
required this.version,
|
required this.version,
|
||||||
required this.packageVersion,
|
required this.packageVersion,
|
||||||
required this.supportedPackageVersions,
|
required this.supportedPackageVersions,
|
||||||
required this.isUnsupported,
|
required this.isUnsupported,
|
||||||
required this.isSelected,
|
required this.isSelected,
|
||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
}) : super(key: key);
|
this.child})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PatchItem> createState() => _PatchItemState();
|
State<PatchItem> createState() => _PatchItemState();
|
||||||
@ -96,6 +99,39 @@ class _PatchItemState extends State<PatchItem> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// widget.name.contains("custom-branding")
|
||||||
|
// ? Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
// child: Container(
|
||||||
|
// padding: const EdgeInsets.symmetric(
|
||||||
|
// vertical: 8,
|
||||||
|
// horizontal: 8,
|
||||||
|
// ),
|
||||||
|
// decoration: BoxDecoration(
|
||||||
|
// color: Theme.of(context)
|
||||||
|
// .colorScheme
|
||||||
|
// .tertiary
|
||||||
|
// .withOpacity(0.1),
|
||||||
|
// borderRadius: BorderRadius.circular(12),
|
||||||
|
// ),
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// "Patch options",
|
||||||
|
// style: GoogleFonts.inter(
|
||||||
|
// fontSize: 18,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const OptionsTextField(hint: "App name"),
|
||||||
|
// const OptionsFilePicker(
|
||||||
|
// optionName: "Choose a logo",
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// : const SizedBox(),
|
||||||
widget.isUnsupported
|
widget.isUnsupported
|
||||||
? Row(
|
? Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -128,6 +164,7 @@ class _PatchItemState extends State<PatchItem> {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
: Container(),
|
: Container(),
|
||||||
|
widget.child ?? const SizedBox(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
68
lib/ui/widgets/patchesSelectorView/patch_options_fields.dart
Normal file
68
lib/ui/widgets/patchesSelectorView/patch_options_fields.dart
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
|
|
||||||
|
class OptionsTextField extends StatelessWidget {
|
||||||
|
final String hint;
|
||||||
|
const OptionsTextField({Key? key, required this.hint}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final sHeight = MediaQuery.of(context).size.height;
|
||||||
|
final sWidth = MediaQuery.of(context).size.width;
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(top: 12, bottom: 6),
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
child: TextField(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: sHeight * 0.05,
|
||||||
|
maxWidth: sWidth * 1,
|
||||||
|
),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
labelText: hint,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OptionsFilePicker extends StatelessWidget {
|
||||||
|
final String optionName;
|
||||||
|
const OptionsFilePicker({Key? key, required this.optionName})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
I18nText(
|
||||||
|
optionName,
|
||||||
|
child: Text(
|
||||||
|
'',
|
||||||
|
style: GoogleFonts.inter(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStateProperty.all(
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// pick files
|
||||||
|
},
|
||||||
|
child: const Text('Select File'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user