From e6f482ae52628834909f2ba38b1f2a448e96f919 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 26 Nov 2020 20:19:58 +0200 Subject: [PATCH] Add platform buttons --- lib/constants.dart | 14 ++++--- lib/ui/app/menu_drawer.dart | 73 ++++++++++++++++++++++++++++++++++++- lib/utils/i18n.dart | 4 ++ lib/utils/platforms.dart | 13 ++++--- 4 files changed, 91 insertions(+), 13 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index e3482630c..0af08691f 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -24,10 +24,15 @@ const String kAppPlansURL = 'https://www.invoiceninja.com/invoicing-pricing-plans/'; const String kPrivacyPolicyURL = 'https://www.invoiceninja.com/privacy-policy'; const String kTermsOfServiceURL = 'https://www.invoiceninja.com/terms'; -const String kAppleStoreUrl = - 'https://itunes.apple.com/us/app/invoice-ninja/id1435514417?ls=1&mt=8'; -const String kGoogleStoreUrl = - 'https://play.google.com/store/apps/details?id=com.invoiceninja.flutter'; + +//const String kAppleStoreUrl = 'https://itunes.apple.com/us/app/invoice-ninja/id1435514417?ls=1&mt=8'; +//const String kGoogleStoreUrl = 'https://play.google.com/store/apps/details?id=com.invoiceninja.flutter'; + +const String kAppleStoreUrl = 'https://testflight.apple.com/join/MJ6WpaXh'; +const String kGoogleStoreUrl = 'https://play.google.com/apps/testing/com.invoiceninja.app'; +const String kMacOSUrl = 'http://download.invoiceninja.com/macos'; +const String kLinuxUrl = 'http://download.invoiceninja.com/linux'; + const String kCapterralUrl = 'https://www.capterra.com/p/145215/Invoice-Ninja/'; const String kCronsHelpUrl = 'https://invoiceninja.github.io/selfhost.html#cron-configuration'; @@ -761,4 +766,3 @@ const String kActivityEmailReminder1 = '63'; const String kActivityEmailReminder2 = '64'; const String kActivityEmailReminder3 = '65'; const String kActivityEmailReminderEndless = '66'; - diff --git a/lib/ui/app/menu_drawer.dart b/lib/ui/app/menu_drawer.dart index 67dbd4782..1967ffe8d 100644 --- a/lib/ui/app/menu_drawer.dart +++ b/lib/ui/app/menu_drawer.dart @@ -818,12 +818,81 @@ void _showAbout(BuildContext context) async { ), ), ), - //if (!state.isProduction) // TODO enable this check Padding( padding: const EdgeInsets.only(top: 30), + child: AppButton( + label: localization.appPlatforms.toUpperCase(), + iconData: MdiIcons.desktopMac, + onPressed: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + actions: [ + FlatButton( + child: Text(localization.close.toUpperCase()), + onPressed: () => Navigator.of(context).pop(), + ), + ], + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text('Mobile'), + Padding( + padding: const EdgeInsets.only(top: 20), + child: AppButton( + label: 'Apple', + iconData: MdiIcons.appleIos, + onPressed: () => launch(kAppleStoreUrl), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 20), + child: AppButton( + label: 'Android', + iconData: MdiIcons.android, + onPressed: () => launch(kGoogleStoreUrl), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 30), + child: Text('Desktop'), + ), + Padding( + padding: const EdgeInsets.only(top: 20), + child: AppButton( + label: 'Apple', + iconData: MdiIcons.apple, + onPressed: () => launch(kMacOSUrl), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 20), + child: AppButton( + label: 'Linux', + iconData: MdiIcons.linux, + onPressed: () => launch(kLinuxUrl), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 20), + child: Text('Windows coming soon...'), + ), + ], + ), + ); + }); + }, + ), + ), + //if (!state.isProduction) // TODO enable this check + Padding( + padding: const EdgeInsets.only(top: 20), child: AppButton( label: localization.healthCheck.toUpperCase(), iconData: MdiIcons.shield, + color: Colors.green, onPressed: () { showDialog( context: context, @@ -838,7 +907,7 @@ void _showAbout(BuildContext context) async { child: AppButton( label: localization.forceUpdate.toUpperCase(), iconData: MdiIcons.update, - color: Colors.grey, + color: Colors.orange, onPressed: () => _showUpdate(context), ), ), diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 933170024..5fc01f2bf 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -15,6 +15,7 @@ mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { // STARTER: lang key - do not remove comment + 'app_platforms': 'App Platforms', 'invoice_late': 'Invoice Late', 'quote_expired': 'Quote Expired', 'partial_due': 'Partial Due', @@ -5186,6 +5187,9 @@ mixin LocalizationsProvider on LocaleCodeAware { String get quoteExpired => _localizedValues[localeCode]['quote_expired'] ?? ''; + String get appPlatforms => + _localizedValues[localeCode]['app_platforms'] ?? ''; + String lookup(String key) { final lookupKey = toSnakeCase(key); diff --git a/lib/utils/platforms.dart b/lib/utils/platforms.dart index f940d9133..25607e02e 100644 --- a/lib/utils/platforms.dart +++ b/lib/utils/platforms.dart @@ -31,12 +31,13 @@ String getPlatform(BuildContext context) => Theme.of(context).platform == TargetPlatform.iOS ? 'ios' : 'android'; String getAppURL(BuildContext context) { - if (kIsWeb) { - return kCapterralUrl; - } else if (isAndroid(context)) { - return kGoogleStoreUrl; - } else { - return kAppleStoreUrl; + switch (Theme.of(context).platform) { + case TargetPlatform.android: + return kGoogleStoreUrl; + case TargetPlatform.iOS: + return kAppleStoreUrl; + default: + return kCapterralUrl; } }