add edit step + do recipe in main view, added carousel for recipe selection

This commit is contained in:
2026-03-12 22:57:15 +01:00
parent 90257a62a0
commit d5dacb8fc4
21 changed files with 1052 additions and 279 deletions

View File

@@ -1,4 +1,5 @@
from .recipe import V60, ESPRESSO, Recipe
from typing import List
from .recipe import V60, ESPRESSO, Recipe, Step, StepType
class RecipeManager:
def __init__(self):
@@ -7,6 +8,8 @@ class RecipeManager:
ESPRESSO
]
self.tmp_recipe = None
self.active_recipe: Recipe = None
self.current_recipe_step_id = 0
def add_recipe(self, recipe):
self.recipes.append(recipe)
@@ -21,6 +24,46 @@ class RecipeManager:
return self.recipes.index(recipe)
def get_recipe(self, recipe_id) -> Recipe:
if recipe_id == None:
if recipe_id is None:
return self.tmp_recipe
return self.recipes[recipe_id]
return self.recipes[recipe_id]
def activate_recipe(self, recipe_id):
self.active_recipe = self.get_recipe(recipe_id)
def deactivate_recipe(self):
self.active_recipe = None
self.current_recipe_step_id = 0
def get_current_step(self) -> List[Step]:
steps = [None] * 3
if self.active_recipe is None:
return steps
if self.current_recipe_step_id > len(self.active_recipe.steps):
return steps
if self.current_recipe_step_id > 0:
steps[0] = self.active_recipe.steps[self.current_recipe_step_id - 1]
if self.current_recipe_step_id < len(self.active_recipe.steps):
steps[1] = self.active_recipe.steps[self.current_recipe_step_id]
elif self.current_recipe_step_id == len(self.active_recipe.steps):
steps[1] = Step(StepType.SECTION, "Enjoy")
if self.current_recipe_step_id < len(self.active_recipe.steps) - 1:
steps[2] = self.active_recipe.steps[self.current_recipe_step_id + 1]
return steps
def next_step(self) -> List[Step]:
if self.active_recipe is None:
return [None] * 3
self.current_recipe_step_id = min(self.current_recipe_step_id + 1, len(self.active_recipe.steps) + 1)
return self.get_current_step()
def previous_step(self) -> List[Step]:
if self.active_recipe is None:
return [None] * 3
self.current_recipe_step_id = max(0, self.current_recipe_step_id - 1)
return self.get_current_step()