oficina / calendar Public

Clone
git clone https://amadan.net/oficina/calendar

Plain git — no account needed to clone.

Download

Download this file

1import SwiftUI
2
3public struct CalendarSettingsView: View {
4 @AppStorage("calendar.timeZoneOverride") private var override = ""
5 @AppStorage("calendar.showMenuBar") private var showMenuBar = true
6 public init() {}
7 public var body: some View {
8 Form {
9 #if os(macOS)
10 Section { Toggle("Show calendar in menu bar", isOn: $showMenuBar) }
11 #endif
12 Section {
13 Toggle("Use system time zone", isOn: Binding(
14 get: { override.isEmpty },
15 set: { override = $0 ? "" : TimeZone.current.identifier }))
16 if override.isEmpty {
17 LabeledContent("Time zone", value: TimeZone.current.identifier.replacingOccurrences(of: "_", with: " "))
18 } else {
19 Picker("Time zone", selection: $override) {
20 ForEach(Array(Set(TimeZone.knownTimeZoneIdentifiers + ["UTC", TimeZone.current.identifier])).sorted(), id: \.self) { zone in
21 Text(zone.replacingOccurrences(of: "_", with: " ")).tag(zone)
22 }
23 }
24 }
25 } footer: {
26 Text("Used for your agenda, new events and quick-add on this device. Existing events keep their original time zones.")
27 }
28 }.formStyle(.grouped).navigationTitle("Calendar settings")
29 #if os(macOS)
30 .frame(width: 460, height: 300)
31 #endif
32 }
33}
34