added 'proper' indicator of how many steps have been completed for a pizza event

This commit is contained in:
broodjeaap89 2021-07-27 20:58:46 +02:00
parent 1cce0767c0
commit 50371642cb
4 changed files with 32 additions and 35 deletions

View file

@ -49,6 +49,17 @@ class PizzaRecipe extends HiveObject {
);
}
int getStepsCompleted(){
var stepCount = 0;
for (var recipeStep in this.recipeSteps) {
if (!recipeStep.completed) {
return stepCount;
}
stepCount++;
}
return stepCount;
}
static Future<PizzaRecipe> fromYaml(yamlPath) async{
String yamlString = await loadAsset(yamlPath);
var yaml = loadYaml(yamlString);

View file

@ -29,6 +29,8 @@ class RecipeStep extends HiveObject {
@HiveField(7)
List<RecipeSubStep> subSteps;
bool get completed => subSteps.every((subStep) => subStep.completed);
RecipeStep(this.name, this.description, this.waitDescription, this.waitUnit, this.waitMin, this.waitMax, this.subSteps) {
waitValue = waitMin;
}

View file

@ -11,5 +11,10 @@ class RecipeSubStep extends HiveObject {
@HiveField(1)
String description;
@HiveField(2)
DateTime? completedOn;
bool get completed => completedOn != null;
RecipeSubStep(this.name, this.description);
}

View file

@ -30,36 +30,15 @@ class PizzaEventWidget extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
width: 50,
height: 50,
child: Container(
color: Colors.green,
child: Container()
)
),
SizedBox(
width: 50,
height: 50,
child: Container(
color: Colors.green,
child: Container()
)
),
SizedBox(
width: 50,
height: 50,
child: Container(
color: Colors.green,
child: Container()
)
),
SizedBox(
width: 50,
height: 50,
child: Container(
color: Colors.green,
child: Container()
Expanded(
child: Slider(
min: 0.0,
max: pizzaEvent.recipe.recipeSteps.length.toDouble(),
divisions: pizzaEvent.recipe.recipeSteps.length,
value: pizzaEvent.recipe.getStepsCompleted().toDouble(),
onChanged: (d) {},
activeColor: Colors.green,
inactiveColor: Colors.white,
)
),
]