-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
177 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:sourdoc/methods/temperature_unit_helpers.dart'; | ||
import 'package:sourdoc/methods/get_fermentation_values.dart'; | ||
|
||
class FermentationModel extends ChangeNotifier { | ||
double _inoculation = 0; | ||
double _bulkRise = 0; | ||
|
||
double get inoculation => _inoculation; | ||
double get bulkRise => _bulkRise; | ||
|
||
TextEditingController temperatureController = TextEditingController(); | ||
|
||
double _parseValue(TextEditingController controller) { | ||
if (controller.value.text.isEmpty) { | ||
return 0; | ||
} | ||
return double.parse(controller.value.text); | ||
} | ||
|
||
void updateFermentationValues() { | ||
final double temperature = _parseValue(temperatureController); | ||
|
||
_inoculation = getInoculationValue(temperature, _temperatureUnit); | ||
_bulkRise = getBulkRiseValue(temperature, _temperatureUnit); | ||
|
||
notifyListeners(); | ||
} | ||
|
||
late TemperatureUnit _temperatureUnit; | ||
|
||
void updateTemperatureUnit(TemperatureUnit temperatureUnit) { | ||
_temperatureUnit = temperatureUnit; | ||
updateFermentationValues(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:sourdoc/methods/get_ingredients_values.dart'; | ||
|
||
class IngredientsModel extends ChangeNotifier { | ||
double _flour = 0; | ||
double _water = 0; | ||
double _levain = 0; | ||
double _salt = 0; | ||
|
||
double get flour => _flour; | ||
double get water => _water; | ||
double get levain => _levain; | ||
double get salt => _salt; | ||
|
||
TextEditingController totalWeightController = TextEditingController(); | ||
TextEditingController hydrationController = TextEditingController(); | ||
TextEditingController saltController = TextEditingController(); | ||
|
||
double _parseValue(TextEditingController controller) { | ||
if (controller.value.text.isEmpty) { | ||
return 0; | ||
} | ||
return double.parse(controller.value.text); | ||
} | ||
|
||
void updateIngredientsValues() { | ||
final double totalWeight = _parseValue(totalWeightController); | ||
final double hydration = _parseValue(hydrationController); | ||
final double saltLevel = _parseValue(saltController); | ||
|
||
_flour = getFlourValue(totalWeight, hydration, saltLevel, _inoculation); | ||
_water = getNonFlourIngredientValue(_flour, hydration); | ||
_levain = getNonFlourIngredientValue(_flour, _inoculation); | ||
_salt = getNonFlourIngredientValue(_flour, saltLevel); | ||
|
||
notifyListeners(); | ||
} | ||
|
||
late double _inoculation; | ||
|
||
void updateInoculation(double inoculation) { | ||
_inoculation = inoculation; | ||
updateIngredientsValues(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters