mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Bossy linter
This commit is contained in:
parent
26e917df48
commit
a4d5aefca3
43 changed files with 191 additions and 232 deletions
|
|
@ -71,8 +71,7 @@ struct CannedMessagesConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: messages, perform: { _ in
|
||||
|
||||
.onChange(of: messages) {
|
||||
var totalBytes = messages.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 198 {
|
||||
|
|
@ -80,7 +79,7 @@ struct CannedMessagesConfig: View {
|
|||
totalBytes = messages.utf8.count
|
||||
}
|
||||
hasMessagesChanges = true
|
||||
})
|
||||
}
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.keyboardType(.default)
|
||||
|
|
|
|||
|
|
@ -123,14 +123,14 @@ struct MQTTConfig: View {
|
|||
Label("Root Topic", systemImage: "tree")
|
||||
TextField("Root Topic", text: $root)
|
||||
.foregroundColor(.gray)
|
||||
.onChange(of: root, perform: { _ in
|
||||
.onChange(of: root) {
|
||||
var totalBytes = root.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 30 {
|
||||
root = String(root.dropLast())
|
||||
totalBytes = root.utf8.count
|
||||
}
|
||||
})
|
||||
}
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.keyboardType(.asciiCapable)
|
||||
|
|
@ -162,7 +162,7 @@ struct MQTTConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: address, perform: { _ in
|
||||
.onChange(of: address) {
|
||||
var totalBytes = address.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 62 {
|
||||
|
|
@ -170,7 +170,7 @@ struct MQTTConfig: View {
|
|||
totalBytes = address.utf8.count
|
||||
}
|
||||
hasChanges = true
|
||||
})
|
||||
}
|
||||
.keyboardType(.default)
|
||||
}
|
||||
.autocorrectionDisabled()
|
||||
|
|
@ -181,7 +181,7 @@ struct MQTTConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: username, perform: { _ in
|
||||
.onChange(of: username) {
|
||||
var totalBytes = username.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 62 {
|
||||
|
|
@ -189,7 +189,7 @@ struct MQTTConfig: View {
|
|||
totalBytes = username.utf8.count
|
||||
}
|
||||
hasChanges = true
|
||||
})
|
||||
}
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.keyboardType(.default)
|
||||
|
|
@ -200,7 +200,7 @@ struct MQTTConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: password, perform: { _ in
|
||||
.onChange(of: password) {
|
||||
var totalBytes = password.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
while totalBytes > 62 {
|
||||
|
|
@ -208,7 +208,7 @@ struct MQTTConfig: View {
|
|||
totalBytes = password.utf8.count
|
||||
}
|
||||
hasChanges = true
|
||||
})
|
||||
}
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.keyboardType(.default)
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ struct PaxCounterConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: enabled) {
|
||||
if $0 != node?.paxCounterConfig?.enabled { hasChanges = true }
|
||||
.onChange(of: enabled) { oldEnabled, newEnabled in
|
||||
if oldEnabled != newEnabled && newEnabled != node?.paxCounterConfig?.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: paxcounterUpdateInterval) {
|
||||
if $0 != node?.paxCounterConfig?.updateInterval ?? -1 { hasChanges = true }
|
||||
.onChange(of: paxcounterUpdateInterval) { oldPaxcounterUpdateInterval, newPaxcounterUpdateInterval in
|
||||
if oldPaxcounterUpdateInterval != newPaxcounterUpdateInterval && newPaxcounterUpdateInterval != node?.paxCounterConfig?.updateInterval ?? -1 { hasChanges = true }
|
||||
}
|
||||
|
||||
SaveConfigButton(node: node, hasChanges: $hasChanges) {
|
||||
|
|
|
|||
|
|
@ -167,32 +167,26 @@ struct StoreForwardConfig: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: enabled) { newEnabled in
|
||||
if node != nil && node?.storeForwardConfig != nil {
|
||||
if newEnabled != node!.storeForwardConfig!.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: enabled) { oldEnabled, newEnabled in
|
||||
if oldEnabled != newEnabled && newEnabled != node!.storeForwardConfig!.enabled { hasChanges = true }
|
||||
}
|
||||
.onChange(of: isRouter) { newIsRouter in
|
||||
if node != nil && node?.storeForwardConfig != nil {
|
||||
if newIsRouter != node!.storeForwardConfig!.isRouter { hasChanges = true }
|
||||
}
|
||||
.onChange(of: isRouter) { oldIsRouter, newIsRouter in
|
||||
if oldIsRouter != newIsRouter && newIsRouter != node!.storeForwardConfig!.isRouter { hasChanges = true }
|
||||
}
|
||||
.onChange(of: heartbeat) { newHeartbeat in
|
||||
if node != nil && node?.storeForwardConfig != nil {
|
||||
if newHeartbeat != node!.storeForwardConfig!.heartbeat { hasChanges = true }
|
||||
}
|
||||
.onChange(of: heartbeat) { oldHeartbeat, newHeartbeat in
|
||||
if oldHeartbeat != newHeartbeat && newHeartbeat != node!.storeForwardConfig!.heartbeat { hasChanges = true }
|
||||
}
|
||||
.onChange(of: records) { newRecords in
|
||||
.onChange(of: records) { oldRecords, newRecords in
|
||||
if node != nil && node?.storeForwardConfig != nil {
|
||||
if newRecords != node!.storeForwardConfig!.records { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: historyReturnMax) { newHistoryReturnMax in
|
||||
.onChange(of: historyReturnMax) { oldHistoryReturnMax, newHistoryReturnMax in
|
||||
if node != nil && node?.storeForwardConfig != nil {
|
||||
if newHistoryReturnMax != node!.storeForwardConfig!.historyReturnMax { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: historyReturnWindow) { newHistoryReturnWindow in
|
||||
.onChange(of: historyReturnWindow) { oldHistoryReturnWindow, newHistoryReturnWindow in
|
||||
if node != nil && node?.storeForwardConfig != nil {
|
||||
if newHistoryReturnWindow != node!.storeForwardConfig!.historyReturnWindow { hasChanges = true }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue