2023-05-16 15:15:58 -07:00
|
|
|
//
|
|
|
|
|
// BatteryIcon.swift
|
|
|
|
|
// Meshtastic
|
|
|
|
|
//
|
|
|
|
|
// Copyright Garth Vander Houwen 3/24/23.
|
|
|
|
|
//
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
|
|
struct BatteryLevelCompact: View {
|
2024-05-29 16:40:07 -05:00
|
|
|
|
2023-11-08 23:21:05 -08:00
|
|
|
@ObservedObject var node: NodeInfoEntity
|
|
|
|
|
|
2023-05-16 15:15:58 -07:00
|
|
|
var font: Font
|
|
|
|
|
var iconFont: Font
|
|
|
|
|
var color: Color
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
2023-11-08 23:21:05 -08:00
|
|
|
let deviceMetrics = node.telemetries?.filtered(using: NSPredicate(format: "metricsType == 0"))
|
|
|
|
|
let mostRecent = deviceMetrics?.lastObject as? TelemetryEntity
|
|
|
|
|
let batteryLevel = mostRecent?.batteryLevel ?? 0
|
|
|
|
|
if deviceMetrics?.count ?? 0 > 0 {
|
2024-07-18 11:26:17 -07:00
|
|
|
BatteryCompact(batteryLevel: batteryLevel, font: font, iconFont: iconFont, color: color)
|
2023-05-16 15:15:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|