Fix label editing view
This commit is contained in:
parent
d0685c163c
commit
4f31622abe
@ -10,7 +10,7 @@ struct LabelCreationView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
ForEach($labels) { label in
|
ForEach($labels, id: \.icon) { label in
|
||||||
HStack {
|
HStack {
|
||||||
Button(action: { remove(label.wrappedValue) }) {
|
Button(action: { remove(label.wrappedValue) }) {
|
||||||
Image(systemSymbol: .minusCircleFill)
|
Image(systemSymbol: .minusCircleFill)
|
||||||
@ -32,13 +32,13 @@ struct LabelCreationView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func addLabel() {
|
private func addLabel() {
|
||||||
var label = ContentLabel(icon: .statisticsTime, value: "Value")
|
for icon in PageIcon.allCases {
|
||||||
var number = 0
|
if labels.contains(where: { $0.icon == icon }) {
|
||||||
while labels.contains(label) {
|
continue
|
||||||
number += 1
|
}
|
||||||
label.value = "Value \(number)"
|
labels.append(.init(icon: icon, value: "Value"))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
labels.append(label)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func remove(_ label: ContentLabel) {
|
private func remove(_ label: ContentLabel) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user