Add local port to watch settings

This commit is contained in:
Christoph Hagen 2024-05-25 16:08:51 +02:00
parent 91af68a44b
commit 3591842861
5 changed files with 17 additions and 8 deletions

View File

@ -1,11 +1,11 @@
import SwiftUI import SwiftUI
struct SettingsNumberInputView: View { struct SettingsNumberInputView<Value>: View where Value: FixedWidthInteger {
let title: String let title: String
@Binding @Binding
var value: Int var value: Value
@State @State
private var text: String = "" private var text: String = ""
@ -16,7 +16,7 @@ struct SettingsNumberInputView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
TextField(title, text: $text) TextField(title, text: $text)
.onSubmit { .onSubmit {
guard let newValue = Int(text) else { guard let newValue = Value(text) else {
return return
} }
value = newValue value = newValue

View File

@ -1,11 +1,11 @@
import SwiftUI import SwiftUI
struct SettingsNumberItemLink: View { struct SettingsNumberItemLink<Value>: View where Value: FixedWidthInteger {
let title: String let title: String
@Binding @Binding
var value: Int var value: Value
let footnote: String let footnote: String

View File

@ -11,6 +11,9 @@ struct SettingsView: View {
@AppStorage("localIP") @AppStorage("localIP")
var localAddress: String = "192.168.178.104/" var localAddress: String = "192.168.178.104/"
@AppStorage("localPort")
var localPort: UInt16 = 8888
@EnvironmentObject @EnvironmentObject
var keys: KeyManagement var keys: KeyManagement
@ -38,17 +41,21 @@ struct SettingsView: View {
title: "Local url", title: "Local url",
value: $localAddress, value: $localAddress,
footnote: "The url where the device can be reached directly on the local WiFi network.") 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( SettingsKeyItemLink(
type: .deviceKey, type: .deviceKey,
footnote: "Some text describing the purpose of the key.") footnote: "The key used by the device for responses")
.environmentObject(keys) .environmentObject(keys)
SettingsKeyItemLink( SettingsKeyItemLink(
type: .remoteKey, type: .remoteKey,
footnote: "Some text describing the purpose of the key.") footnote: "The key used by the remote for requests.")
.environmentObject(keys) .environmentObject(keys)
SettingsKeyItemLink( SettingsKeyItemLink(
type: .authToken, type: .authToken,
footnote: "Some text describing the purpose of the key.") footnote: "The authentication token of the remote for the server.")
.environmentObject(keys) .environmentObject(keys)
} }
.navigationTitle("Settings") .navigationTitle("Settings")

View File

@ -86,6 +86,7 @@
E24EE77927FF95E00011CFD2 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24EE77827FF95E00011CFD2 /* Message.swift */; }; E24EE77927FF95E00011CFD2 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24EE77827FF95E00011CFD2 /* Message.swift */; };
E24F6C6E2A89749A0040F8C4 /* ConnectionStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24F6C6D2A89749A0040F8C4 /* ConnectionStrategy.swift */; }; E24F6C6E2A89749A0040F8C4 /* ConnectionStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24F6C6D2A89749A0040F8C4 /* ConnectionStrategy.swift */; };
E24F6C6F2A8974C60040F8C4 /* ConnectionStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24F6C6D2A89749A0040F8C4 /* ConnectionStrategy.swift */; }; E24F6C6F2A8974C60040F8C4 /* ConnectionStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24F6C6D2A89749A0040F8C4 /* ConnectionStrategy.swift */; };
E25231782C0227B500FFE373 /* UDPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BA7DD22BD41B8A008F2A3C /* UDPClient.swift */; };
E25317562A8A1ABF005A537D /* HistoryItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E28DED34281EB17600259690 /* HistoryItem.swift */; }; E25317562A8A1ABF005A537D /* HistoryItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E28DED34281EB17600259690 /* HistoryItem.swift */; };
E268E0822A85302000185913 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E268E0532A852F8E00185913 /* WidgetKit.framework */; }; E268E0822A85302000185913 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E268E0532A852F8E00185913 /* WidgetKit.framework */; };
E268E0832A85302000185913 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E268E0552A852F8E00185913 /* SwiftUI.framework */; }; E268E0832A85302000185913 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E268E0552A852F8E00185913 /* SwiftUI.framework */; };
@ -610,6 +611,7 @@
8860D76C2B246F5E00849FAC /* UInt32+Random.swift in Sources */, 8860D76C2B246F5E00849FAC /* UInt32+Random.swift in Sources */,
E240655A2A82218D009C1AD8 /* SettingsKeyInputView.swift in Sources */, E240655A2A82218D009C1AD8 /* SettingsKeyInputView.swift in Sources */,
8860D76F2B246FC400849FAC /* Text+Extensions.swift in Sources */, 8860D76F2B246FC400849FAC /* Text+Extensions.swift in Sources */,
E25231782C0227B500FFE373 /* UDPClient.swift in Sources */,
88E197D229EDCE6600BF1D19 /* SesameRoute.swift in Sources */, 88E197D229EDCE6600BF1D19 /* SesameRoute.swift in Sources */,
8860D75E2B237FC600849FAC /* Message+Size.swift in Sources */, 8860D75E2B237FC600849FAC /* Message+Size.swift in Sources */,
8860D7552B237F9100849FAC /* TransmissionType.swift in Sources */, 8860D7552B237F9100849FAC /* TransmissionType.swift in Sources */,