From ad60abdb24c73aebfcef31700dce997f3da1c0f6 Mon Sep 17 00:00:00 2001 From: Ibrty Date: Sat, 6 Dec 2025 22:27:38 -0800 Subject: [PATCH] Add files via upload Add battery percentage to inline lockscreen widget --- .../LockScreen/LockScreenWeatherWidget.swift | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/DynamicIsland/components/LockScreen/LockScreenWeatherWidget.swift b/DynamicIsland/components/LockScreen/LockScreenWeatherWidget.swift index 5d486b0..59af845 100644 --- a/DynamicIsland/components/LockScreen/LockScreenWeatherWidget.swift +++ b/DynamicIsland/components/LockScreen/LockScreenWeatherWidget.swift @@ -25,7 +25,7 @@ struct LockScreenWeatherWidget: View { chargingSegment(for: charging) } - if !isInline, let battery = snapshot.battery { + if let battery = snapshot.battery { batterySegment(for: battery) } @@ -101,7 +101,7 @@ struct LockScreenWeatherWidget: View { private func batterySegment(for info: LockScreenWeatherSnapshot.BatteryInfo) -> some View { switch snapshot.widgetStyle { case .inline: - EmptyView() + inlineBatterySegment(for: info) case .circular: circularBatterySegment(for: info) } @@ -205,6 +205,24 @@ struct LockScreenWeatherWidget: View { } .layoutPriority(1) } + + private func inlineBatterySegment(for info: LockScreenWeatherSnapshot.BatteryInfo) -> some View { + let level = clampedBatteryLevel(info.batteryLevel) + + return HStack(alignment: .firstTextBaseline, spacing: 6) { + // Optional icon (laptop vs battery glyph) + Image(systemName: info.usesLaptopSymbol ? "laptopcomputer" : batteryIconName(for: level)) + .font(.system(size: 20, weight: .semibold)) + .symbolRenderingMode(.hierarchical) + + // ✅ The actual percentage text you want in inline style + Text("\(level)%") + .font(inlinePrimaryFont) + .lineLimit(1) + .minimumScaleFactor(0.85) + } + .layoutPriority(1) + } private func circularBluetoothSegment(for info: LockScreenWeatherSnapshot.BluetoothInfo) -> some View { let clamped = clampedBatteryLevel(info.batteryLevel)