Improve content saving, label editing

This commit is contained in:
Christoph Hagen
2025-05-02 22:11:43 +02:00
parent fea06a93b7
commit 1f4f32c9af
15 changed files with 274 additions and 150 deletions

View File

@ -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)
}
}