Sesame-iOS/Sesame-Watch Watch App/SettingsView.swift

85 lines
3.3 KiB
Swift
Raw Normal View History

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/"
@AppStorage("counter")
var nextMessageCounter: Int = 0
@AppStorage("compensate")
var isCompensatingDaylightTime: Bool = false
@AppStorage("deviceId")
private var deviceId: Int = 0
@EnvironmentObject
var keys: KeyManagement
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) {
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)
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.")
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)
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
}
}