From 446a6772bdbd26bac0163368b858c9971dbeb611 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 31 Oct 2021 12:54:11 +0200 Subject: [PATCH] Show native dialog --- lib/ui/app/menu_drawer.dart | 21 +++++++++++++++++++-- lib/utils/dialogs.dart | 2 ++ lib/utils/i18n.dart | 12 ++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index 63c396d9d..f3728c960 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_styled_toast/flutter_styled_toast.dart'; import 'package:invoiceninja_flutter/data/web_client.dart'; import 'package:invoiceninja_flutter/flutter_version.dart'; @@ -764,9 +765,25 @@ class SidebarFooter extends StatelessWidget { color: Colors.orange, ), ) - else if (!state.dismissedNativeWarning && false) + else if (!state.dismissedNativeWarning) IconButton( - onPressed: () => null, + onPressed: () => showMessageDialog( + context: context, + message: isMobileOS() + ? localization.recommendMobile + : localization.recommendDesktop, + onDismiss: () { + // + }, + secondaryActions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(localization.download.toUpperCase()), + ), + ], + ), icon: Icon( Icons.warning, color: Colors.orange, diff --git a/lib/utils/dialogs.dart b/lib/utils/dialogs.dart index 1ade35dad..5def6657f 100644 --- a/lib/utils/dialogs.dart +++ b/lib/utils/dialogs.dart @@ -54,6 +54,7 @@ void showMessageDialog({ @required BuildContext context, @required String message, List secondaryActions, + Function onDismiss, }) { showDialog( context: context, @@ -61,6 +62,7 @@ void showMessageDialog({ return MessageDialog( message, secondaryActions: secondaryActions, + onDismiss: onDismiss, ); }); } diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 999737c59..910be69f1 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -15,6 +15,10 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'recommend_desktop': + 'We recommend using the desktop app for the best performance', + 'recommend_mobile': + 'We recommend using the mobile app for the best performance', 'disconnected_gateway': 'Successfully disconnected gateway', 'disconnect': 'Disconnect', 'add_to_invoices': 'Add to Invoices', @@ -62766,6 +62770,14 @@ mixin LocalizationsProvider on LocaleCodeAware { _localizedValues[localeCode]['disconnected_gateway'] ?? _localizedValues['en']['disconnected_gateway']; + String get recommendDesktop => + _localizedValues[localeCode]['recommend_desktop'] ?? + _localizedValues['en']['recommend_desktop']; + + String get recommendMobile => + _localizedValues[localeCode]['recommend_mobile'] ?? + _localizedValues['en']['recommend_mobile']; + // STARTER: lang field - do not remove comment String lookup(String key) {