Skip to content

Commit

Permalink
Display calculated variables in cards
Browse files Browse the repository at this point in the history
  • Loading branch information
duddu committed Oct 22, 2023
1 parent 3b63faf commit 19e3b2e
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 78 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.1
1.9.0
2 changes: 1 addition & 1 deletion lib/constants/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ const Map<TemperatureUnit, double> maxValueTemperatureMap = {
TemperatureUnit.celsius: 40,
TemperatureUnit.farenheit: 104
};
const double maxValueTotalWeight = 100000;
const double maxValueTotalWeight = 9999;
const double maxValueHydration = 99;
const double maxValueSaltLevel = 10;
4 changes: 2 additions & 2 deletions lib/constants/locale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const String variableLabelFlour = 'Flour';
const String variableLabelWater = 'Water';
const String variableLabelLevain = 'Starter';
const String variableLabelSalt = 'Salt';
const String variableLabelInoculation = 'Inoculation level';
const String variableLabelDoughRise = 'Target dough rise';
const String variableLabelInoculation = 'Inoculation';
const String variableLabelDoughRise = 'Dough rise';
const String unitGrams = 'g';
const String unitPercent = '%';
const String unitDegreesCelsius = 'ºC';
Expand Down
59 changes: 27 additions & 32 deletions lib/widgets/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,29 @@ class HomePageListView extends StatelessWidget {
return ListView(
primary: true,
padding: const EdgeInsets.only(bottom: 35),
children: <CenteredContainer>[
children: [
CenteredContainer(
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.inversePrimary
.withAlpha(170)),
padding: const EdgeInsets.fromLTRB(0, 10, 0, 11),
padding: const EdgeInsets.symmetric(vertical: 10),
child: Text(
style.isMobileScreenWidth(context)
? locale.formIntro
: locale.formIntroLarge,
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.bodySmall,
style: Theme.of(context).textTheme.bodyMedium,
)),
CenteredContainer(
decoration: BoxDecoration(
color:
Theme.of(context).colorScheme.inversePrimary.withAlpha(30),
border: Border(
bottom: BorderSide(width: 1, color: Colors.grey.shade300))),
padding: const EdgeInsets.symmetric(vertical: 12),
child: ChangeNotifierProvider(
create: (context) => TemperatureUnitModel(),
Card(
margin: EdgeInsets.zero,
semanticContainer: false,
shape: const RoundedRectangleBorder(),
child: CenteredContainer(
padding: const EdgeInsets.symmetric(vertical: 12),
child: ChangeNotifierProvider(
create: (context) => TemperatureUnitModel(),
child: const CalculatorForm()))),
const CenteredContainer(child: IngredientsValues()),
const CenteredContainer(child: FermentationValues()),
Expand Down Expand Up @@ -276,28 +275,24 @@ class IngredientsValues extends StatelessWidget {
return Consumer<CalculatorModel>(builder: (context, model, child) {
return Column(children: <Row>[
const Row(children: <Header>[Header(text: locale.headerIngredients)]),
Row(children: <VariableWithLabel>[
Row(children: [
VariableWithLabel(
label: locale.variableLabelFlour,
value: model.flour,
fractionDigits: 1,
unit: locale.unitGrams)
]),
Row(children: <VariableWithLabel>[
label: locale.variableLabelFlour,
value: model.flour,
fractionDigits: 1,
unit: locale.unitGrams,
noMarginLeft: true,
),
VariableWithLabel(
label: locale.variableLabelWater,
value: model.water,
fractionDigits: 1,
unit: locale.unitGrams)
]),
Row(children: <VariableWithLabel>[
unit: locale.unitGrams),
VariableWithLabel(
label: locale.variableLabelLevain,
value: model.levain,
fractionDigits: 1,
unit: locale.unitGrams)
]),
Row(children: <VariableWithLabel>[
unit: locale.unitGrams),
VariableWithLabel(
label: locale.variableLabelSalt,
value: model.salt,
Expand All @@ -319,13 +314,13 @@ class FermentationValues extends StatelessWidget {
const Row(children: <Header>[Header(text: locale.headerFermentation)]),
Row(children: <VariableWithLabel>[
VariableWithLabel(
label: locale.variableLabelInoculation,
value: model.inoculation,
fractionDigits: 0,
unit: locale.unitPercent,
additionalInfoText: locale.additionalInfoInoculation)
]),
Row(children: <VariableWithLabel>[
label: locale.variableLabelInoculation,
value: model.inoculation,
fractionDigits: 0,
unit: locale.unitPercent,
additionalInfoText: locale.additionalInfoInoculation,
noMarginLeft: true,
),
VariableWithLabel(
label: locale.variableLabelDoughRise,
value: model.bulkRise,
Expand Down
101 changes: 61 additions & 40 deletions lib/widgets/variable_with_label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class VariableWithLabel extends StatelessWidget {
required this.fractionDigits,
required this.unit,
this.additionalInfoText,
this.noMarginLeft = false,
});

final String label;
final double value;
final int fractionDigits;
final String unit;
final String? additionalInfoText;
final bool noMarginLeft;

bool _hasAdditionalInfo() =>
additionalInfoText != null && additionalInfoText!.isNotEmpty;
Expand All @@ -28,47 +30,66 @@ class VariableWithLabel extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
height: _isMobileDevice(context) ? 46 : 44,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Theme.of(context).colorScheme.inversePrimary,
width: 2,
),
),
),
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text(
'$label:',
style: Theme.of(context).textTheme.bodyLarge,
textAlign: TextAlign.start,
),
if (_hasAdditionalInfo())
Expanded(
flex: 0,
child: Semantics(
button: true,
focusable: true,
label: locale.a11yVariableInfoButtonLabel,
hint: locale.a11yVariableInfoButtonHint,
child: InfoButton(
title: label,
text: additionalInfoText!,
))),
child: Card(
semanticContainer: true,
margin: EdgeInsets.fromLTRB(noMarginLeft ? 0 : 11, 5, 0, 3),
child: Padding(
padding: EdgeInsets.fromLTRB(
_hasAdditionalInfo() ? 19 : 2,
_hasAdditionalInfo() && _isMobileDevice(context) ? 9 : 12,
_hasAdditionalInfo() ? 4 : 2,
_hasAdditionalInfo() && _isMobileDevice(context) ? 8 : 11),
child: Row(children: [
Expanded(
child: Text(
'${value.toStringAsFixed(fractionDigits)}$unit',
semanticsLabel: label,
style: Theme.of(context).textTheme.bodyLarge,
textAlign: TextAlign.end,
)),
],
)
])),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
label,
style: TextStyle(
overflow: TextOverflow.clip,
fontSize: Theme.of(context)
.textTheme
.bodyMedium!
.fontSize,
color: Colors.grey.shade800,
height: 1.45),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${value.toStringAsFixed(fractionDigits)}$unit',
semanticsLabel: label,
style: TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: Theme.of(context)
.textTheme
.bodyLarge!
.fontSize,
height: 1.35),
),
],
)
])),
if (_hasAdditionalInfo())
Semantics(
button: true,
focusable: true,
label: locale.a11yVariableInfoButtonLabel,
hint: locale.a11yVariableInfoButtonHint,
child: InfoButton(
title: label,
text: additionalInfoText!,
)),
]))),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/download-release-asset.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<title>Download Sourdoc release asset</title>
<script>
const version = '1.8.1';
const version = '1.9.0';
const build = new URLSearchParams(window.location.search).get('build');
window.location.href = 'https://github.com/duddu/sourdoc/releases/download/v' + version + '/' + build + '-sourdoc-v' + version + '.tgz';
</script>
Expand Down
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ZS2J7KXZ0Q"></script>
<script defer src="gtm-gtag.js"></script>
<script>
const serviceWorkerVersion = '1.8.1';
const serviceWorkerVersion = '1.9.0';
</script>
<script defer src="flutter.js"></script>
</head>
Expand Down

0 comments on commit 19e3b2e

Please sign in to comment.