Channel Location Precision mockup

This commit is contained in:
Garth Vander Houwen 2024-02-23 23:18:48 -08:00
parent 4288415cf1
commit 3798cd43be
3 changed files with 25 additions and 4 deletions

View file

@ -152,6 +152,7 @@ func channelPacket (channel: Channel, fromNum: Int64, context: NSManagedObjectCo
newChannel.name = channel.settings.name
newChannel.role = Int32(channel.role.rawValue)
newChannel.psk = channel.settings.psk
//newChannel.precisionBits = channel.settings.precisionBits
guard let mutableChannels = fetchedMyInfo[0].channels!.mutableCopy() as? NSMutableOrderedSet else {
return
}

View file

@ -34,7 +34,7 @@
<attribute name="index" attributeType="Integer 32" minValueString="0" maxValueString="13" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="mute" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="name" optional="YES" attributeType="String"/>
<attribute name="precisionBits" optional="YES" attributeType="Integer 32" defaultValueString="32" usesScalarValueType="YES"/>
<attribute name="positionPrecision" optional="YES" attributeType="Integer 32" defaultValueString="32" usesScalarValueType="YES"/>
<attribute name="psk" optional="YES" attributeType="Binary"/>
<attribute name="role" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="uplinkEnabled" attributeType="Boolean" usesScalarValueType="YES"/>
@ -282,6 +282,7 @@
<attribute name="latest" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="latitudeI" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="longitudeI" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="precisionBits" optional="YES" attributeType="Integer 32" defaultValueString="32" usesScalarValueType="YES"/>
<attribute name="rssi" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="satsInView" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="seqNo" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>

View file

@ -44,8 +44,14 @@ struct Channels: View {
@State private var positionPrecision = 32.0
@State private var preciseLocation = true
@State private var positionsEnabled = true
/// Minimum Version for granular position configuration
@State var minimumVersion = "2.2.20"
var body: some View {
let supportedVersion = bleManager.connectedVersion == "0.0.0" || self.minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(bleManager.connectedVersion, options: .numeric) == .orderedSame
VStack {
List {
@ -73,6 +79,16 @@ struct Channels: View {
uplink = channel.uplinkEnabled
downlink = channel.downlinkEnabled
hasChanges = false
if !supportedVersion && channelRole == 1 {
positionPrecision = 0
preciseLocation = true
positionsEnabled = true
} else if !supportedVersion && channelRole == 2 {
positionPrecision = 32
preciseLocation = false
positionsEnabled = false
}
isPresentingEditView = true
}) {
VStack(alignment: .leading) {
@ -217,25 +233,27 @@ struct Channels: View {
Label("Positions Enabled", systemImage: positionsEnabled ? "mappin" : "mappin.slash")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
.disabled(!supportedVersion)
}
if positionsEnabled {
VStack(alignment: .leading) {
Toggle(isOn: $preciseLocation) {
Label("Precise Location", systemImage: "location.circle")
Label("Precise Location", systemImage: "scope")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
.disabled(!supportedVersion)
.listRowSeparator(.visible)
.onChange(of: preciseLocation) { pl in
if pl == false {
positionPrecision = 16
positionPrecision = 13
}
}
}
if !preciseLocation {
VStack(alignment: .leading) {
Label("Position Precision", systemImage: "scope")
Label("Reduce Precision", systemImage: "location.viewfinder")
Slider(
value: $positionPrecision,
in: 11...16,
@ -321,6 +339,7 @@ struct Channels: View {
newChannel.name = channel.settings.name
newChannel.role = Int32(channel.role.rawValue)
newChannel.psk = channel.settings.psk
guard let mutableChannels = node?.myInfo?.channels?.mutableCopy() as? NSMutableOrderedSet else {
return
}