Recipe edit view polish
This commit is contained in:
@@ -21,13 +21,15 @@ struct RecipeDurationSection: View {
|
||||
DurationView(time: viewModel.observableRecipeDetail.cookTime, title: LocalizedStringKey("Cooking"))
|
||||
DurationView(time: viewModel.observableRecipeDetail.totalTime, title: LocalizedStringKey("Total time"))
|
||||
}
|
||||
Button {
|
||||
presentPopover.toggle()
|
||||
} label: {
|
||||
Text("Edit")
|
||||
if viewModel.editMode {
|
||||
Button {
|
||||
presentPopover.toggle()
|
||||
} label: {
|
||||
Text("Edit")
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.padding(.top, 5)
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.padding(.top, 5)
|
||||
}
|
||||
.padding()
|
||||
.popover(isPresented: $presentPopover) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import SwiftUI
|
||||
|
||||
|
||||
struct RecipeListSection: View {
|
||||
@State var list: [String]
|
||||
@Binding var list: [String]
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
@@ -74,14 +74,17 @@ struct EditableListView: View {
|
||||
List {
|
||||
if items.isEmpty {
|
||||
Text(emptyListText)
|
||||
} else {
|
||||
ForEach(items.indices, id: \.self) { ix in
|
||||
TextField(titleKey, text: $items[ix], axis: axis)
|
||||
.lineLimit(lineLimit)
|
||||
.padding(5)
|
||||
}
|
||||
.onDelete(perform: deleteItem)
|
||||
.onMove(perform: moveItem)
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
|
||||
}
|
||||
|
||||
ForEach(items.indices, id: \.self) { ix in
|
||||
TextField(titleKey, text: $items[ix], axis: axis)
|
||||
.lineLimit(lineLimit)
|
||||
}
|
||||
.onDelete(perform: deleteItem)
|
||||
.onMove(perform: moveItem)
|
||||
}
|
||||
VStack {
|
||||
Spacer()
|
||||
@@ -104,7 +107,7 @@ struct EditableListView: View {
|
||||
Text("Done")
|
||||
}
|
||||
)
|
||||
.environment(\.editMode, .constant(.active)) // Bind edit mode to your state variable
|
||||
.environment(\.editMode, .constant(.active))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ struct RecipeKeywordSection: View {
|
||||
CollapsibleView(titleColor: .secondary, isCollapsed: !UserSettings.shared.expandKeywordSection) {
|
||||
Group {
|
||||
if !viewModel.observableRecipeDetail.keywords.isEmpty && !viewModel.editMode {
|
||||
RecipeListSection(list: viewModel.observableRecipeDetail.keywords)
|
||||
RecipeListSection(list: $viewModel.observableRecipeDetail.keywords)
|
||||
} else {
|
||||
Text(LocalizedStringKey("No keywords."))
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ struct RecipeToolSection: View {
|
||||
Spacer()
|
||||
}
|
||||
|
||||
RecipeListSection(list: viewModel.observableRecipeDetail.tool)
|
||||
RecipeListSection(list: $viewModel.observableRecipeDetail.tool)
|
||||
|
||||
if viewModel.editMode {
|
||||
Button {
|
||||
|
||||
Reference in New Issue
Block a user