mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: Show a dialog when an update is available (#1654)
This commit is contained in:
@ -55,17 +55,15 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
FutureBuilder<bool>(
|
||||
future: model.hasManagerUpdates(),
|
||||
initialData: false,
|
||||
builder: (context, snapshot) => Opacity(
|
||||
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.25,
|
||||
child: FilledButton(
|
||||
onPressed: snapshot.hasData && snapshot.data!
|
||||
? () => widget.model.showUpdateConfirmationDialog(
|
||||
widget.parentContext,
|
||||
false,
|
||||
)
|
||||
: () => {},
|
||||
child: I18nText('updateButton'),
|
||||
builder: (context, snapshot) => FilledButton(
|
||||
onPressed: () => widget.model.showUpdateConfirmationDialog(
|
||||
widget.parentContext,
|
||||
false,
|
||||
!snapshot.data!,
|
||||
),
|
||||
child: (snapshot.hasData && !snapshot.data!)
|
||||
? I18nText('showChangelogButton')
|
||||
: I18nText('showUpdateButton'),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -83,7 +81,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const Text('Patches'),
|
||||
const Text('ReVanced Patches'),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
@ -108,19 +106,17 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
),
|
||||
),
|
||||
FutureBuilder<bool>(
|
||||
future: locator<HomeViewModel>().hasPatchesUpdates(),
|
||||
future: model.hasPatchesUpdates(),
|
||||
initialData: false,
|
||||
builder: (context, snapshot) => Opacity(
|
||||
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.25,
|
||||
child: FilledButton(
|
||||
onPressed: snapshot.hasData && snapshot.data!
|
||||
? () => widget.model.showUpdateConfirmationDialog(
|
||||
widget.parentContext,
|
||||
true,
|
||||
)
|
||||
: () => {},
|
||||
child: I18nText('updateButton'),
|
||||
builder: (context, snapshot) => FilledButton(
|
||||
onPressed: () => widget.model.showUpdateConfirmationDialog(
|
||||
widget.parentContext,
|
||||
true,
|
||||
!snapshot.data!,
|
||||
),
|
||||
child: (snapshot.hasData && !snapshot.data!)
|
||||
? I18nText('showChangelogButton')
|
||||
: I18nText('showUpdateButton'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -4,10 +4,11 @@ import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||
|
||||
class UpdateConfirmationDialog extends StatelessWidget {
|
||||
const UpdateConfirmationDialog({super.key, required this.isPatches});
|
||||
class UpdateConfirmationSheet extends StatelessWidget {
|
||||
const UpdateConfirmationSheet({super.key, required this.isPatches, this.changelog = false});
|
||||
|
||||
final bool isPatches;
|
||||
final bool changelog;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final HomeViewModel model = locator<HomeViewModel>();
|
||||
@ -36,6 +37,7 @@ class UpdateConfirmationDialog extends StatelessWidget {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!changelog)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 40.0,
|
||||
@ -51,8 +53,8 @@ class UpdateConfirmationDialog extends StatelessWidget {
|
||||
children: [
|
||||
I18nText(
|
||||
isPatches
|
||||
? 'homeView.updatePatchesDialogTitle'
|
||||
: 'homeView.updateDialogTitle',
|
||||
? 'homeView.updatePatchesSheetTitle'
|
||||
: 'homeView.updateSheetTitle',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
@ -7,6 +7,7 @@ import 'package:revanced_manager/ui/widgets/settingsView/settings_auto_update_pa
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_enable_patches_selection.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_require_suggested_app_version.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_show_update_dialog.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_universal_patches.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_version_compatibility_check.dart';
|
||||
|
||||
@ -19,6 +20,7 @@ class SAdvancedSection extends StatelessWidget {
|
||||
title: 'settingsView.advancedSectionTitle',
|
||||
children: const <Widget>[
|
||||
SAutoUpdatePatches(),
|
||||
SShowUpdateDialog(),
|
||||
SEnablePatchesSelection(),
|
||||
SRequireSuggestedAppVersion(),
|
||||
SVersionCompatibilityCheck(),
|
||||
|
39
lib/ui/widgets/settingsView/settings_show_update_dialog.dart
Normal file
39
lib/ui/widgets/settingsView/settings_show_update_dialog.dart
Normal file
@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_switch_list_tile.dart';
|
||||
|
||||
class SShowUpdateDialog extends StatefulWidget {
|
||||
const SShowUpdateDialog({super.key});
|
||||
|
||||
@override
|
||||
State<SShowUpdateDialog> createState() => _SShowUpdateDialogState();
|
||||
}
|
||||
|
||||
final _settingsViewModel = SettingsViewModel();
|
||||
|
||||
class _SShowUpdateDialogState extends State<SShowUpdateDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return HapticSwitchListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
title: I18nText(
|
||||
'settingsView.showUpdateDialogLabel',
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
subtitle: I18nText('settingsView.showUpdateDialogHint'),
|
||||
value: _settingsViewModel.showUpdateDialog(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_settingsViewModel.setShowUpdateDialog(value);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user