Skip to content

Commit

Permalink
fix: Overflow issue on 'update nutrition facts' page. (#1306)
Browse files Browse the repository at this point in the history
* fix: 1303

* removed additional files

* used mediaquery

* added commas
  • Loading branch information
bhattabhi013 authored Mar 26, 2022
1 parent eaf83df commit 180d0b4
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/smooth_app/lib/pages/product/nutrition_page_loaded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
// If true then serving, if false then 100g.
bool _servingOr100g = false;

static const double _columnSize1 = 250; // TODO(monsieurtanuki): proper size
static const double _columnSize2 =
100; // TODO(monsieurtanuki): anyway, should fit the largest text, probably 'mcg/µg'
double getColumnSizeFromContext(
BuildContext context,
double adjustmentFactor,
) {
final double _columnSize = MediaQuery.of(context).size.width;
return _columnSize * adjustmentFactor;
}

final Map<String, TextEditingController> _controllers =
<String, TextEditingController>{};
Expand Down Expand Up @@ -74,10 +78,7 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
for (final OrderedNutrient orderedNutrient
in _nutritionContainer.getDisplayableNutrients()) {
children.add(
_getNutrientRow(
appLocalizations,
orderedNutrient,
),
_getNutrientRow(appLocalizations, orderedNutrient),
);
}
children.add(_addNutrientButton(appLocalizations));
Expand Down Expand Up @@ -108,15 +109,15 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: _columnSize1,
width: getColumnSizeFromContext(context, 0.6),
child: _getNutrientCell(
appLocalizations,
orderedNutrient,
_servingOr100g,
),
),
SizedBox(
width: _columnSize2,
width: getColumnSizeFromContext(context, 0.3),
child: _getUnitCell(orderedNutrient),
),
],
Expand Down Expand Up @@ -232,7 +233,7 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
Container(
color: Theme.of(context).colorScheme.primary,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Switch(
Expand All @@ -241,7 +242,7 @@ class _NutritionPageLoadedState extends State<NutritionPageLoaded> {
setState(() => _unspecified = !_unspecified),
),
SizedBox(
width: 300, // TODO(monsieurtanuki): proper size
width: getColumnSizeFromContext(context, 0.6),
child: Text(
appLocalizations.nutrition_page_unspecified,
style: const TextStyle(color: Colors.white),
Expand Down

0 comments on commit 180d0b4

Please sign in to comment.