Version casi lista

This commit is contained in:
alexandrev-tibco
2026-02-17 13:34:02 +01:00
commit e593453abd
99 changed files with 10867 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import SwiftUI
import SwiftData
@MainActor
final class TagViewModel: ObservableObject {
@Published var editingTag: Tag?
@Published var maxPerWeek: Int? = nil
@Published var noConsecutive: Bool = false
@Published var noDuplicateInDay: Bool = false
@Published var mealTypeRestriction: String? = nil
@Published var useMaxLimit: Bool = true
func loadTag(_ tag: Tag) {
editingTag = tag
maxPerWeek = tag.maxPerWeek
noConsecutive = tag.noConsecutive
noDuplicateInDay = tag.noDuplicateInDay
mealTypeRestriction = tag.mealTypeRestriction
useMaxLimit = tag.maxPerWeek != nil
}
func save() {
guard let tag = editingTag else { return }
tag.maxPerWeek = useMaxLimit ? (maxPerWeek ?? 3) : nil
tag.noConsecutive = noConsecutive
tag.noDuplicateInDay = noDuplicateInDay
tag.mealTypeRestriction = mealTypeRestriction
}
func reset() {
editingTag = nil
}
}