-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split fermentation and ingredients models
- Loading branch information
Showing
10 changed files
with
148 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.9.5 | ||
1.9.6 |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
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; | ||
|
||
void updateFermentationValues( | ||
{required double temperature, required TemperatureUnit temperatureUnit}) { | ||
_inoculation = getInoculationValue(temperature, temperatureUnit); | ||
_bulkRise = getBulkRiseValue(temperature, temperatureUnit); | ||
|
||
notifyListeners(); | ||
} | ||
} |
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,27 @@ | ||
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; | ||
|
||
void updateIngredientsValues( | ||
{required double totalWeight, | ||
required double hydration, | ||
required double saltLevel, | ||
required double inoculation}) { | ||
_flour = getFlourValue(totalWeight, hydration, saltLevel, inoculation); | ||
_water = getNonFlourIngredientValue(_flour, hydration); | ||
_levain = getNonFlourIngredientValue(_flour, inoculation); | ||
_salt = getNonFlourIngredientValue(_flour, saltLevel); | ||
|
||
notifyListeners(); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:sourdoc/methods/temperature_unit_helpers.dart'; | ||
import 'package:sourdoc/models/fermentation_model.dart'; | ||
|
||
void main() { | ||
group('FermentationModel', () { | ||
test('should have fermentation values', () { | ||
final model = FermentationModel(); | ||
expect(model.inoculation, 0); | ||
expect(model.bulkRise, 0); | ||
}); | ||
|
||
test('should update fermentation values', () { | ||
final model = FermentationModel(); | ||
var i = 0; | ||
model.addListener(() { | ||
expect(model.inoculation, greaterThan(0)); | ||
expect(model.bulkRise, greaterThan(0)); | ||
i++; | ||
}); | ||
model.updateFermentationValues( | ||
temperature: 20, temperatureUnit: TemperatureUnit.celsius); | ||
expect(i, 1); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.