diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index a7cfebf0..6c5fe5ed 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -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") diff --git a/Meshtastic/Views/Settings/Channels/ChannelForm.swift b/Meshtastic/Views/Settings/Channels/ChannelForm.swift index c191d345..7176d802 100644 --- a/Meshtastic/Views/Settings/Channels/ChannelForm.swift +++ b/Meshtastic/Views/Settings/Channels/ChannelForm.swift @@ -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 {