Add local port to watch settings
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsNumberInputView: View {
|
||||
struct SettingsNumberInputView<Value>: View where Value: FixedWidthInteger {
|
||||
|
||||
let title: String
|
||||
|
||||
@Binding
|
||||
var value: Int
|
||||
var value: Value
|
||||
|
||||
@State
|
||||
private var text: String = ""
|
||||
@@ -16,7 +16,7 @@ struct SettingsNumberInputView: View {
|
||||
VStack(alignment: .leading) {
|
||||
TextField(title, text: $text)
|
||||
.onSubmit {
|
||||
guard let newValue = Int(text) else {
|
||||
guard let newValue = Value(text) else {
|
||||
return
|
||||
}
|
||||
value = newValue
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsNumberItemLink: View {
|
||||
struct SettingsNumberItemLink<Value>: View where Value: FixedWidthInteger {
|
||||
|
||||
let title: String
|
||||
|
||||
@Binding
|
||||
var value: Int
|
||||
var value: Value
|
||||
|
||||
let footnote: String
|
||||
|
||||
|
@@ -11,6 +11,9 @@ struct SettingsView: View {
|
||||
@AppStorage("localIP")
|
||||
var localAddress: String = "192.168.178.104/"
|
||||
|
||||
@AppStorage("localPort")
|
||||
var localPort: UInt16 = 8888
|
||||
|
||||
@EnvironmentObject
|
||||
var keys: KeyManagement
|
||||
|
||||
@@ -38,17 +41,21 @@ struct SettingsView: View {
|
||||
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: "Some text describing the purpose of the key.")
|
||||
footnote: "The key used by the device for responses")
|
||||
.environmentObject(keys)
|
||||
SettingsKeyItemLink(
|
||||
type: .remoteKey,
|
||||
footnote: "Some text describing the purpose of the key.")
|
||||
footnote: "The key used by the remote for requests.")
|
||||
.environmentObject(keys)
|
||||
SettingsKeyItemLink(
|
||||
type: .authToken,
|
||||
footnote: "Some text describing the purpose of the key.")
|
||||
footnote: "The authentication token of the remote for the server.")
|
||||
.environmentObject(keys)
|
||||
}
|
||||
.navigationTitle("Settings")
|
||||
|
Reference in New Issue
Block a user