-
-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: #2561 - fixed value+unit management in nutrient page #2568
fix: #2561 - fixed value+unit management in nutrient page #2568
Conversation
Impacted files: * `nutrition_page_loaded.dart`: little fix - now we consider the page edited also when at least one unit changed. * `nutrition_container.dart`: fix - now we populate units and we don't convert values when saving to the server; added initial units field for the "were units edited?" check; refactored
Codecov Report
@@ Coverage Diff @@
## develop #2568 +/- ##
==========================================
- Coverage 8.86% 7.56% -1.31%
==========================================
Files 161 210 +49
Lines 6623 10090 +3467
==========================================
+ Hits 587 763 +176
- Misses 6036 9327 +3291
Continue to review full report at Codecov.
|
void _setUnit( | ||
final String nutrientId, | ||
final Unit unit, { | ||
required final bool init, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you document this field please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe in comments here:
- it's a private method
- the parameter has a decent name (
init
? "it must have something to do with the init phase") - the method is used only twice, first time at init time with
init: true
, and later withinit: false
final String text = controller.value.text; | ||
final double? value = getValue(key); | ||
if (value == null) { | ||
if (text != '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNotEmpty
wouldn't be better here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it would have been the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @monsieurtanuki
Impacted files:
nutrition_page_loaded.dart
: little fix - now we consider the page edited also when at least one unit changed.nutrition_container.dart
: fix - now we populate units and we don't convert values when saving to the server; added initial units field for the "were units edited?" check; refactoredWhat
0.12
andmg
, which means 0.12 grams to be displayed in mg, therefore as "120 mg"). You have to convert the value from grams into the given unit.120
andmg
(more intuitive)Should we automatically compute one from the other in the app?
Part of