mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: allow control over patches update (#1063)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@ -8,11 +8,11 @@ import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||
class LatestCommitCard extends StatefulWidget {
|
||||
const LatestCommitCard({
|
||||
Key? key,
|
||||
required this.onPressedManager,
|
||||
required this.onPressedPatches,
|
||||
required this.model,
|
||||
required this.parentContext,
|
||||
}) : super(key: key);
|
||||
final Function() onPressedManager;
|
||||
final Function() onPressedPatches;
|
||||
final HomeViewModel model;
|
||||
final BuildContext parentContext;
|
||||
|
||||
@override
|
||||
State<LatestCommitCard> createState() => _LatestCommitCardState();
|
||||
@ -63,7 +63,10 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
child: CustomMaterialButton(
|
||||
label: I18nText('updateButton'),
|
||||
onPressed: snapshot.hasData && snapshot.data!
|
||||
? widget.onPressedManager
|
||||
? () => widget.model.showUpdateConfirmationDialog(
|
||||
widget.parentContext,
|
||||
false,
|
||||
)
|
||||
: () => {},
|
||||
),
|
||||
),
|
||||
@ -91,7 +94,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
Row(
|
||||
children: <Widget>[
|
||||
FutureBuilder<String?>(
|
||||
future: model.getLatestPatcherReleaseTime(),
|
||||
future: model.getLatestPatchesReleaseTime(),
|
||||
builder: (context, snapshot) => Text(
|
||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||
? FlutterI18n.translate(
|
||||
@ -117,7 +120,10 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
child: CustomMaterialButton(
|
||||
label: I18nText('updateButton'),
|
||||
onPressed: snapshot.hasData && snapshot.data!
|
||||
? widget.onPressedPatches
|
||||
? () => widget.model.showUpdateConfirmationDialog(
|
||||
widget.parentContext,
|
||||
true,
|
||||
)
|
||||
: () => {},
|
||||
),
|
||||
),
|
||||
|
@ -6,8 +6,9 @@ import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||
|
||||
class UpdateConfirmationDialog extends StatelessWidget {
|
||||
const UpdateConfirmationDialog({Key? key}) : super(key: key);
|
||||
const UpdateConfirmationDialog({super.key, required this.isPatches});
|
||||
|
||||
final bool isPatches;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final HomeViewModel model = locator<HomeViewModel>();
|
||||
@ -20,7 +21,9 @@ class UpdateConfirmationDialog extends StatelessWidget {
|
||||
controller: scrollController,
|
||||
child: SafeArea(
|
||||
child: FutureBuilder<Map<String, dynamic>?>(
|
||||
future: model.getLatestManagerRelease(),
|
||||
future: !isPatches
|
||||
? model.getLatestManagerRelease()
|
||||
: model.getLatestPatchesRelease(),
|
||||
builder: (_, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const SizedBox(
|
||||
@ -48,7 +51,9 @@ class UpdateConfirmationDialog extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
I18nText(
|
||||
'homeView.updateDialogTitle',
|
||||
isPatches
|
||||
? 'homeView.updatePatchesDialogTitle'
|
||||
: 'homeView.updateDialogTitle',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
@ -86,7 +91,9 @@ class UpdateConfirmationDialog extends StatelessWidget {
|
||||
label: I18nText('updateButton'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
model.updateManager(context);
|
||||
isPatches
|
||||
? model.updatePatches(context)
|
||||
: model.updateManager(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_manage_api_url.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_manage_sources.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_auto_update_patches.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_patches.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_experimental_universal_patches.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
||||
@ -23,6 +24,7 @@ class SAdvancedSection extends StatelessWidget {
|
||||
SManageApiUrlUI(),
|
||||
SManageSourcesUI(),
|
||||
// SManageKeystorePasswordUI(),
|
||||
SAutoUpdatePatches(),
|
||||
SExperimentalUniversalPatches(),
|
||||
SExperimentalPatches(),
|
||||
ListTile(
|
||||
|
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
|
||||
class SAutoUpdatePatches extends StatefulWidget {
|
||||
const SAutoUpdatePatches({super.key});
|
||||
|
||||
@override
|
||||
State<SAutoUpdatePatches> createState() => _SAutoUpdatePatchesState();
|
||||
}
|
||||
|
||||
final _settingsViewModel = SettingsViewModel();
|
||||
|
||||
class _SAutoUpdatePatchesState extends State<SAutoUpdatePatches> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: I18nText(
|
||||
'homeView.patchesConsentDialogText3',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.autoUpdatePatchesHint'),
|
||||
value: _settingsViewModel.isPatchesAutoUpdate(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_settingsViewModel.setPatchesAutoUpdate(value);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user