mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Update onchange events
This commit is contained in:
parent
3dcec505ff
commit
d7e887dd63
17 changed files with 183 additions and 261 deletions
|
|
@ -72,14 +72,14 @@ struct WaypointFormMapKit: View {
|
|||
axis: .vertical
|
||||
)
|
||||
.foregroundColor(Color.gray)
|
||||
.onChange(of: description, perform: { _ in
|
||||
.onChange(of: description) {
|
||||
var totalBytes = description.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 100 {
|
||||
description = String(description.dropLast())
|
||||
totalBytes = description.utf8.count
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
HStack {
|
||||
Text("Icon")
|
||||
|
|
@ -87,7 +87,7 @@ struct WaypointFormMapKit: View {
|
|||
EmojiOnlyTextField(text: $icon, placeholder: "Select an emoji")
|
||||
.font(.title)
|
||||
.focused($iconIsFocused)
|
||||
.onChange(of: icon) { value in
|
||||
.onChange(of: icon) { _, value in
|
||||
|
||||
// If you have anything other than emojis in your string make it empty
|
||||
if !value.onlyEmojis() {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ struct WaypointForm: View {
|
|||
EmojiOnlyTextField(text: $icon, placeholder: "Select an emoji")
|
||||
.font(.title)
|
||||
.focused($iconIsFocused)
|
||||
.onChange(of: icon) { value in
|
||||
.onChange(of: icon) { _, value in
|
||||
|
||||
// If you have anything other than emojis in your string make it empty
|
||||
if !value.onlyEmojis() {
|
||||
|
|
|
|||
|
|
@ -121,14 +121,14 @@ struct BluetoothConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: enabled) {
|
||||
if $0 != node?.bluetoothConfig?.enabled { hasChanges = true }
|
||||
.onChange(of: enabled) { oldEnabled, newEnabled in
|
||||
if oldEnabled != newEnabled && newEnabled != node?.bluetoothConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: mode) {
|
||||
if $0 != node?.bluetoothConfig?.mode ?? -1 { hasChanges = true }
|
||||
.onChange(of: mode) { oldNode, newNode in
|
||||
if oldNode != newNode && newNode != node?.bluetoothConfig?.mode ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: fixedPin) { newFixedPin in
|
||||
if newFixedPin != String(node?.bluetoothConfig?.fixedPin ?? -1) { hasChanges = true }
|
||||
.onChange(of: fixedPin) { oldFixedPin, newFixedPin in
|
||||
if oldFixedPin != newFixedPin && newFixedPin != String(node?.bluetoothConfig?.fixedPin ?? -1) { hasChanges = true }
|
||||
}
|
||||
}
|
||||
func setBluetoothValues() {
|
||||
|
|
|
|||
|
|
@ -261,22 +261,20 @@ struct DeviceConfig: View {
|
|||
.onChange(of: rebroadcastMode) { oldRebroadcastMode, newRebroadcastMode in
|
||||
if oldRebroadcastMode != newRebroadcastMode && newRebroadcastMode != node?.deviceConfig?.rebroadcastMode ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: nodeInfoBroadcastSecs) { newNodeInfoBroadcastSecs in
|
||||
if newNodeInfoBroadcastSecs != node?.deviceConfig?.nodeInfoBroadcastSecs ?? -1 { hasChanges = true }
|
||||
.onChange(of: nodeInfoBroadcastSecs) { oldNodeInfoBroadcastSecs, newNodeInfoBroadcastSecs in
|
||||
if oldNodeInfoBroadcastSecs != newNodeInfoBroadcastSecs && newNodeInfoBroadcastSecs != node?.deviceConfig?.nodeInfoBroadcastSecs ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: doubleTapAsButtonPress) {
|
||||
if $0 != node?.deviceConfig?.doubleTapAsButtonPress { hasChanges = true }
|
||||
.onChange(of: doubleTapAsButtonPress) { oldDoubleTapAsButtonPress, newDoubleTapAsButtonPress in
|
||||
if oldDoubleTapAsButtonPress != newDoubleTapAsButtonPress && newDoubleTapAsButtonPress != node?.deviceConfig?.doubleTapAsButtonPress ?? false { hasChanges = true }
|
||||
}
|
||||
.onChange(of: tripleClickAsAdHocPing) {
|
||||
if $0 != node?.deviceConfig?.tripleClickAsAdHocPing { hasChanges = true }
|
||||
.onChange(of: tripleClickAsAdHocPing) { oldTripleClickAsAdHocPing, newTripleClickAsAdHocPing in
|
||||
if oldTripleClickAsAdHocPing != newTripleClickAsAdHocPing && newTripleClickAsAdHocPing != node?.deviceConfig?.tripleClickAsAdHocPing ?? false { hasChanges = true }
|
||||
}
|
||||
.onChange(of: tzdef) { newTzdef in
|
||||
if newTzdef != node?.deviceConfig?.tzdef { hasChanges = true }
|
||||
.onChange(of: tzdef) { oldTzdef, newTzdef in
|
||||
if oldTzdef != newTzdef && newTzdef != node?.deviceConfig?.tzdef { hasChanges = true }
|
||||
}
|
||||
.onChange(of: ledHeartbeatEnabled) { newLedHeartbeatEnabled in
|
||||
if node != nil && node?.deviceConfig != nil {
|
||||
if newLedHeartbeatEnabled != node!.deviceConfig!.ledHeartbeatEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: ledHeartbeatEnabled) { oldLedHeartbeatEnabled, newLedHeartbeatEnabled in
|
||||
if oldLedHeartbeatEnabled != newLedHeartbeatEnabled && newLedHeartbeatEnabled != node?.deviceConfig?.ledHeartbeatEnabled ?? false { hasChanges = true }
|
||||
}
|
||||
}
|
||||
func setDeviceValues() {
|
||||
|
|
|
|||
|
|
@ -184,32 +184,32 @@ struct DisplayConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: screenOnSeconds) { newScreenSecs in
|
||||
if newScreenSecs != node?.displayConfig?.screenOnSeconds ?? -1 { hasChanges = true }
|
||||
.onChange(of: screenOnSeconds) { oldScreenSecs, newScreenSecs in
|
||||
if oldScreenSecs != newScreenSecs && newScreenSecs != node?.displayConfig?.screenOnSeconds ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: screenCarouselInterval) { newCarouselSecs in
|
||||
if newCarouselSecs != node?.displayConfig?.screenCarouselInterval ?? -1 { hasChanges = true }
|
||||
.onChange(of: screenCarouselInterval) { oldCarouselSecs, newCarouselSecs in
|
||||
if oldCarouselSecs != newCarouselSecs && newCarouselSecs != node?.displayConfig?.screenCarouselInterval ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: compassNorthTop) {
|
||||
if $0 != node?.displayConfig?.compassNorthTop { hasChanges = true }
|
||||
.onChange(of: compassNorthTop) { oldCompassNorthTop, newCompassNorthTop in
|
||||
if oldCompassNorthTop != newCompassNorthTop && newCompassNorthTop != node?.displayConfig?.compassNorthTop { hasChanges = true }
|
||||
}
|
||||
.onChange(of: wakeOnTapOrMotion) {
|
||||
if $0 != node?.displayConfig?.wakeOnTapOrMotion { hasChanges = true }
|
||||
.onChange(of: wakeOnTapOrMotion) { oldWakeOnTapOrMotion, newWakeOnTapOrMotion in
|
||||
if oldWakeOnTapOrMotion != newWakeOnTapOrMotion && newWakeOnTapOrMotion != node?.displayConfig?.wakeOnTapOrMotion { hasChanges = true }
|
||||
}
|
||||
.onChange(of: gpsFormat) { newGpsFormat in
|
||||
if newGpsFormat != node?.displayConfig?.gpsFormat ?? -1 { hasChanges = true }
|
||||
.onChange(of: gpsFormat) { oldGpsFormat, newGpsFormat in
|
||||
if oldGpsFormat != newGpsFormat && newGpsFormat != node?.displayConfig?.gpsFormat ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: flipScreen) {
|
||||
if $0 != node?.displayConfig?.flipScreen { hasChanges = true }
|
||||
.onChange(of: flipScreen) { oldFlipScreen, newFlipScreen in
|
||||
if oldFlipScreen != newFlipScreen && newFlipScreen != node?.displayConfig?.flipScreen { hasChanges = true }
|
||||
}
|
||||
.onChange(of: oledType) { newOledType in
|
||||
if newOledType != node?.displayConfig?.oledType ?? -1 { hasChanges = true }
|
||||
.onChange(of: oledType) { oldOledType, newOledType in
|
||||
if oldOledType != newOledType && newOledType != node?.displayConfig?.oledType ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: displayMode) { newDisplayMode in
|
||||
if newDisplayMode != node?.displayConfig?.displayMode ?? -1 { hasChanges = true }
|
||||
.onChange(of: displayMode) { oldDisplayMode, newDisplayMode in
|
||||
if oldDisplayMode != newDisplayMode && newDisplayMode != node?.displayConfig?.displayMode ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: units) { newUnits in
|
||||
if newUnits != node?.displayConfig?.units ?? -1 { hasChanges = true }
|
||||
.onChange(of: units) { oldUnits, newUnits in
|
||||
if oldUnits != newUnits && newUnits != node?.displayConfig?.units ?? -1 { hasChanges = true }
|
||||
}
|
||||
}
|
||||
func setDisplayValues() {
|
||||
|
|
|
|||
|
|
@ -259,47 +259,47 @@ struct LoRaConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: region) { newRegion in
|
||||
.onChange(of: region) { _, newRegion in
|
||||
if newRegion != node?.loRaConfig?.regionCode ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: usePreset) {
|
||||
if $0 != node?.loRaConfig?.usePreset { hasChanges = true }
|
||||
.onChange(of: usePreset) { _, newPreset in
|
||||
if newPreset != node?.loRaConfig?.usePreset { hasChanges = true }
|
||||
}
|
||||
.onChange(of: modemPreset) { newModemPreset in
|
||||
.onChange(of: modemPreset) { _, newModemPreset in
|
||||
if newModemPreset != node?.loRaConfig?.modemPreset ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: hopLimit) { newHopLimit in
|
||||
.onChange(of: hopLimit) { _, newHopLimit in
|
||||
if newHopLimit != node?.loRaConfig?.hopLimit ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: channelNum) { newChannelNum in
|
||||
.onChange(of: channelNum) { _, newChannelNum in
|
||||
if newChannelNum != node?.loRaConfig?.channelNum ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: bandwidth) { newBandwidth in
|
||||
.onChange(of: bandwidth) { _, newBandwidth in
|
||||
if newBandwidth != node?.loRaConfig?.bandwidth ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: codingRate) { newCodingRate in
|
||||
.onChange(of: codingRate) { _, newCodingRate in
|
||||
if newCodingRate != node?.loRaConfig?.codingRate ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: spreadFactor) { newSpreadFactor in
|
||||
.onChange(of: spreadFactor) { _, newSpreadFactor in
|
||||
if newSpreadFactor != node?.loRaConfig?.spreadFactor ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: rxBoostedGain) {
|
||||
if $0 != node?.loRaConfig?.sx126xRxBoostedGain { hasChanges = true }
|
||||
.onChange(of: rxBoostedGain) { _, newRxBoostedGain in
|
||||
if newRxBoostedGain != node?.loRaConfig?.sx126xRxBoostedGain { hasChanges = true }
|
||||
}
|
||||
.onChange(of: overrideFrequency) { newOverrideFrequency in
|
||||
.onChange(of: overrideFrequency) { _, newOverrideFrequency in
|
||||
if newOverrideFrequency != node?.loRaConfig?.overrideFrequency { hasChanges = true }
|
||||
}
|
||||
.onChange(of: txPower) { newTxPower in
|
||||
.onChange(of: txPower) { _, newTxPower in
|
||||
if newTxPower != node?.loRaConfig?.txPower ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: txEnabled) {
|
||||
if $0 != node?.loRaConfig?.txEnabled { hasChanges = true }
|
||||
.onChange(of: txEnabled) { _, newTxEnabled in
|
||||
if newTxEnabled != node?.loRaConfig?.txEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: ignoreMqtt) {
|
||||
if $0 != node?.loRaConfig?.ignoreMqtt { hasChanges = true }
|
||||
.onChange(of: ignoreMqtt) { _, newIgnoreMqtt in
|
||||
if newIgnoreMqtt != node?.loRaConfig?.ignoreMqtt { hasChanges = true }
|
||||
}
|
||||
.onChange(of: okToMqtt) {
|
||||
if $0 != node?.loRaConfig?.okToMqtt { hasChanges = true }
|
||||
.onChange(of: okToMqtt) { _, newOkToMqtt in
|
||||
if newOkToMqtt != node?.loRaConfig?.okToMqtt { hasChanges = true }
|
||||
}
|
||||
}
|
||||
func setLoRaValues() {
|
||||
|
|
|
|||
|
|
@ -106,20 +106,14 @@ struct AmbientLightingConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: ledState) {
|
||||
if let val = node?.ambientLightingConfig?.ledState {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: ledState) { _, newLedState in
|
||||
if newLedState != node?.ambientLightingConfig?.ledState { hasChanges = true }
|
||||
}
|
||||
.onChange(of: current) {
|
||||
if let val = node?.ambientLightingConfig?.current {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: current) { _, newCurrent in
|
||||
if newCurrent != node?.ambientLightingConfig?.current ?? 10 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: color) { c in
|
||||
if color != c {
|
||||
hasChanges = true
|
||||
}
|
||||
.onChange(of: color) { oldColor, newColor in
|
||||
if oldColor != newColor { hasChanges = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -283,55 +283,35 @@ struct CannedMessagesConfig: View {
|
|||
|
||||
hasChanges = true
|
||||
}
|
||||
.onChange(of: enabled) {
|
||||
if let val = node?.cannedMessageConfig?.enabled {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: enabled) { _, newEnabled in
|
||||
if newEnabled != node?.cannedMessageConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: sendBell) {
|
||||
if let val = node?.cannedMessageConfig?.sendBell {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: sendBell) { _, newSendBell in
|
||||
if newSendBell != node?.cannedMessageConfig?.sendBell { hasChanges = true }
|
||||
}
|
||||
.onChange(of: rotary1Enabled) {
|
||||
if let val = node?.cannedMessageConfig?.rotary1Enabled {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: rotary1Enabled) { _, newRotary1Enabled in
|
||||
if newRotary1Enabled != node?.cannedMessageConfig?.rotary1Enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: updown1Enabled) {
|
||||
if let val = node?.cannedMessageConfig?.updown1Enabled {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: updown1Enabled) { _, newUpdown1Enabled in
|
||||
if newUpdown1Enabled != node?.cannedMessageConfig?.updown1Enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerPinA) { newPinA in
|
||||
if node != nil && node!.cannedMessageConfig != nil {
|
||||
if newPinA != node!.cannedMessageConfig!.inputbrokerPinA { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerPinA) { _, newPinA in
|
||||
if newPinA != node?.cannedMessageConfig?.inputbrokerPinA ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerPinB) { newPinB in
|
||||
if node != nil && node!.cannedMessageConfig != nil {
|
||||
if newPinB != node!.cannedMessageConfig!.inputbrokerPinB { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerPinB) { _, newPinB in
|
||||
if newPinB != node?.cannedMessageConfig?.inputbrokerPinB ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerPinPress) { newPinPress in
|
||||
if node != nil && node!.cannedMessageConfig != nil {
|
||||
if newPinPress != node!.cannedMessageConfig!.inputbrokerPinPress { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerPinPress) { _, newPinPress in
|
||||
if newPinPress != node?.cannedMessageConfig?.inputbrokerPinPress ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerEventCw) { newKeyA in
|
||||
if node != nil && node!.cannedMessageConfig != nil {
|
||||
if newKeyA != node!.cannedMessageConfig!.inputbrokerEventCw { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerEventCw) { _, newKeyA in
|
||||
if newKeyA != node?.cannedMessageConfig?.inputbrokerEventCw ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerEventCcw) { newKeyB in
|
||||
if node != nil && node!.cannedMessageConfig != nil {
|
||||
if newKeyB != node!.cannedMessageConfig!.inputbrokerEventCcw { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerEventCcw) { _, newKeyB in
|
||||
if newKeyB != node?.cannedMessageConfig?.inputbrokerEventCcw ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerEventPress) { newKeyPress in
|
||||
if node != nil && node!.cannedMessageConfig != nil {
|
||||
if newKeyPress != node!.cannedMessageConfig!.inputbrokerEventPress { hasChanges = true }
|
||||
}
|
||||
.onChange(of: inputbrokerEventPress) { _, newKeyPress in
|
||||
if newKeyPress != node?.cannedMessageConfig?.inputbrokerEventPress ?? -1 { hasChanges = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,14 +91,14 @@ struct DetectionSensorConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: name, perform: { _ in
|
||||
.onChange(of: name) {
|
||||
var totalBytes = name.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 20 {
|
||||
name = String(name.dropLast())
|
||||
totalBytes = name.utf8.count
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
Text("Friendly name used to format message sent to mesh. Example: A name \"Motion\" would result in a message \"Motion detected\"")
|
||||
|
|
@ -210,47 +210,31 @@ struct DetectionSensorConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: enabled) {
|
||||
if let val = node?.detectionSensorConfig?.enabled {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: enabled) { _, newEnabled in
|
||||
if newEnabled != node?.detectionSensorConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: sendBell) {
|
||||
if let val = node?.detectionSensorConfig?.sendBell {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: sendBell) { _, newSendBell in
|
||||
if newSendBell != node?.detectionSensorConfig?.sendBell { hasChanges = true }
|
||||
}
|
||||
.onChange(of: detectionTriggeredHigh) { newDetectionTriggeredHigh in
|
||||
if node != nil && node?.detectionSensorConfig != nil {
|
||||
if newDetectionTriggeredHigh != node!.detectionSensorConfig!.detectionTriggeredHigh { hasChanges = true }
|
||||
}
|
||||
.onChange(of: detectionTriggeredHigh) { _, newDetectionTriggeredHigh in
|
||||
if newDetectionTriggeredHigh != node?.detectionSensorConfig?.detectionTriggeredHigh { hasChanges = true }
|
||||
}
|
||||
.onChange(of: usePullup) {
|
||||
if let val = node?.detectionSensorConfig?.usePullup {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: usePullup) { _, newUsePullup in
|
||||
if newUsePullup != node?.detectionSensorConfig?.usePullup { hasChanges = true }
|
||||
}
|
||||
.onChange(of: name) { newName in
|
||||
if node != nil && node?.detectionSensorConfig != nil {
|
||||
if newName != node!.detectionSensorConfig!.name { hasChanges = true }
|
||||
}
|
||||
.onChange(of: name) { _, newName in
|
||||
if newName != node?.detectionSensorConfig?.name ?? "" { hasChanges = true }
|
||||
}
|
||||
.onChange(of: monitorPin) { newMonitorPin in
|
||||
if node != nil && node?.detectionSensorConfig != nil {
|
||||
if newMonitorPin != node!.detectionSensorConfig!.monitorPin { hasChanges = true }
|
||||
}
|
||||
.onChange(of: monitorPin) { _, newMonitorPin in
|
||||
if newMonitorPin != node?.detectionSensorConfig?.monitorPin ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: minimumBroadcastSecs) { newMinimumBroadcastSecs in
|
||||
if node != nil && node?.detectionSensorConfig != nil {
|
||||
if newMinimumBroadcastSecs != node!.detectionSensorConfig!.minimumBroadcastSecs { hasChanges = true }
|
||||
}
|
||||
.onChange(of: minimumBroadcastSecs) { _, newMinimumBroadcastSecs in
|
||||
if newMinimumBroadcastSecs != node?.detectionSensorConfig?.minimumBroadcastSecs ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: stateBroadcastSecs) { newStateBroadcastSecs in
|
||||
if node != nil && node?.detectionSensorConfig != nil {
|
||||
if newStateBroadcastSecs != node!.detectionSensorConfig!.stateBroadcastSecs { hasChanges = true }
|
||||
}
|
||||
.onChange(of: stateBroadcastSecs) { _, newStateBroadcastSecs in
|
||||
if newStateBroadcastSecs != node?.detectionSensorConfig?.stateBroadcastSecs ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: detectionNotificationsEnabled) { newDetectionNotificationsEnabled in
|
||||
.onChange(of: detectionNotificationsEnabled) { _, newDetectionNotificationsEnabled in
|
||||
UserDefaults.enableDetectionNotifications = newDetectionNotificationsEnabled
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,80 +220,50 @@ struct ExternalNotificationConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: enabled) {
|
||||
if let val = node?.externalNotificationConfig?.enabled {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: enabled) { _, newEnabled in
|
||||
if newEnabled != node?.externalNotificationConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: alertBell) {
|
||||
if let val = node?.externalNotificationConfig?.alertBell {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: alertBell) { _, newAlertBell in
|
||||
if newAlertBell != node?.externalNotificationConfig?.alertBell { hasChanges = true }
|
||||
}
|
||||
.onChange(of: alertBellBuzzer) {
|
||||
if let val = node?.externalNotificationConfig?.alertBellBuzzer {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: alertBellBuzzer) { _, newAlertBellBuzzer in
|
||||
if newAlertBellBuzzer != node?.externalNotificationConfig?.alertBellBuzzer { hasChanges = true }
|
||||
}
|
||||
.onChange(of: alertBellVibra) {
|
||||
if let val = node?.externalNotificationConfig?.alertBellVibra {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: alertBellVibra) { _, newAlertBellVibra in
|
||||
if newAlertBellVibra != node?.externalNotificationConfig?.alertBellVibra { hasChanges = true }
|
||||
}
|
||||
.onChange(of: alertMessage) {
|
||||
if let val = node?.externalNotificationConfig?.alertMessage {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: alertMessage) { _, newAlertMessage in
|
||||
if newAlertMessage != node?.externalNotificationConfig?.alertMessage { hasChanges = true }
|
||||
}
|
||||
.onChange(of: alertMessageBuzzer) {
|
||||
if let val = node?.externalNotificationConfig?.alertMessageBuzzer {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: alertMessageBuzzer) { _, newAlertMessageBuzzer in
|
||||
if newAlertMessageBuzzer != node?.externalNotificationConfig?.alertMessageBuzzer { hasChanges = true }
|
||||
}
|
||||
.onChange(of: alertMessageVibra) {
|
||||
if let val = node?.externalNotificationConfig?.alertMessageVibra {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: alertMessageVibra) { _, newAlertMessageVibra in
|
||||
if newAlertMessageVibra != node?.externalNotificationConfig?.alertMessageVibra { hasChanges = true }
|
||||
}
|
||||
.onChange(of: active) {
|
||||
if let val = node?.externalNotificationConfig?.active {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: active) { _, newActive in
|
||||
if newActive != node?.externalNotificationConfig?.active { hasChanges = true }
|
||||
}
|
||||
.onChange(of: output) { newOutput in
|
||||
if node != nil && node!.externalNotificationConfig != nil {
|
||||
if newOutput != node!.externalNotificationConfig!.output { hasChanges = true }
|
||||
}
|
||||
.onChange(of: output) { _, newOutput in
|
||||
if newOutput != node?.externalNotificationConfig?.output ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: output) { newOutputBuzzer in
|
||||
if node != nil && node!.externalNotificationConfig != nil {
|
||||
if newOutputBuzzer != node!.externalNotificationConfig!.outputBuzzer { hasChanges = true }
|
||||
}
|
||||
.onChange(of: output) { _, newOutputBuzzer in
|
||||
if newOutputBuzzer != node?.externalNotificationConfig?.outputBuzzer ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: output) { newOutputVibra in
|
||||
if node != nil && node!.externalNotificationConfig != nil {
|
||||
if newOutputVibra != node!.externalNotificationConfig!.outputVibra { hasChanges = true }
|
||||
}
|
||||
.onChange(of: output) { _, newOutputVibra in
|
||||
if newOutputVibra != node?.externalNotificationConfig?.outputVibra ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: outputMilliseconds) { newOutputMs in
|
||||
if node != nil && node!.externalNotificationConfig != nil {
|
||||
if newOutputMs != node!.externalNotificationConfig!.outputMilliseconds { hasChanges = true }
|
||||
}
|
||||
.onChange(of: outputMilliseconds) { _, newOutputMs in
|
||||
if newOutputMs != node?.externalNotificationConfig?.outputMilliseconds ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: usePWM) {
|
||||
if let val = node?.externalNotificationConfig?.usePWM {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: usePWM) { _, newPWM in
|
||||
if newPWM != node?.externalNotificationConfig?.usePWM { hasChanges = true }
|
||||
}
|
||||
.onChange(of: nagTimeout) { newNagTimeout in
|
||||
if node != nil && node!.externalNotificationConfig != nil {
|
||||
if newNagTimeout != node!.externalNotificationConfig!.nagTimeout { hasChanges = true }
|
||||
}
|
||||
.onChange(of: nagTimeout) { _, newNagTimeout in
|
||||
if newNagTimeout != node?.externalNotificationConfig?.nagTimeout ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: useI2SAsBuzzer) {
|
||||
if let val = node?.externalNotificationConfig?.useI2SAsBuzzer {
|
||||
hasChanges = $0 != val
|
||||
}
|
||||
.onChange(of: useI2SAsBuzzer) { _, newUseI2SAsBuzzer in
|
||||
if newUseI2SAsBuzzer != node?.externalNotificationConfig?.useI2SAsBuzzer { hasChanges = true }
|
||||
}
|
||||
}
|
||||
func setExternalNotificationValues() {
|
||||
|
|
|
|||
|
|
@ -262,24 +262,20 @@ struct MQTTConfig: View {
|
|||
)
|
||||
}
|
||||
)
|
||||
.onChange(of: enabled) {
|
||||
if $0 != node?.mqttConfig?.enabled { hasChanges = true }
|
||||
.onChange(of: enabled) { _, newEnabled in
|
||||
if newEnabled != node?.mqttConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: proxyToClientEnabled) { newProxyToClientEnabled in
|
||||
.onChange(of: proxyToClientEnabled) { _, newProxyToClientEnabled in
|
||||
if newProxyToClientEnabled {
|
||||
jsonEnabled = false
|
||||
}
|
||||
if newProxyToClientEnabled != node?.mqttConfig?.proxyToClientEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: address) { newAddress in
|
||||
if node != nil && node?.mqttConfig != nil {
|
||||
if newAddress != node!.mqttConfig!.address { hasChanges = true }
|
||||
}
|
||||
.onChange(of: address) { _, newAddress in
|
||||
if newAddress != node?.mqttConfig?.address ?? "" { hasChanges = true }
|
||||
}
|
||||
.onChange(of: username) { newUsername in
|
||||
if node != nil && node?.mqttConfig != nil {
|
||||
if newUsername != node!.mqttConfig!.username { hasChanges = true }
|
||||
}
|
||||
if newUsername != node?.mqttConfig?.username ?? "" { hasChanges = true }
|
||||
}
|
||||
.onChange(of: password) { newPassword in
|
||||
if node != nil && node?.mqttConfig != nil {
|
||||
|
|
@ -291,26 +287,26 @@ struct MQTTConfig: View {
|
|||
if newRoot != node!.mqttConfig!.root { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: selectedTopic) { newSelectedTopic in
|
||||
.onChange(of: selectedTopic) { _, newSelectedTopic in
|
||||
root = newSelectedTopic
|
||||
}
|
||||
.onChange(of: encryptionEnabled) {
|
||||
if $0 != node?.mqttConfig?.encryptionEnabled { hasChanges = true }
|
||||
.onChange(of: encryptionEnabled) { _, newEncryptionEnabled in
|
||||
if newEncryptionEnabled != node?.mqttConfig?.encryptionEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: jsonEnabled) { newJsonEnabled in
|
||||
.onChange(of: jsonEnabled) { _, newJsonEnabled in
|
||||
if newJsonEnabled {
|
||||
proxyToClientEnabled = false
|
||||
}
|
||||
if newJsonEnabled != node?.mqttConfig?.jsonEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: tlsEnabled) { newTlsEnabled in
|
||||
.onChange(of: tlsEnabled) { _, newTlsEnabled in
|
||||
if address.lowercased() == "mqtt.meshtastic.org" {
|
||||
tlsEnabled = false
|
||||
} else {
|
||||
if newTlsEnabled != node?.mqttConfig?.tlsEnabled { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: mqttConnected) { newMqttConnected in
|
||||
.onChange(of: mqttConnected) { _, newMqttConnected in
|
||||
if newMqttConnected == false {
|
||||
if bleManager.mqttProxyConnected {
|
||||
bleManager.mqttManager.disconnect()
|
||||
|
|
@ -321,8 +317,8 @@ struct MQTTConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: mapReportingEnabled) {
|
||||
if $0 != node?.mqttConfig?.mapReportingEnabled { hasChanges = true }
|
||||
.onChange(of: mapReportingEnabled) { _, newMapReportingEnabled in
|
||||
if newMapReportingEnabled != node?.mqttConfig?.mapReportingEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: mapPublishIntervalSecs) { newMapPublishIntervalSecs in
|
||||
if node != nil && node?.mqttConfig != nil {
|
||||
|
|
|
|||
|
|
@ -102,14 +102,14 @@ struct RangeTestConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: enabled) {
|
||||
if $0 != node?.rangeTestConfig?.enabled { hasChanges = true }
|
||||
.onChange(of: enabled) { _, newEnabled in
|
||||
if newEnabled != node?.rangeTestConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: save) {
|
||||
if $0 != node?.rangeTestConfig?.save { hasChanges = true }
|
||||
.onChange(of: save) { _, newSave in
|
||||
if newSave != node?.rangeTestConfig?.save { hasChanges = true }
|
||||
}
|
||||
.onChange(of: sender) {
|
||||
if $0 != node?.rangeTestConfig?.sender ?? -1 { hasChanges = true }
|
||||
.onChange(of: sender) { _, newSender in
|
||||
if newSender != node?.rangeTestConfig?.sender ?? -1 { hasChanges = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ struct RtttlConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: ringtone, perform: { _ in
|
||||
.onChange(of: ringtone) {
|
||||
var totalBytes = ringtone.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 228 {
|
||||
ringtone = String(ringtone.dropLast())
|
||||
totalBytes = ringtone.utf8.count
|
||||
}
|
||||
})
|
||||
}
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.keyboardType(.default)
|
||||
|
|
@ -93,7 +93,7 @@ struct RtttlConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: ringtone) { newRingtone in
|
||||
.onChange(of: ringtone) { _, newRingtone in
|
||||
if node != nil && node!.rtttlConfig != nil {
|
||||
if newRingtone != node!.rtttlConfig!.ringtone { hasChanges = true }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ struct NetworkConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: wifiEnabled) {
|
||||
if $0 != node?.networkConfig?.wifiEnabled { hasChanges = true }
|
||||
.onChange(of: wifiEnabled) { _, newEnabled in
|
||||
if newEnabled != node?.networkConfig?.wifiEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: wifiSsid) { _, newSSID in
|
||||
if newSSID != node?.networkConfig?.wifiSsid { hasChanges = true }
|
||||
|
|
@ -160,11 +160,11 @@ struct NetworkConfig: View {
|
|||
.onChange(of: wifiPsk) { _, newPsk in
|
||||
if newPsk != node?.networkConfig?.wifiPsk { hasChanges = true }
|
||||
}
|
||||
.onChange(of: wifiMode) {
|
||||
if $0 != node?.networkConfig?.wifiMode ?? -1 { hasChanges = true }
|
||||
.onChange(of: wifiMode) { _, newMode in
|
||||
if newMode != node?.networkConfig?.wifiMode ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: ethEnabled) {
|
||||
if $0 != node?.networkConfig?.ethEnabled { hasChanges = true }
|
||||
.onChange(of: ethEnabled) { _, newEthEnabled in
|
||||
if newEthEnabled != node?.networkConfig?.ethEnabled { hasChanges = true }
|
||||
}
|
||||
}
|
||||
func setNetworkValues() {
|
||||
|
|
|
|||
|
|
@ -411,37 +411,37 @@ struct PositionConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: gpsMode) { newGpsMode in
|
||||
.onChange(of: gpsMode) { _, newGpsMode in
|
||||
if newGpsMode != node?.positionConfig?.gpsMode ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: rxGpio) { newRxGpio in
|
||||
.onChange(of: rxGpio) { _, newRxGpio in
|
||||
if newRxGpio != node?.positionConfig?.rxGpio ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: txGpio) { newTxGpio in
|
||||
.onChange(of: txGpio) { _, newTxGpio in
|
||||
if newTxGpio != node?.positionConfig?.txGpio ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: gpsEnGpio) { newGpsEnGpio in
|
||||
.onChange(of: gpsEnGpio) { _, newGpsEnGpio in
|
||||
if newGpsEnGpio != node?.positionConfig?.gpsEnGpio ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: smartPositionEnabled) { newSmartPositionEnabled in
|
||||
.onChange(of: smartPositionEnabled) { _, newSmartPositionEnabled in
|
||||
if newSmartPositionEnabled != node?.positionConfig?.smartPositionEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: positionBroadcastSeconds) { newPositionBroadcastSeconds in
|
||||
.onChange(of: positionBroadcastSeconds) { _, newPositionBroadcastSeconds in
|
||||
if newPositionBroadcastSeconds != node?.positionConfig?.positionBroadcastSeconds ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: broadcastSmartMinimumIntervalSecs) { newBroadcastSmartMinimumIntervalSecs in
|
||||
.onChange(of: broadcastSmartMinimumIntervalSecs) { _, newBroadcastSmartMinimumIntervalSecs in
|
||||
if newBroadcastSmartMinimumIntervalSecs != node?.positionConfig?.broadcastSmartMinimumIntervalSecs ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: broadcastSmartMinimumDistance) { newBroadcastSmartMinimumDistance in
|
||||
.onChange(of: broadcastSmartMinimumDistance) { _, newBroadcastSmartMinimumDistance in
|
||||
if newBroadcastSmartMinimumDistance != node?.positionConfig?.broadcastSmartMinimumDistance ?? 0 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: gpsUpdateInterval) { newGpsUpdateInterval in
|
||||
.onChange(of: gpsUpdateInterval) { _, newGpsUpdateInterval in
|
||||
if newGpsUpdateInterval != node?.positionConfig?.gpsUpdateInterval ?? 0 { hasChanges = true }
|
||||
}
|
||||
}
|
||||
|
||||
func handlePositionFlagtChanges() {
|
||||
guard let positionConfig = node?.positionConfig else { return }
|
||||
guard (node?.positionConfig) != nil else { return }
|
||||
let pf = PositionFlags(rawValue: self.positionFlags)
|
||||
hasChanges =
|
||||
pf.contains(.Altitude) ||
|
||||
|
|
|
|||
|
|
@ -168,11 +168,11 @@ struct PowerConfig: View {
|
|||
.onChange(of: waitBluetoothSecs) { oldWaitBluetoothSecs, newWaitBluetoothSecs in
|
||||
if oldWaitBluetoothSecs != newWaitBluetoothSecs && newWaitBluetoothSecs != node?.powerConfig?.waitBluetoothSecs ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: lsSecs) {
|
||||
if $0 != node?.powerConfig?.lsSecs ?? -1 { hasChanges = true }
|
||||
.onChange(of: lsSecs) { _, newLsSecs in
|
||||
if newLsSecs != node?.powerConfig?.lsSecs ?? -1 { hasChanges = true }
|
||||
}
|
||||
.onChange(of: minWakeSecs) {
|
||||
if $0 != node?.powerConfig?.minWakeSecs ?? -1 { hasChanges = true }
|
||||
.onChange(of: minWakeSecs) { _, newMinWakeSecs in
|
||||
if newMinWakeSecs != node?.powerConfig?.minWakeSecs ?? -1 { hasChanges = true }
|
||||
}
|
||||
|
||||
SaveConfigButton(node: node, hasChanges: $hasChanges) {
|
||||
|
|
|
|||
|
|
@ -106,17 +106,17 @@ struct SecurityConfig: View {
|
|||
name: "\(bleManager.connectedPeripheral?.shortName ?? "?")"
|
||||
)
|
||||
})
|
||||
.onChange(of: isManaged) {
|
||||
if $0 != node?.securityConfig?.isManaged { hasChanges = true }
|
||||
.onChange(of: isManaged) { _, newIsManaged in
|
||||
if newIsManaged != node?.securityConfig?.isManaged { hasChanges = true }
|
||||
}
|
||||
.onChange(of: serialEnabled) {
|
||||
if $0 != node?.securityConfig?.serialEnabled { hasChanges = true }
|
||||
.onChange(of: serialEnabled) { _, newSerialEnabled in
|
||||
if newSerialEnabled != node?.securityConfig?.serialEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: debugLogApiEnabled) {
|
||||
if $0 != node?.securityConfig?.debugLogApiEnabled { hasChanges = true }
|
||||
.onChange(of: debugLogApiEnabled) { _, newDebugLogApiEnabled in
|
||||
if newDebugLogApiEnabled != node?.securityConfig?.debugLogApiEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: adminChannelEnabled) {
|
||||
if $0 != node?.securityConfig?.adminChannelEnabled { hasChanges = true }
|
||||
.onChange(of: adminChannelEnabled) { _, newAdminChannelEnabled in
|
||||
if newAdminChannelEnabled != node?.securityConfig?.adminChannelEnabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: publicKey) {
|
||||
let tempKey = Data(base64Encoded: publicKey) ?? Data()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue