mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Node map altitude chart
This commit is contained in:
parent
a89f33b9f5
commit
3d06e55818
3 changed files with 9 additions and 50 deletions
|
|
@ -666,7 +666,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
let interval = UserDefaults.provideLocationInterval > 0 ? UserDefaults.provideLocationInterval : 30
|
||||
if positionTimer != nil {
|
||||
}
|
||||
positionTimer = Timer.scheduledTimer(timeInterval: TimeInterval((UserDefaults.provideLocationInterval)), target: self, selector: #selector(positionTimerFired), userInfo: context, repeats: true)
|
||||
positionTimer = Timer.scheduledTimer(timeInterval: TimeInterval(interval), target: self, selector: #selector(positionTimerFired), userInfo: context, repeats: true)
|
||||
if positionTimer != nil {
|
||||
RunLoop.current.add(positionTimer!, forMode: .common)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ import Charts
|
|||
import MapKit
|
||||
#endif
|
||||
|
||||
struct PositionAltitude {
|
||||
let time: Date
|
||||
var altitude: Measurement<UnitLength>
|
||||
}
|
||||
|
||||
@available(iOS 17.0, macOS 14.0, *)
|
||||
struct PositionAltitudeChart: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@ObservedObject var node: NodeInfoEntity
|
||||
|
||||
@State private var lineWidth = 2.0
|
||||
@State private var interpolationMethod: ChartInterpolationMethod = .linear
|
||||
@State private var chartColor: Color = .accentColor
|
||||
@State private var showSymbols = true
|
||||
|
||||
var body: some View {
|
||||
let nodePositions = Array(node.positions!) as! [PositionEntity]
|
||||
|
|
@ -32,12 +32,11 @@ struct PositionAltitudeChart: View {
|
|||
y: .value("Altitude", PlottableMeasurement(measurement: $0.altitude))
|
||||
)
|
||||
.accessibilityLabel($0.time.formatted(date: .abbreviated, time: .shortened))
|
||||
.accessibilityValue("\($0.altitude) ft high")
|
||||
.accessibilityValue("\($0.altitude)")
|
||||
.lineStyle(StrokeStyle(lineWidth: lineWidth))
|
||||
.foregroundStyle(chartColor.gradient)
|
||||
.interpolationMethod(interpolationMethod.mode)
|
||||
.interpolationMethod(.linear)
|
||||
.symbol(Circle().strokeBorder(lineWidth: lineWidth))
|
||||
.symbolSize(showSymbols ? 60 : 0)
|
||||
.symbolSize(60)
|
||||
}
|
||||
.chartYAxis {
|
||||
AxisMarks { value in
|
||||
|
|
@ -62,39 +61,3 @@ struct PositionAltitudeChart: View {
|
|||
.opacity(/*@START_MENU_TOKEN@*/0.8/*@END_MENU_TOKEN@*/)
|
||||
}
|
||||
}
|
||||
|
||||
struct PositionAltitude {
|
||||
let time: Date
|
||||
var altitude: Measurement<UnitLength>
|
||||
}
|
||||
|
||||
enum ChartInterpolationMethod: Identifiable, CaseIterable {
|
||||
case linear
|
||||
case monotone
|
||||
case catmullRom
|
||||
case cardinal
|
||||
case stepStart
|
||||
case stepCenter
|
||||
case stepEnd
|
||||
|
||||
var id: String { mode.description }
|
||||
|
||||
var mode: InterpolationMethod {
|
||||
switch self {
|
||||
case .linear:
|
||||
return .linear
|
||||
case .monotone:
|
||||
return .monotone
|
||||
case .stepStart:
|
||||
return .stepStart
|
||||
case .stepCenter:
|
||||
return .stepCenter
|
||||
case .stepEnd:
|
||||
return .stepEnd
|
||||
case .catmullRom:
|
||||
return .catmullRom
|
||||
case .cardinal:
|
||||
return .cardinal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,7 @@ struct NodeListItem: View {
|
|||
VStack(alignment: .leading) {
|
||||
CircleText(text: node.user?.shortName ?? "?", color: Color(UIColor(hex: UInt32(node.num))), circleSize: 65)
|
||||
.padding(.trailing, 5)
|
||||
let deviceMetrics = node.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0"))
|
||||
if deviceMetrics?.count ?? 0 >= 1 {
|
||||
let mostRecent = deviceMetrics?.lastObject as? TelemetryEntity
|
||||
BatteryLevelCompact(node: node, font: .caption, iconFont: .callout, color: .accentColor)
|
||||
}
|
||||
BatteryLevelCompact(node: node, font: .caption, iconFont: .callout, color: .accentColor)
|
||||
}
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue