From d4a4e8b29e0afd120194721332e53366bccc90b7 Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Thu, 9 May 2024 00:38:40 -0300 Subject: [PATCH] Messaging fixes --- lib/models/app.dart | 6 +++--- lib/screens/app_detail_screen.dart | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/models/app.dart b/lib/models/app.dart index 70a19e1..9fab06d 100644 --- a/lib/models/app.dart +++ b/lib/models/app.dart @@ -156,7 +156,7 @@ extension AppX on App { AppInstallStatus get status { if (latestMetadata == null) { - return AppInstallStatus.notInstallable; + return AppInstallStatus.noArch; } if (installedVersion == null) { return AppInstallStatus.installable; @@ -165,7 +165,7 @@ extension AppX on App { if (comp == 1) return AppInstallStatus.updatable; if (comp == 0) return AppInstallStatus.updated; // else it's a downgrade, which is not installable - return AppInstallStatus.notInstallable; + return AppInstallStatus.downgrade; } Future install() async { @@ -260,7 +260,7 @@ Future _isHashMismatch(String path, String hash) async { // install support -enum AppInstallStatus { updated, updatable, installable, notInstallable } +enum AppInstallStatus { updated, updatable, installable, downgrade, noArch } // class diff --git a/lib/screens/app_detail_screen.dart b/lib/screens/app_detail_screen.dart index f77e631..8a5ebbf 100644 --- a/lib/screens/app_detail_screen.dart +++ b/lib/screens/app_detail_screen.dart @@ -386,7 +386,8 @@ class InstallButton extends ConsumerWidget { width: double.infinity, child: ElevatedButton( onPressed: switch (app.status) { - AppInstallStatus.notInstallable => null, + AppInstallStatus.noArch => null, + AppInstallStatus.downgrade => null, AppInstallStatus.updated => () { LaunchApp.openApp(androidPackageName: app.id!.toString()); }, @@ -424,7 +425,10 @@ class InstallButton extends ConsumerWidget { _ => Colors.blue[700], }), child: switch (app.status) { - AppInstallStatus.notInstallable => Text('Sorry, can\'t install'), + AppInstallStatus.noArch => + Text('Sorry, release does not support your device'), + AppInstallStatus.downgrade => + Text('Installed version is higher, can\'t downgrade'), AppInstallStatus.updated => Text('Open'), _ => switch (progress) { IdleInstallProgress() => app.canUpdate @@ -491,23 +495,25 @@ class InstallAlertDialog extends ConsumerWidget { ], ), actions: [ - if (user != null) - TextButton( - onPressed: () { - app.install(); - // NOTE: can't use context.pop() - Navigator.of(context).pop(); - }, - child: Text('Install'), - ), if (user == null) TextButton( onPressed: () { Navigator.of(context).pop(); scaffoldKey.currentState!.openDrawer(); }, - child: Text('Log in to view web of trust'), + child: Text('Log in to view web of trust', + style: TextStyle(fontWeight: FontWeight.bold)), ), + TextButton( + onPressed: () { + app.install(); + // NOTE: can't use context.pop() + Navigator.of(context).pop(); + }, + child: user != null + ? Text('Install', style: TextStyle(fontWeight: FontWeight.bold)) + : Text('I trust the signer, install anyway'), + ), TextButton( onPressed: () { // NOTE: can't use context.pop()