Basic Edit View and components

This commit is contained in:
Vicnet
2023-09-30 10:07:27 +02:00
parent d4db6fbd82
commit ee1c0d9aed
21 changed files with 485 additions and 206 deletions

View File

@@ -12,7 +12,7 @@ struct RecipeCardView: View {
@State var viewModel: MainViewModel
@State var recipe: Recipe
@State var recipeThumb: UIImage?
@State var isDownloaded: Bool
@State var isDownloaded: Bool? = nil
var body: some View {
HStack {
@@ -25,18 +25,21 @@ struct RecipeCardView: View {
.font(.headline)
Spacer()
VStack {
Image(systemName: isDownloaded ? "checkmark.icloud" : "icloud.and.arrow.down")
.foregroundColor(.secondary)
.padding()
Spacer()
if let isDownloaded = isDownloaded {
VStack {
Image(systemName: isDownloaded ? "checkmark.circle" : "icloud.and.arrow.down")
.foregroundColor(.secondary)
.padding()
Spacer()
}
}
}
.background(.ultraThickMaterial)
.background(Color.backgroundHighlight)
.clipShape(RoundedRectangle(cornerRadius: 10))
.padding(.horizontal)
.task {
recipeThumb = await viewModel.loadImage(recipeId: recipe.recipe_id, thumb: true)
self.isDownloaded = viewModel.recipeDetailExists(recipeId: recipe.recipe_id)
}
.refreshable {
recipeThumb = await viewModel.loadImage(recipeId: recipe.recipe_id, thumb: true, needsUpdate: true)