Convert channels to use the selected pattern for the sheet

This commit is contained in:
Garth Vander Houwen 2024-03-17 10:26:42 -07:00
parent 8d2b705068
commit 8528f08572
2 changed files with 6 additions and 16 deletions

View file

@ -31,7 +31,6 @@ struct Channels: View {
@State var hasChanges = false
@State var hasValidKey = true
@State private var isPresentingEditView = false
@State private var isPresentingSaveConfirm: Bool = false
@State private var channelIndex: Int32 = 0
@State private var channelName = ""
@ -44,6 +43,7 @@ struct Channels: View {
@State private var preciseLocation = true
@State private var positionsEnabled = true
@State private var supportedVersion = true
@State var selectedChannel: ChannelEntity?
/// Minimum Version for granular position configuration
@State var minimumVersion = "2.2.24"
@ -77,9 +77,6 @@ struct Channels: View {
channelName = channel.name ?? ""
uplink = channel.uplinkEnabled
downlink = channel.downlinkEnabled
print("Position Precision \(channel.positionPrecision)")
//self.positionPrecision = State(initialValue: Double(self.channel.positionPrecision))
positionPrecision = Double(channel.positionPrecision)
if !supportedVersion && channelRole == 1 {
positionPrecision = 32
@ -104,9 +101,7 @@ struct Channels: View {
}
}
hasChanges = false
isPresentingEditView = true
selectedChannel = channel
}) {
VStack(alignment: .leading) {
HStack {
@ -132,8 +127,7 @@ struct Channels: View {
}
}
}
.sheet(isPresented: $isPresentingEditView) {
.sheet(item: $selectedChannel) { selection in
#if targetEnvironment(macCatalyst)
Text("channel")
.font(.largeTitle)
@ -208,11 +202,10 @@ struct Channels: View {
let adminMessageId = bleManager.saveChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!)
if adminMessageId > 0 {
self.isPresentingEditView = false
selectedChannel = nil
channelName = ""
channelRole = 2
hasChanges = false
//_ = bleManager.getChannel(channel: channel, fromUser: node!.user!, toUser: node!.user!)
}
} label: {
Label("save", systemImage: "square.and.arrow.down")
@ -224,7 +217,7 @@ struct Channels: View {
.padding(.bottom)
#if targetEnvironment(macCatalyst)
Button {
isPresentingEditView = false
goBack()
} label: {
Label("close", systemImage: "xmark")
}
@ -256,7 +249,7 @@ struct Channels: View {
uplink = false
downlink = false
hasChanges = true
isPresentingEditView = true
selectedChannel = ChannelEntity(context: context)
} label: {
Label("Add Channel", systemImage: "plus.square")

View file

@ -23,11 +23,8 @@ struct ChannelForm: View {
@Binding var positionPrecision: Double
@Binding var preciseLocation: Bool
@Binding var positionsEnabled: Bool
@Binding var hasChanges: Bool
@Binding var hasValidKey: Bool
/// Minimum Version for granular position configuration
@Binding var supportedVersion: Bool
var body: some View {