Redesign recipe creation and edit view with Form-based layout and URL import
Replace the single "+" button with a 2-option menu (Create New Recipe / Import from URL) across RecipeTabView, RecipeListView, and AllRecipesListView. Add ImportURLSheet for server-side recipe import with loading and error states. Completely redesign edit mode to use a native Form layout with inline editing for all sections (metadata, duration, ingredients, instructions, tools, nutrition) instead of the previous sheet-based EditableListView approach. Move delete action from edit toolbar to view mode context menu. Add recipe image display to the edit form. Refactor RecipeListView and AllRecipesListView to use closure-based callbacks instead of Binding<Bool> for the create/import actions. Add preloadedRecipeDetail support to RecipeView.ViewModel for imported recipes. Add DE/ES/FR translations for all new UI strings. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,10 +63,42 @@ struct RecipeNutritionSection: View {
|
||||
|
||||
func nutritionEmpty() -> Bool {
|
||||
for nutrition in Nutrition.allCases {
|
||||
if let value = viewModel.observableRecipeDetail.nutrition[nutrition.dictKey] {
|
||||
if let _ = viewModel.observableRecipeDetail.nutrition[nutrition.dictKey] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Recipe Edit Nutrition Section (Form-based)
|
||||
|
||||
struct RecipeEditNutritionSection: View {
|
||||
@Binding var nutrition: [String: String]
|
||||
|
||||
@State private var isExpanded: Bool = false
|
||||
|
||||
var body: some View {
|
||||
Section {
|
||||
DisclosureGroup("Nutrition Information", isExpanded: $isExpanded) {
|
||||
ForEach(Nutrition.allCases, id: \.self) { item in
|
||||
HStack {
|
||||
Text(item.localizedDescription)
|
||||
.lineLimit(1)
|
||||
Spacer()
|
||||
TextField("", text: nutritionBinding(for: item.dictKey))
|
||||
.multilineTextAlignment(.trailing)
|
||||
.frame(maxWidth: 150)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func nutritionBinding(for key: String) -> Binding<String> {
|
||||
Binding(
|
||||
get: { nutrition[key, default: ""] },
|
||||
set: { nutrition[key] = $0 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user