Improve content saving, label editing
This commit is contained in:
@ -35,47 +35,15 @@ struct InsertableLabels: View, InsertableCommandView {
|
||||
}
|
||||
}
|
||||
|
||||
@Environment(\.colorScheme)
|
||||
private var colorScheme
|
||||
|
||||
@ObservedObject
|
||||
private var model: Model
|
||||
|
||||
|
||||
|
||||
init(model: Model) {
|
||||
self.model = model
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 2) {
|
||||
ForEach(model.labels, id: \.icon) { label in
|
||||
HStack {
|
||||
Button(action: { remove(label) }) {
|
||||
Image(systemSymbol: .minusCircleFill)
|
||||
.foregroundStyle(.red)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
LabelEditingView(label: label)
|
||||
}
|
||||
.padding(.vertical, 2)
|
||||
.padding(.horizontal, 8)
|
||||
.background(colorScheme == .light ? Color.white : Color.black)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
Button("Add", action: addLabel)
|
||||
.padding(.vertical, 2)
|
||||
}
|
||||
LabelCreationView(labels: $model.labels)
|
||||
}
|
||||
|
||||
private func addLabel() {
|
||||
model.labels.append(.init(icon: .clockFill, value: "Value"))
|
||||
}
|
||||
|
||||
private func remove(_ label: ContentLabel) {
|
||||
guard let index = model.labels.firstIndex(of: label) else {
|
||||
return
|
||||
}
|
||||
model.labels.remove(at: index)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user