2023-08-07 15:57:09 +02:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SettingsView: View {
|
2023-08-09 16:29:18 +02:00
|
|
|
|
2023-08-14 10:39:29 +02:00
|
|
|
@AppStorage("connectionType")
|
|
|
|
var connectionType: ConnectionStrategy = .remoteFirst
|
|
|
|
|
2023-08-09 16:29:18 +02:00
|
|
|
@AppStorage("server")
|
|
|
|
var serverPath: String = "https://christophhagen.de/sesame/"
|
|
|
|
|
|
|
|
@AppStorage("localIP")
|
|
|
|
var localAddress: String = "192.168.178.104/"
|
|
|
|
|
|
|
|
@EnvironmentObject
|
|
|
|
var keys: KeyManagement
|
2023-12-12 17:33:42 +01:00
|
|
|
|
|
|
|
var some: String { "some" }
|
2023-08-09 16:29:18 +02:00
|
|
|
|
2023-08-07 15:57:09 +02:00
|
|
|
var body: some View {
|
2023-08-09 16:29:18 +02:00
|
|
|
NavigationStack {
|
|
|
|
List {
|
2023-08-14 10:39:29 +02:00
|
|
|
Picker("Connection", selection: $connectionType) {
|
2023-12-12 17:33:42 +01:00
|
|
|
Text(display: ConnectionStrategy.local)
|
2023-08-14 10:39:29 +02:00
|
|
|
.tag(ConnectionStrategy.local)
|
2023-12-12 17:33:42 +01:00
|
|
|
Text(display: ConnectionStrategy.localFirst)
|
2023-08-14 10:39:29 +02:00
|
|
|
.tag(ConnectionStrategy.localFirst)
|
2023-12-12 17:33:42 +01:00
|
|
|
Text(display: ConnectionStrategy.remote)
|
2023-08-14 10:39:29 +02:00
|
|
|
.tag(ConnectionStrategy.remote)
|
2023-12-12 17:33:42 +01:00
|
|
|
Text(display: ConnectionStrategy.remoteFirst)
|
2023-08-14 10:39:29 +02:00
|
|
|
.tag(ConnectionStrategy.remoteFirst)
|
|
|
|
}
|
|
|
|
.padding(.leading)
|
2023-08-09 16:29:18 +02:00
|
|
|
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.")
|
|
|
|
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)
|
2023-08-07 15:57:09 +02:00
|
|
|
}
|
2023-08-09 16:29:18 +02:00
|
|
|
.navigationTitle("Settings")
|
2023-08-07 15:57:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SettingsView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
SettingsView()
|
|
|
|
.previewDevice("Apple Watch Series 7 - 41mm")
|
2023-08-09 16:29:18 +02:00
|
|
|
.environmentObject(KeyManagement())
|
2023-08-07 15:57:09 +02:00
|
|
|
}
|
|
|
|
}
|