Sesame-iOS/Sesame-Watch Watch App/SettingsView.swift
2023-12-12 17:33:42 +01:00

66 lines
2.3 KiB
Swift

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/"
@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.")
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())
}
}