diff --git a/lib/entities/PizzaRecipe/PizzaRecipe.dart b/lib/entities/PizzaRecipe/PizzaRecipe.dart index d053671..18302ba 100644 --- a/lib/entities/PizzaRecipe/PizzaRecipe.dart +++ b/lib/entities/PizzaRecipe/PizzaRecipe.dart @@ -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 fromYaml(yamlPath) async{ String yamlString = await loadAsset(yamlPath); var yaml = loadYaml(yamlString); diff --git a/lib/entities/PizzaRecipe/RecipeStep.dart b/lib/entities/PizzaRecipe/RecipeStep.dart index 31cdcd9..17f5f6c 100644 --- a/lib/entities/PizzaRecipe/RecipeStep.dart +++ b/lib/entities/PizzaRecipe/RecipeStep.dart @@ -29,6 +29,8 @@ class RecipeStep extends HiveObject { @HiveField(7) List 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; } diff --git a/lib/entities/PizzaRecipe/RecipeSubStep.dart b/lib/entities/PizzaRecipe/RecipeSubStep.dart index 16ea21d..ab137d6 100644 --- a/lib/entities/PizzaRecipe/RecipeSubStep.dart +++ b/lib/entities/PizzaRecipe/RecipeSubStep.dart @@ -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); } \ No newline at end of file diff --git a/lib/widgets/PizzaEventWidget.dart b/lib/widgets/PizzaEventWidget.dart index de87a12..8815294 100644 --- a/lib/widgets/PizzaEventWidget.dart +++ b/lib/widgets/PizzaEventWidget.dart @@ -28,41 +28,20 @@ class PizzaEventWidget extends StatelessWidget { padding: const EdgeInsets.all(10), height: 72, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - 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: [ + 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(