ChWebsiteApp/CHDataManagement/Views/Settings/NavigationBarSettingsView.swift
2024-12-04 22:54:05 +01:00

85 lines
2.9 KiB
Swift

import SwiftUI
private struct IconDescriptionView: View {
@ObservedObject
var settings: LocalizedSettings
var body: some View {
TextField("", text: $settings.navigationBarIconDescription)
.textFieldStyle(.roundedBorder)
.frame(maxWidth: 300)
}
}
struct NavigationBarSettingsView: View {
@Environment(\.language)
private var language
@EnvironmentObject
private var content: Content
@State
private var showTagPicker = false
var body: some View {
ScrollView {
VStack(alignment: .leading) {
Text("Notification Bar Settings")
.font(.largeTitle)
.bold()
Text("Customize the navigation bar for all pages at the top of the website")
.padding(.bottom, 30)
Text("Icon Path")
.font(.headline)
TextField("", text: $content.settings.navigationBar.iconPath)
.textFieldStyle(.roundedBorder)
.frame(maxWidth: 300)
Text("Specify the path to the icon file with regard to the final website folder.")
.padding(.bottom, 30)
Text("Icon Description")
.font(.headline)
IconDescriptionView(settings: content.settings.localized(in: language))
Text("Provide a description of the icon for screen readers.")
.padding(.bottom, 30)
Text("Visible Tags")
.font(.headline)
FlowHStack {
ForEach(content.settings.navigationBar.tags, id: \.id) { tag in
TagView(tag: .init(
en: tag.english.name,
de: tag.german.name)
)
.foregroundStyle(.white)
}
Button(action: { showTagPicker = true }) {
Image(systemSymbol: .squareAndPencilCircleFill)
.resizable()
.aspectRatio(1, contentMode: .fit)
.frame(height: 22)
.foregroundColor(Color.gray)
.background(Circle()
.fill(Color.white)
.padding(1))
}
.buttonStyle(.plain)
}
Text("Select the tags to show in the navigation bar. The number should be even.")
}
}
.sheet(isPresented: $showTagPicker) {
TagSelectionView(
presented: $showTagPicker,
selected: $content.settings.navigationBar.tags,
tags: $content.tags)
}
}
}
#Preview {
NavigationBarSettingsView()
.environmentObject(Content.mock)
.padding()
}