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{
|
||||
String yamlString = await loadAsset(yamlPath);
|
||||
var yaml = loadYaml(yamlString);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -28,41 +28,20 @@ class PizzaEventWidget extends StatelessWidget {
|
|||
padding: const EdgeInsets.all(10),
|
||||
height: 72,
|
||||
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()
|
||||
)
|
||||
),
|
||||
]
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
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,
|
||||
)
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
Row(
|
||||
|
|
Loading…
Add table
Reference in a new issue