mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
25 lines
613 B
Swift
25 lines
613 B
Swift
//
|
|
// BatteryIcon.swift
|
|
// Meshtastic
|
|
//
|
|
// Copyright Garth Vander Houwen 3/24/23.
|
|
//
|
|
import SwiftUI
|
|
|
|
struct BatteryLevelCompact: View {
|
|
|
|
@ObservedObject var node: NodeInfoEntity
|
|
|
|
var font: Font
|
|
var iconFont: Font
|
|
var color: Color
|
|
|
|
var body: some View {
|
|
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 {
|
|
BatteryCompact(batteryLevel: batteryLevel, font: font, iconFont: iconFont, color: color)
|
|
}
|
|
}
|
|
}
|