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("localPort") var localPort: UInt16 = 8888 @EnvironmentObject var keys: KeyManagement var some: String { "some" } var body: some View { NavigationStack { List { Picker("Connection", selection: $connectionType) { Text(display: ConnectionStrategy.local) .tag(ConnectionStrategy.local) Text(display: ConnectionStrategy.localFirst) .tag(ConnectionStrategy.localFirst) Text(display: ConnectionStrategy.remote) .tag(ConnectionStrategy.remote) Text(display: ConnectionStrategy.remoteFirst) .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: "Local port", value: $localPort, footnote: "The port for the local connection") SettingsKeyItemLink( type: .deviceKey, footnote: "The key used by the device for responses") .environmentObject(keys) SettingsKeyItemLink( type: .remoteKey, footnote: "The key used by the remote for requests.") .environmentObject(keys) SettingsKeyItemLink( type: .authToken, footnote: "The authentication token of the remote for the server.") .environmentObject(keys) } .navigationTitle("Settings") } } } struct SettingsView_Previews: PreviewProvider { static var previews: some View { SettingsView() .previewDevice("Apple Watch Series 7 - 41mm") .environmentObject(KeyManagement()) } }