Skip to content

Commit

Permalink
feat: openfoodfacts#960 - adjustments for the goldens test
Browse files Browse the repository at this point in the history
Impacted files:
* `attribute_button.dart`: adjustments in order to pass the goldens test.
* `design_constants.dart`: added a constant for the minimum target size (according to goldens).
* `user_preferences_page-blue-dark.png`: impacted by new display.
* `user_preferences_page-blue-light.png`: impacted by new display.
* `user_preferences_page-brown-dark.png`: impacted by new display.
* `user_preferences_page-brown-light.png`: impacted by new display.
* `user_preferences_page-green-dark.png`: impacted by new display.
* `user_preferences_page-green-light.png`: impacted by new display.
  • Loading branch information
monsieurtanuki committed Apr 17, 2022
1 parent b4046c0 commit 9f49ab2
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 65 deletions.
3 changes: 3 additions & 0 deletions packages/smooth_app/lib/generic_lib/design_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const double VERY_LARGE_SPACE = 20.0;
/// Default icon size, cf. [Icon]
const double DEFAULT_ICON_SIZE = 24.0;

/// Default icon size, cf. goldens.dart
const double MINIMUM_TARGET_SIZE = 48.0;

/// Background, e.g SmoothCard
const Radius ROUNDED_RADIUS = Radius.circular(20.0);
//ignore: non_constant_identifier_names
Expand Down
124 changes: 59 additions & 65 deletions packages/smooth_app/lib/widgets/attribute_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,53 +37,49 @@ class AttributeButton extends StatelessWidget {
final double importanceWidth = widgetWidth / 4;
final TextStyle style = themeData.textTheme.headline3!;
final String? info = attribute.settingNote;
final List<Widget> labelChildren = <Widget>[];
final List<Widget> importanceChildren = <Widget>[];
final List<Widget> children = <Widget>[];
for (final String importanceId in _importanceIds) {
Future<void> selectImportance() async {
await productPreferences.setImportance(attribute.id!, importanceId);
await showDialog<void>(
context: context,
builder: (BuildContext context) {
children.add(
GestureDetector(
onTap: () async {
await productPreferences.setImportance(attribute.id!, importanceId);
final AppLocalizations? appLocalizations =
AppLocalizations.of(context);
return SmoothAlertDialog(
body: Text(
'blah blah blah importance "$importanceId"'), // TODO(monsieurtanuki): find translations
actions: <SmoothActionButton>[
SmoothActionButton(
text: appLocalizations!.close,
onPressed: () => Navigator.pop(context),
),
],
await showDialog<void>(
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
body: Text(
'blah blah blah importance "$importanceId"'), // TODO(monsieurtanuki): find translations
actions: <SmoothActionButton>[
SmoothActionButton(
text: appLocalizations!.close,
onPressed: () => Navigator.pop(context),
),
],
),
);
},
);
}

labelChildren.add(
GestureDetector(
onTap: () async => selectImportance(),
child: SizedBox(
width: importanceWidth,
child: AutoSizeText(
productPreferences
.getPreferenceImportanceFromImportanceId(importanceId)!
.name!,
maxLines: 2,
textAlign: TextAlign.center,
),
),
),
);
importanceChildren.add(
SizedBox(
width: importanceWidth,
child: Center(
child: Radio<String>(
groupValue: currentImportanceId,
value: importanceId,
onChanged: (final String? value) async => selectImportance(),
height: MINIMUM_TARGET_SIZE,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
AutoSizeText(
productPreferences
.getPreferenceImportanceFromImportanceId(importanceId)!
.name!,
maxLines: 1,
textAlign: TextAlign.center,
),
Icon(
currentImportanceId == importanceId
? Icons.radio_button_checked
: Icons.radio_button_off,
color: themeData.colorScheme.primary,
),
],
),
),
),
Expand All @@ -99,27 +95,30 @@ class AttributeButton extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
if (info != null) const Icon(Icons.info_outline),
Container(
padding: info == null
? null
: const EdgeInsets.only(left: SMALL_SPACE),
child: SizedBox(
width: widgetWidth -
SMALL_SPACE -
(iconThemeData.size ?? DEFAULT_ICON_SIZE),
child: AutoSizeText(
attribute.settingName ?? attribute.name!,
maxLines: 2,
style: style,
child: SizedBox(
height: MINIMUM_TARGET_SIZE,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
if (info != null) const Icon(Icons.info_outline),
Container(
padding: info == null
? null
: const EdgeInsets.only(left: SMALL_SPACE),
child: SizedBox(
width: widgetWidth -
SMALL_SPACE -
(iconThemeData.size ?? DEFAULT_ICON_SIZE),
child: AutoSizeText(
attribute.settingName ?? attribute.name!,
maxLines: 2,
style: style,
),
),
),
),
],
],
),
),
onTap: info == null
? null
Expand All @@ -143,12 +142,7 @@ class AttributeButton extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: labelChildren,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: importanceChildren,
children: children,
),
],
),
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 9f49ab2

Please sign in to comment.