Fix label editing view

This commit is contained in:
Christoph Hagen 2025-05-02 23:15:01 +02:00
parent d0685c163c
commit 4f31622abe

View File

@ -10,7 +10,7 @@ struct LabelCreationView: View {
var body: some View {
List {
ForEach($labels) { label in
ForEach($labels, id: \.icon) { label in
HStack {
Button(action: { remove(label.wrappedValue) }) {
Image(systemSymbol: .minusCircleFill)
@ -32,13 +32,13 @@ struct LabelCreationView: View {
}
private func addLabel() {
var label = ContentLabel(icon: .statisticsTime, value: "Value")
var number = 0
while labels.contains(label) {
number += 1
label.value = "Value \(number)"
for icon in PageIcon.allCases {
if labels.contains(where: { $0.icon == icon }) {
continue
}
labels.append(.init(icon: icon, value: "Value"))
return
}
labels.append(label)
}
private func remove(_ label: ContentLabel) {