IceCubesApp/IceCubesApp/App/Tabs/Settings/TagsGroupSettingView.swift

51 lines
1.3 KiB
Swift
Raw Normal View History

import DesignSystem
2024-02-14 11:48:14 +00:00
import Env
import Models
import SwiftData
import SwiftUI
struct TagsGroupSettingView: View {
@Environment(\.modelContext) private var context
2024-02-14 11:48:14 +00:00
@Environment(RouterPath.self) private var routerPath
@Environment(Theme.self) private var theme
2024-02-14 11:48:14 +00:00
@Query(sort: \TagGroup.creationDate, order: .reverse) var tagGroups: [TagGroup]
2024-02-14 11:48:14 +00:00
var body: some View {
Form {
ForEach(tagGroups) { group in
Label(group.title, systemImage: group.symbolName)
.onTapGesture {
routerPath.presentedSheet = .editTagGroup(tagGroup: group, onSaved: nil)
}
}
.onDelete { indexes in
if let index = indexes.first {
context.delete(tagGroups[index])
}
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#endif
Button {
routerPath.presentedSheet = .addTagGroup
} label: {
Label("timeline.filter.add-tag-groups", systemImage: "plus")
}
#if !os(visionOS)
.listRowBackground(theme.primaryBackgroundColor)
#endif
}
.navigationTitle("timeline.filter.tag-groups")
.scrollContentBackground(.hidden)
#if !os(visionOS)
2024-02-14 11:48:14 +00:00
.background(theme.secondaryBackgroundColor)
#endif
2024-02-14 11:48:14 +00:00
.toolbar {
EditButton()
}
}
}