Files
Kymo/kymo/Features/MenuBar/MenuBarLabel.swift
T

31 lines
948 B
Swift

import SwiftUI
struct MenuBarLabel: View {
let snapshot: MetricsSnapshot
var body: some View {
// Use one native image/title label: the previous multi-view HStack showed
// only its first image and percentage in the user-verified menu bar.
Label {
Text(verbatim: title)
.monospacedDigit()
} icon: {
Image("BrandMark")
.renderingMode(.template)
.resizable()
.scaledToFit()
.frame(width: 18, height: 18)
}
.labelStyle(.titleAndIcon)
}
private var title: String {
var items = ["CPU \(MetricFormat.percent(snapshot.cpu?.usage))"]
if let gpu = snapshot.gpuUsage {
items.append("GPU \(MetricFormat.percent(gpu))")
}
items.append("MEM \(MetricFormat.percent(snapshot.memory?.usage))")
return items.joined(separator: " · ")
}
}