diff --git a/packages/smooth_app/lib/generic_lib/dialogs/smooth_alert_dialog.dart b/packages/smooth_app/lib/generic_lib/dialogs/smooth_alert_dialog.dart index 8088a5ac655..789667dda47 100644 --- a/packages/smooth_app/lib/generic_lib/dialogs/smooth_alert_dialog.dart +++ b/packages/smooth_app/lib/generic_lib/dialogs/smooth_alert_dialog.dart @@ -501,6 +501,40 @@ class _SmoothActionFlatButton extends StatelessWidget { } } +/// A [Button] that can be displayed in the [body] of a [SmoothAlertDialog]. +class SmoothAlertContentButton extends StatelessWidget { + const SmoothAlertContentButton({ + required this.label, + required this.onPressed, + this.icon, + }); + + final String label; + final IconData? icon; + final VoidCallback onPressed; + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: onPressed, + child: FractionallySizedBox( + widthFactor: 0.8, + child: Row( + children: [ + Expanded( + child: Text(label), + ), + if (icon != null) + ExcludeSemantics( + child: Icon(icon), + ), + ], + ), + ), + ); + } +} + /// A custom dialog where you only have to pass a [title] and a [message]. /// By default an "OK" button will be show., but you can override it by passing /// a [positiveAction] and/or [negativeAction] diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart index e96ad53ead0..5d7e482842d 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_contribute.dart @@ -114,14 +114,8 @@ class UserPreferencesContribute extends AbstractUserPreferences { ], ), positiveAction: SmoothActionButton( - text: appLocalizations.okay, - minWidth: 100, - onPressed: () => Navigator.pop(context), - ), - negativeAction: SmoothActionButton( text: AppLocalizations.of(context) .contribute_improve_ProductsToBeCompleted, - minWidth: 150, onPressed: () async { final LocalDatabase localDatabase = context.read(); @@ -136,8 +130,15 @@ class UserPreferencesContribute extends AbstractUserPreferences { ); }, ), + negativeAction: SmoothActionButton( + onPressed: () { + Navigator.of(context, rootNavigator: true).pop('dialog'); + }, + text: appLocalizations.close, + minWidth: 100, + ), actionsAxis: Axis.vertical, - actionsOrder: SmoothButtonsBarOrder.numerical, + actionsOrder: SmoothButtonsBarOrder.auto, ); }, ); @@ -155,34 +156,28 @@ class UserPreferencesContribute extends AbstractUserPreferences { const SizedBox(height: VERY_LARGE_SPACE), Text(appLocalizations.contribute_develop_text_2), const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextButton( - onPressed: () => LaunchUrlHelper.launchURL( - 'https://slack.openfoodfacts.org/', false), - child: const Text( - 'Slack', - style: TextStyle(color: Colors.blue), - ), - ), - TextButton( - onPressed: () => LaunchUrlHelper.launchURL( - 'https://github.com/openfoodfacts', false), - child: const Text( - 'Github', - style: TextStyle(color: Colors.blue), - ), - ), - ], + SmoothAlertContentButton( + label: 'Slack', + icon: Icons.open_in_new, + onPressed: () => LaunchUrlHelper.launchURL( + 'https://slack.openfoodfacts.org/', false), + ), + const SizedBox(height: SMALL_SPACE), + SmoothAlertContentButton( + label: 'GitHub', + icon: Icons.open_in_new, + onPressed: () => LaunchUrlHelper.launchURL( + 'https://github.com/openfoodfacts', false), ), const SizedBox(height: 10), const _DevModeSetting(), ], ), - positiveAction: SmoothActionButton( - onPressed: () => Navigator.pop(context), - text: appLocalizations.okay, + negativeAction: SmoothActionButton( + onPressed: () { + Navigator.of(context, rootNavigator: true).pop('dialog'); + }, + text: appLocalizations.close, minWidth: 100, ), ); @@ -211,6 +206,15 @@ class UserPreferencesContribute extends AbstractUserPreferences { 'https://translate.openfoodfacts.org/', false), text: appLocalizations.contribute_translate_link_text, ), + negativeAction: SmoothActionButton( + onPressed: () { + Navigator.of(context, rootNavigator: true).pop('dialog'); + }, + text: appLocalizations.close, + minWidth: 100, + ), + actionsAxis: Axis.vertical, + actionsOrder: SmoothButtonsBarOrder.auto, ); }, ); @@ -338,20 +342,20 @@ class _ContributorsDialog extends StatelessWidget { }, ), positiveAction: SmoothActionButton( + onPressed: () => LaunchUrlHelper.launchURL( + 'https://github.com/openfoodfacts/smooth-app', false), + text: AppLocalizations.of(context).contribute, + minWidth: 150, + ), + negativeAction: SmoothActionButton( onPressed: () { Navigator.of(context, rootNavigator: true).pop('dialog'); }, text: appLocalizations.close, minWidth: 100, ), - negativeAction: SmoothActionButton( - onPressed: () => LaunchUrlHelper.launchURL( - 'https://github.com/openfoodfacts/smooth-app', false), - text: AppLocalizations.of(context).contribute, - minWidth: 150, - ), actionsAxis: Axis.vertical, - actionsOrder: SmoothButtonsBarOrder.numerical, + actionsOrder: SmoothButtonsBarOrder.auto, ); } } diff --git a/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart b/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart index 9d4e7d0d005..608f762859a 100644 --- a/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart +++ b/packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart @@ -137,72 +137,54 @@ class UserPreferencesFaq extends AbstractUserPreferences { ), ], ), - Divider(color: themeData.colorScheme.onSurface), const SizedBox(height: VERY_LARGE_SPACE), SingleChildScrollView( - child: Column( - children: [ - Text(appLocalizations.whatIsOff), - const SizedBox(height: LARGE_SPACE), - IntrinsicHeight( - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: TextButton( - onPressed: () => LaunchUrlHelper.launchURL( - 'https://openfoodfacts.org/who-we-are', true), - child: Text( - appLocalizations.learnMore, - textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.blue, - ), - ), - ), + child: IconTheme( + data: const IconThemeData(size: 16.0), + child: Column( + children: [ + FractionallySizedBox( + widthFactor: 0.9, + child: Text(appLocalizations.whatIsOff), + ), + const SizedBox(height: LARGE_SPACE), + SmoothAlertContentButton( + onPressed: () => LaunchUrlHelper.launchURL( + 'https://openfoodfacts.org/who-we-are', true), + label: appLocalizations.learnMore, + icon: Icons.open_in_new, + ), + const SizedBox(height: SMALL_SPACE), + SmoothAlertContentButton( + onPressed: () => LaunchUrlHelper.launchURL( + 'https://openfoodfacts.org/terms-of-', true), + label: appLocalizations.termsOfUse, + icon: Icons.open_in_new, + ), + const SizedBox(height: SMALL_SPACE), + SmoothAlertContentButton( + onPressed: () => showLicensePage( + context: context, + applicationName: packageInfo.appName, + applicationVersion: packageInfo.version, + applicationIcon: SvgPicture.asset( + logo, + height: MediaQuery.of(context).size.height * 0.1, ), - Expanded( - child: TextButton( - onPressed: () => LaunchUrlHelper.launchURL( - 'https://openfoodfacts.org/terms-of-use', - true), - child: Text( - appLocalizations.termsOfUse, - textAlign: TextAlign.center, - style: const TextStyle( - color: Colors.blue, - ), - ), - ), - ) - ], + ), + label: appLocalizations.licenses, + icon: Icons.info, ), - ), - ], + const SizedBox(height: SMALL_SPACE), + ], + ), ), ), ], ), - positiveAction: SmoothActionButton( - onPressed: () => Navigator.of(context, rootNavigator: true).pop(), - text: appLocalizations.okay, - ), negativeAction: SmoothActionButton( - onPressed: () async { - Navigator.of(context).pop(); - - showLicensePage( - context: context, - applicationName: packageInfo.appName, - applicationVersion: packageInfo.version, - applicationIcon: SvgPicture.asset( - logo, - height: MediaQuery.of(context).size.height * 0.1, - ), - ); - }, - text: appLocalizations.licenses, + onPressed: () => Navigator.of(context, rootNavigator: true).pop(), + text: appLocalizations.close, ), ); }, diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-amoled.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-amoled.png index 488de4e5eb6..4880822c9e4 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-amoled.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-amoled.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-dark.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-dark.png index 68131ffeef6..f96ec95a9d3 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-dark.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-dark.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-light.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-light.png index e274c25004f..865123c5537 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-light.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Improving-light.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-amoled.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-amoled.png index c9745182b80..6159aa2f844 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-amoled.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-amoled.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-dark.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-dark.png index 781019430e0..ad0efeb92cf 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-dark.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-dark.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-light.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-light.png index 2f7613f2fb3..c56e9468151 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-light.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Software development-light.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-amoled.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-amoled.png index a443af21fb3..ad13bbf348c 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-amoled.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-amoled.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-dark.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-dark.png index be07715e3ff..496ec3a80f5 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-dark.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-dark.png differ diff --git a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-light.png b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-light.png index 028a39256c8..42685225859 100644 Binary files a/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-light.png and b/packages/smooth_app/test/dialogs/generic_lib/goldens/user_preferences_page_dialogs_Translate-light.png differ diff --git a/packages/smooth_app/test/pages/goldens/user_preferences_page-amoled.png b/packages/smooth_app/test/pages/goldens/user_preferences_page-amoled.png index d315ea48c0e..72a3e41bd50 100644 Binary files a/packages/smooth_app/test/pages/goldens/user_preferences_page-amoled.png and b/packages/smooth_app/test/pages/goldens/user_preferences_page-amoled.png differ diff --git a/packages/smooth_app/test/pages/goldens/user_preferences_page-dark.png b/packages/smooth_app/test/pages/goldens/user_preferences_page-dark.png index db63b4195e2..890a5c3161e 100644 Binary files a/packages/smooth_app/test/pages/goldens/user_preferences_page-dark.png and b/packages/smooth_app/test/pages/goldens/user_preferences_page-dark.png differ diff --git a/packages/smooth_app/test/pages/goldens/user_preferences_page-light.png b/packages/smooth_app/test/pages/goldens/user_preferences_page-light.png index 412f0d18e82..3d7a3e0263d 100644 Binary files a/packages/smooth_app/test/pages/goldens/user_preferences_page-light.png and b/packages/smooth_app/test/pages/goldens/user_preferences_page-light.png differ diff --git a/packages/smooth_app/test/users/goldens/login_page-amoled.png b/packages/smooth_app/test/users/goldens/login_page-amoled.png index d36bd49c6f4..ee2cd01f323 100644 Binary files a/packages/smooth_app/test/users/goldens/login_page-amoled.png and b/packages/smooth_app/test/users/goldens/login_page-amoled.png differ diff --git a/packages/smooth_app/test/users/goldens/login_page-dark.png b/packages/smooth_app/test/users/goldens/login_page-dark.png index 39fadc9d20a..95dfcd57cd3 100644 Binary files a/packages/smooth_app/test/users/goldens/login_page-dark.png and b/packages/smooth_app/test/users/goldens/login_page-dark.png differ diff --git a/packages/smooth_app/test/users/goldens/login_page-light.png b/packages/smooth_app/test/users/goldens/login_page-light.png index 39ec4b740d5..6ead0e4c9a0 100644 Binary files a/packages/smooth_app/test/users/goldens/login_page-light.png and b/packages/smooth_app/test/users/goldens/login_page-light.png differ diff --git a/packages/smooth_app/test/users/goldens/signup_page-amoled.png b/packages/smooth_app/test/users/goldens/signup_page-amoled.png index a4119f65446..990953dfcaa 100644 Binary files a/packages/smooth_app/test/users/goldens/signup_page-amoled.png and b/packages/smooth_app/test/users/goldens/signup_page-amoled.png differ diff --git a/packages/smooth_app/test/users/goldens/signup_page-dark.png b/packages/smooth_app/test/users/goldens/signup_page-dark.png index 0c898098c81..be9259ccc63 100644 Binary files a/packages/smooth_app/test/users/goldens/signup_page-dark.png and b/packages/smooth_app/test/users/goldens/signup_page-dark.png differ diff --git a/packages/smooth_app/test/users/goldens/signup_page-light.png b/packages/smooth_app/test/users/goldens/signup_page-light.png index f33dc72fa02..fcddd0428db 100644 Binary files a/packages/smooth_app/test/users/goldens/signup_page-light.png and b/packages/smooth_app/test/users/goldens/signup_page-light.png differ