import SwiftUI struct SettingsView: View { @AppStorage("connectionType") var connectionType: ConnectionStrategy = .remoteFirst @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("deviceId") private var deviceId: Int = 0 @EnvironmentObject var keys: KeyManagement var body: some View { NavigationStack { List { Picker("Connection", selection: $connectionType) { Text(ConnectionStrategy.local.rawValue) .tag(ConnectionStrategy.local) Text(ConnectionStrategy.localFirst.rawValue) .tag(ConnectionStrategy.localFirst) Text(ConnectionStrategy.remote.rawValue) .tag(ConnectionStrategy.remote) Text(ConnectionStrategy.remoteFirst.rawValue) .tag(ConnectionStrategy.remoteFirst) } .padding(.leading) 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.") 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()) } }