108 lines
3.2 KiB
Swift
108 lines
3.2 KiB
Swift
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@State private var viewModel = SettingsViewModel()
|
|
|
|
var body: some View {
|
|
Form {
|
|
Section(header: Text(String(localized: "settings.section.general"))) {
|
|
Picker(String(localized: "settings.language"), selection: $viewModel.language) {
|
|
ForEach(AppLanguage.allCases) { lang in
|
|
Text(lang.displayName).tag(lang)
|
|
}
|
|
}
|
|
|
|
Picker(String(localized: "settings.firstWeekday"), selection: $viewModel.firstWeekday) {
|
|
ForEach(FirstWeekday.allCases) { day in
|
|
Text(day.displayName).tag(day)
|
|
}
|
|
}
|
|
|
|
DatePicker(
|
|
String(localized: "settings.dayStart"),
|
|
selection: $viewModel.dayStartDate,
|
|
displayedComponents: .hourAndMinute
|
|
)
|
|
.tint(Theme.green)
|
|
}
|
|
.listRowBackground(Theme.surface)
|
|
|
|
Section {
|
|
ForEach(PremiumFeature.allCases) { feature in
|
|
PremiumFeatureRow(feature: feature)
|
|
}
|
|
} header: {
|
|
Text(String(localized: "settings.section.premium"))
|
|
} footer: {
|
|
Text(String(localized: "settings.premium.footnote"))
|
|
}
|
|
.listRowBackground(Theme.surface)
|
|
}
|
|
.scrollContentBackground(.hidden)
|
|
.background(Theme.background.ignoresSafeArea())
|
|
.navigationTitle(String(localized: "tab.settings"))
|
|
}
|
|
}
|
|
|
|
// MARK: - Premium Feature
|
|
|
|
private enum PremiumFeature: String, CaseIterable, Identifiable {
|
|
case cloudSync
|
|
case appleWatch
|
|
case ipadMacSync
|
|
case widgets
|
|
case siriShortcuts
|
|
|
|
var id: String { rawValue }
|
|
|
|
var icon: String {
|
|
switch self {
|
|
case .cloudSync: return "icloud.fill"
|
|
case .appleWatch: return "applewatch"
|
|
case .ipadMacSync: return "ipad.and.macbook"
|
|
case .widgets: return "square.grid.2x2.fill"
|
|
case .siriShortcuts: return "mic.fill"
|
|
}
|
|
}
|
|
|
|
var titleKey: String {
|
|
switch self {
|
|
case .cloudSync: return "settings.premium.cloudSync"
|
|
case .appleWatch: return "settings.premium.appleWatch"
|
|
case .ipadMacSync: return "settings.premium.ipadMacSync"
|
|
case .widgets: return "settings.premium.widgets"
|
|
case .siriShortcuts: return "settings.premium.siriShortcuts"
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct PremiumFeatureRow: View {
|
|
let feature: PremiumFeature
|
|
|
|
var body: some View {
|
|
HStack(spacing: 12) {
|
|
Image(systemName: feature.icon)
|
|
.font(.body)
|
|
.foregroundStyle(Theme.primaryText.opacity(0.35))
|
|
.frame(width: 24)
|
|
|
|
Text(String(localized: String.LocalizationValue(feature.titleKey)))
|
|
.font(.body)
|
|
.foregroundStyle(Theme.primaryText.opacity(0.35))
|
|
|
|
Spacer()
|
|
|
|
Image(systemName: "lock.fill")
|
|
.font(.caption)
|
|
.foregroundStyle(Theme.yellow.opacity(0.8))
|
|
}
|
|
.opacity(0.7)
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
NavigationStack {
|
|
SettingsView()
|
|
}
|
|
}
|