Merge remote-tracking branch 'refs/remotes/origin/2.2.20_Working_Changes'

This commit is contained in:
Garth Vander Houwen 2024-01-24 10:14:17 -08:00
commit e78cc6336f

View file

@ -25,6 +25,7 @@ struct Channels: View {
var node: NodeInfoEntity?
@State var hasChanges = false
@State var hasValidKey = false
@State private var isPresentingEditView = false
@State private var isPresentingSaveConfirm: Bool = false
@State private var channelIndex: Int32 = 0
@ -167,9 +168,33 @@ struct Channels: View {
HStack(alignment: .top) {
Text("Key")
Spacer()
Text(channelKey)
.foregroundColor(Color.gray)
.textSelection(.enabled)
TextField(
"Key",
text: $channelKey
)
.disableAutocorrection(true)
.keyboardType(.alphabet)
.foregroundColor(Color.gray)
.textSelection(.enabled)
.background(
RoundedRectangle(cornerRadius: 25.0)
.stroke(
hasValidKey ?
Color.green :
Color.red
, lineWidth: 2.0)
)
.onChange(of: channelKey, perform: { _ in
let tempKey = Data(base64Encoded: channelKey) ?? Data()
if tempKey.count == channelKeySize || channelKeySize == -1{
hasValidKey = true
}
else {
hasValidKey = false
}
hasChanges = true
})
.disabled(channelKeySize <= 0)
// TextField(
// "",
// text: $channelKey,
@ -256,7 +281,7 @@ struct Channels: View {
} label: {
Label("save", systemImage: "square.and.arrow.down")
}
.disabled(bleManager.connectedPeripheral == nil || !hasChanges)
.disabled(bleManager.connectedPeripheral == nil || !hasChanges || !hasValidKey)
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)