added 'proper' indicator of how many steps have been completed for a pizza event
This commit is contained in:
parent
1cce0767c0
commit
50371642cb
4 changed files with 32 additions and 35 deletions
|
@ -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{
|
static Future<PizzaRecipe> fromYaml(yamlPath) async{
|
||||||
String yamlString = await loadAsset(yamlPath);
|
String yamlString = await loadAsset(yamlPath);
|
||||||
var yaml = loadYaml(yamlString);
|
var yaml = loadYaml(yamlString);
|
||||||
|
|
|
@ -29,6 +29,8 @@ class RecipeStep extends HiveObject {
|
||||||
@HiveField(7)
|
@HiveField(7)
|
||||||
List<RecipeSubStep> subSteps;
|
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) {
|
RecipeStep(this.name, this.description, this.waitDescription, this.waitUnit, this.waitMin, this.waitMax, this.subSteps) {
|
||||||
waitValue = waitMin;
|
waitValue = waitMin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,5 +11,10 @@ class RecipeSubStep extends HiveObject {
|
||||||
@HiveField(1)
|
@HiveField(1)
|
||||||
String description;
|
String description;
|
||||||
|
|
||||||
|
@HiveField(2)
|
||||||
|
DateTime? completedOn;
|
||||||
|
|
||||||
|
bool get completed => completedOn != null;
|
||||||
|
|
||||||
RecipeSubStep(this.name, this.description);
|
RecipeSubStep(this.name, this.description);
|
||||||
}
|
}
|
|
@ -30,36 +30,15 @@ class PizzaEventWidget extends StatelessWidget {
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SizedBox(
|
Expanded(
|
||||||
width: 50,
|
child: Slider(
|
||||||
height: 50,
|
min: 0.0,
|
||||||
child: Container(
|
max: pizzaEvent.recipe.recipeSteps.length.toDouble(),
|
||||||
color: Colors.green,
|
divisions: pizzaEvent.recipe.recipeSteps.length,
|
||||||
child: Container()
|
value: pizzaEvent.recipe.getStepsCompleted().toDouble(),
|
||||||
)
|
onChanged: (d) {},
|
||||||
),
|
activeColor: Colors.green,
|
||||||
SizedBox(
|
inactiveColor: Colors.white,
|
||||||
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()
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue