Improved timer widget

This commit is contained in:
VincentMeilinger
2024-01-11 14:15:12 +01:00
parent b069555950
commit 9b225f63b5
5 changed files with 90 additions and 44 deletions

View File

@@ -61,8 +61,8 @@ struct RecipeDetailView: View {
}
Divider()
TimerView(timer: viewModel.getTimer(forRecipe: recipeDetail.id, timeTotal: 20))
RecipeDurationSection(recipeDetail: recipeDetail)
RecipeDurationSection(viewModel: viewModel, recipeDetail: recipeDetail)
LazyVGrid(columns: [GridItem(.adaptive(minimum: 400), alignment: .top)]) {
if(!recipeDetail.recipeIngredient.isEmpty) {
@@ -214,10 +214,11 @@ fileprivate struct ShareView: View {
fileprivate struct RecipeDurationSection: View {
@ObservedObject var viewModel: MainViewModel
@State var recipeDetail: RecipeDetail
var body: some View {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150), alignment: .leading)]) {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 250), alignment: .leading)]) {
if let prepTime = recipeDetail.prepTime, let time = DurationComponents.ptToText(prepTime) {
VStack(alignment: .leading) {
HStack {
@@ -229,6 +230,12 @@ fileprivate struct RecipeDurationSection: View {
}.padding()
}
if let cookTime = recipeDetail.cookTime, let time = DurationComponents.ptToText(cookTime) {
TimerView(timer: viewModel.getTimer(forRecipe: recipeDetail.id, duration: DurationComponents.fromPTString(cookTime)))
.padding()
}
/*
if let cookTime = recipeDetail.cookTime, let time = DurationComponents.ptToText(cookTime) {
VStack(alignment: .leading) {
HStack {
@@ -238,7 +245,7 @@ fileprivate struct RecipeDurationSection: View {
Text(time)
.lineLimit(1)
}.padding()
}
}*/
if let totalTime = recipeDetail.totalTime, let time = DurationComponents.ptToText(totalTime) {
VStack(alignment: .leading) {