2023-04-11 18:18:31 +02:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SettingsView: View {
|
|
|
|
|
2023-08-14 10:39:29 +02:00
|
|
|
let keyManager: KeyManagement
|
2023-04-11 18:18:31 +02:00
|
|
|
|
|
|
|
@Binding
|
|
|
|
var serverAddress: String
|
|
|
|
|
|
|
|
@Binding
|
|
|
|
var localAddress: String
|
2023-08-07 15:47:40 +02:00
|
|
|
|
2023-04-11 18:18:31 +02:00
|
|
|
var body: some View {
|
|
|
|
NavigationView {
|
|
|
|
ScrollView {
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text("Server address")
|
|
|
|
.bold()
|
|
|
|
TextField("Server address", text: $serverAddress)
|
2023-08-07 15:47:40 +02:00
|
|
|
.foregroundColor(.secondary)
|
2023-04-11 18:18:31 +02:00
|
|
|
.padding(.leading, 8)
|
|
|
|
}.padding(.vertical, 8)
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text("Local address")
|
|
|
|
.bold()
|
|
|
|
TextField("Local address", text: $localAddress)
|
2023-08-07 15:47:40 +02:00
|
|
|
.foregroundColor(.secondary)
|
2023-04-11 18:18:31 +02:00
|
|
|
.padding(.leading, 8)
|
|
|
|
}.padding(.vertical, 8)
|
|
|
|
ForEach(KeyManagement.KeyType.allCases) { keyType in
|
|
|
|
SingleKeyView(
|
2023-08-14 10:39:29 +02:00
|
|
|
keyManager: keyManager,
|
2023-04-11 18:18:31 +02:00
|
|
|
type: keyType)
|
|
|
|
}
|
|
|
|
}.padding()
|
|
|
|
}.onDisappear {
|
|
|
|
if !localAddress.hasSuffix("/") {
|
|
|
|
localAddress += "/"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.navigationTitle("Settings")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SettingsView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
SettingsView(
|
2023-08-14 10:39:29 +02:00
|
|
|
keyManager: KeyManagement(),
|
2023-04-11 18:18:31 +02:00
|
|
|
serverAddress: .constant("https://example.com"),
|
2023-12-12 17:33:42 +01:00
|
|
|
localAddress: .constant("192.168.178.42"))
|
2023-04-11 18:18:31 +02:00
|
|
|
}
|
|
|
|
}
|