import SwiftUI struct SettingsView: View { @AppStorage("server") var serverPath: String = "https://christophhagen.de/sesame/" @AppStorage("localIP") var localAddress: String = "192.168.178.104/" @AppStorage("counter") var nextMessageCounter: Int = 0 @AppStorage("compensate") var isCompensatingDaylightTime: Bool = false @AppStorage("local") private var useLocalConnection = false @AppStorage("deviceId") private var deviceId: Int = 0 @EnvironmentObject var keys: KeyManagement var body: some View { NavigationStack { List { SettingsTextItemLink( title: "Server url", value: $serverPath, footnote: "The url where the sesame server listens for incoming messages.") SettingsTextItemLink( title: "Local url", value: $localAddress, footnote: "The url where the device can be reached directly on the local WiFi network.") SettingsListToggleItem( title: "Local connection", value: $useLocalConnection, subtitle: "Attempt to communicate directly with the device, which requires a WiFi connection on the same network.") SettingsNumberItemLink( title: "Device ID", value: $deviceId, footnote: "The device ID is unique for each remote device, and is assigned by the system administrator.") SettingsNumberItemLink( title: "Message counter", value: $nextMessageCounter, footnote: "The message counter is increased after every message to the device, and used to prevent replay attacks.") SettingsListToggleItem( title: "Daylight savings", value: $isCompensatingDaylightTime, subtitle: "Compensate timestamps if the remote has daylight savings time wrongly set.") SettingsKeyItemLink( type: .deviceKey, footnote: "Some text describing the purpose of the key.") .environmentObject(keys) SettingsKeyItemLink( type: .remoteKey, footnote: "Some text describing the purpose of the key.") .environmentObject(keys) SettingsKeyItemLink( type: .authToken, footnote: "Some text describing the purpose of the key.") .environmentObject(keys) } .navigationTitle("Settings") } } } struct SettingsView_Previews: PreviewProvider { static var previews: some View { SettingsView() .previewDevice("Apple Watch Series 7 - 41mm") .environmentObject(KeyManagement()) } }