Skip to content

Commit

Permalink
fix: Revamp of the about screen openfoodfacts#4412 openfoodfacts#4457
Browse files Browse the repository at this point in the history
…updated design
  • Loading branch information
ADILAYOUB committed Sep 3, 2023
1 parent 2283854 commit 4ce3a48
Showing 1 changed file with 62 additions and 77 deletions.
139 changes: 62 additions & 77 deletions packages/smooth_app/lib/pages/preferences/user_preferences_faq.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:smooth_app/helpers/user_feedback_helper.dart';
import 'package:smooth_app/pages/preferences/abstract_user_preferences.dart';
import 'package:smooth_app/pages/preferences/user_preferences_list_tile.dart';
import 'package:smooth_app/pages/preferences/user_preferences_page.dart';
import 'package:smooth_app/themes/constant_icons.dart';

/// Display of "FAQ" for the preferences page.
class UserPreferencesFaq extends AbstractUserPreferences {
Expand Down Expand Up @@ -91,7 +92,20 @@ class UserPreferencesFaq extends AbstractUserPreferences {
UserPreferencesListTile.getTintedIcon(Icons.open_in_new, context),
leading: UserPreferencesListTile.getTintedIcon(leading, context),
);

Widget _getAboutListTile({
required final String title,
final IconData? trailing,
final String? url,
final VoidCallback? onTap,
}) =>
UserPreferencesListTile(
title: Text(title),
onTap: onTap ?? () async => LaunchUrlHelper.launchURL(url!, false),
trailing: trailing != null
? Icon(trailing) // Use the Icon widget directly with the IconData.
: null,
);
ConstantIcons constantIcons = ConstantIcons.instance;
static const String _iconLightAssetPath =
'assets/app/release_icon_light_transparent_no_border.svg';
static const String _iconDarkAssetPath =
Expand All @@ -100,48 +114,39 @@ class UserPreferencesFaq extends AbstractUserPreferences {
Future<void> _about() async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
// ignore: use_build_context_synchronously
showModalBottomSheet<void>(
showDialog<void>(
context: context,
builder: (BuildContext context) {
final String logo = Theme.of(context).brightness == Brightness.light
? _iconLightAssetPath
: _iconDarkAssetPath;
return FractionallySizedBox(
heightFactor: 0.6,
child: Column(

return SmoothAlertDialog(
body: Column(
children: <Widget>[
Padding(
padding: const EdgeInsetsDirectional.only(
top: MEDIUM_SPACE,
end: LARGE_SPACE,
start: LARGE_SPACE,
),
child: Row(
children: <Widget>[
SvgPicture.asset(
logo,
width: MINIMUM_TOUCH_SIZE,
package: AppHelper.APP_PACKAGE,
),
const SizedBox(width: SMALL_SPACE),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
FittedBox(
child: Text(
packageInfo.appName,
style: themeData.textTheme.displayLarge,
),
),
Text(
'${packageInfo.version}+${packageInfo.buildNumber}-${GlobalVars.scannerLabel.name}-${GlobalVars.storeLabel.name}',
style: themeData.textTheme.titleSmall,
)
],
padding: const EdgeInsetsDirectional.all(MEDIUM_SPACE),
child: ListTile(
leading: SvgPicture.asset(
logo,
width: MINIMUM_TOUCH_SIZE,
package: AppHelper.APP_PACKAGE,
),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
FittedBox(
child: Text(
packageInfo.appName,
style: themeData.textTheme.displayLarge,
),
),
),
],
Text(
'${packageInfo.version}+${packageInfo.buildNumber}-${GlobalVars.scannerLabel.name}-${GlobalVars.storeLabel.name}',
style: themeData.textTheme.titleSmall,
)
],
),
),
),
Divider(color: themeData.colorScheme.onBackground),
Expand All @@ -155,43 +160,26 @@ class UserPreferencesFaq extends AbstractUserPreferences {
),
child: Text(appLocalizations.whatIsOff),
),
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,
),
),
),
),
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,
),
),
),
)
],
_getAboutListTile(
title: appLocalizations.learnMore,
trailing: constantIcons.getForwardIcon(),
onTap: () => LaunchUrlHelper.launchURL(
'https://openfoodfacts.org/who-we-are',
true,
),
),
const SizedBox(height: MEDIUM_SPACE),
TextButton(
onPressed: () async {
_getAboutListTile(
title: appLocalizations.termsOfUse,
trailing: constantIcons.getForwardIcon(),
onTap: () => LaunchUrlHelper.launchURL(
'https://openfoodfacts.org/terms-of-use',
false,
),
),
_getAboutListTile(
title: appLocalizations.licenses,
trailing: Icons.info,
onTap: () async {
Navigator.of(context).pop();
showLicensePage(
context: context,
Expand All @@ -203,18 +191,15 @@ class UserPreferencesFaq extends AbstractUserPreferences {
),
);
},
child: Text(
appLocalizations.licenses,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.blue,
),
),
),
],
),
],
),
negativeAction: SmoothActionButton(
onPressed: () => Navigator.of(context, rootNavigator: true).pop(),
text: appLocalizations.close,
),
);
},
);
Expand Down

0 comments on commit 4ce3a48

Please sign in to comment.