feat: Show a dialog when an update is available (#1654)

This commit is contained in:
aAbed
2024-01-25 23:05:34 +05:45
committed by aAbed
parent 7104d6d6dd
commit c7d975e612
10 changed files with 302 additions and 190 deletions

View File

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

View File

@ -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(