feat: allow control over patches update (#1063)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
aAbed
2023-08-04 02:08:56 +05:45
committed by GitHub
parent e55f427b05
commit f905a52988
15 changed files with 322 additions and 103 deletions

View File

@ -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,
)
: () => {},
),
),

View File

@ -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);
},
)
],