Skip to content

Commit

Permalink
feat: Add some consistency between dialogs in the profile (openfoodfa…
Browse files Browse the repository at this point in the history
…cts#4458)

* Add some consistency between dialogs in the profile

* Update goldens

* (Re) update goldens
  • Loading branch information
g123k authored Aug 6, 2023
1 parent a4998cd commit 7815266
Show file tree
Hide file tree
Showing 21 changed files with 114 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<LocalDatabase>();
Expand All @@ -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,
);
},
);
Expand All @@ -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: <Widget>[
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,
),
);
Expand Down Expand Up @@ -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,
);
},
);
Expand Down Expand Up @@ -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,
);
}
}
Expand Down
96 changes: 39 additions & 57 deletions packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,72 +137,54 @@ class UserPreferencesFaq extends AbstractUserPreferences {
),
],
),
Divider(color: themeData.colorScheme.onSurface),
const SizedBox(height: VERY_LARGE_SPACE),
SingleChildScrollView(
child: Column(
children: <Widget>[
Text(appLocalizations.whatIsOff),
const SizedBox(height: LARGE_SPACE),
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
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: <Widget>[
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,
),
);
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/login_page-amoled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/login_page-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/login_page-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/signup_page-amoled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/signup_page-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/smooth_app/test/users/goldens/signup_page-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7815266

Please sign in to comment.