mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Merge pull request #162 from Ebullioscopic/feature/lock-screen
Battery status update
This commit is contained in:
commit
da64661cc6
4 changed files with 21 additions and 14 deletions
|
|
@ -18644,10 +18644,6 @@
|
||||||
},
|
},
|
||||||
"Temperature unit" : {
|
"Temperature unit" : {
|
||||||
|
|
||||||
},
|
|
||||||
"The MacBook icon is available only in the circular layout." : {
|
|
||||||
"comment" : "A message displayed below a toggle that lets the user choose whether to show a MacBook icon in the battery gauge of the weather widget. The message explains that the MacBook icon is only available when the weather widget is in a",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
},
|
||||||
"TheDynamicIsland" : {
|
"TheDynamicIsland" : {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ struct LockScreenWeatherWidget: View {
|
||||||
chargingSegment(for: charging)
|
chargingSegment(for: charging)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isInline, let battery = snapshot.battery {
|
if let battery = snapshot.battery {
|
||||||
batterySegment(for: battery)
|
batterySegment(for: battery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +101,7 @@ struct LockScreenWeatherWidget: View {
|
||||||
private func batterySegment(for info: LockScreenWeatherSnapshot.BatteryInfo) -> some View {
|
private func batterySegment(for info: LockScreenWeatherSnapshot.BatteryInfo) -> some View {
|
||||||
switch snapshot.widgetStyle {
|
switch snapshot.widgetStyle {
|
||||||
case .inline:
|
case .inline:
|
||||||
EmptyView()
|
inlineBatterySegment(for: info)
|
||||||
case .circular:
|
case .circular:
|
||||||
circularBatterySegment(for: info)
|
circularBatterySegment(for: info)
|
||||||
}
|
}
|
||||||
|
|
@ -206,6 +206,24 @@ struct LockScreenWeatherWidget: View {
|
||||||
.layoutPriority(1)
|
.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 {
|
private func circularBluetoothSegment(for info: LockScreenWeatherSnapshot.BluetoothInfo) -> some View {
|
||||||
let clamped = clampedBatteryLevel(info.batteryLevel)
|
let clamped = clampedBatteryLevel(info.batteryLevel)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2696,14 +2696,7 @@ struct LockScreenSettings: View {
|
||||||
|
|
||||||
if lockScreenWeatherShowsBatteryGauge {
|
if lockScreenWeatherShowsBatteryGauge {
|
||||||
Defaults.Toggle("Use MacBook icon when on battery", key: .lockScreenWeatherBatteryUsesLaptopSymbol)
|
Defaults.Toggle("Use MacBook icon when on battery", key: .lockScreenWeatherBatteryUsesLaptopSymbol)
|
||||||
.disabled(lockScreenWeatherWidgetStyle != .circular)
|
|
||||||
.settingsHighlight(id: highlightID("Use MacBook icon when on battery"))
|
.settingsHighlight(id: highlightID("Use MacBook icon when on battery"))
|
||||||
|
|
||||||
if lockScreenWeatherWidgetStyle != .circular {
|
|
||||||
Text("The MacBook icon is available only in the circular layout.")
|
|
||||||
.font(.caption)
|
|
||||||
.foregroundStyle(.secondary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Defaults.Toggle("Show Bluetooth battery", key: .lockScreenWeatherShowsBluetooth)
|
Defaults.Toggle("Show Bluetooth battery", key: .lockScreenWeatherShowsBluetooth)
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
|
|
||||||
guard clampedLevel >= 0 else { return nil }
|
guard clampedLevel >= 0 else { return nil }
|
||||||
|
|
||||||
let usesLaptopSymbol = widgetStyle == .circular && Defaults[.lockScreenWeatherBatteryUsesLaptopSymbol]
|
let usesLaptopSymbol = Defaults[.lockScreenWeatherBatteryUsesLaptopSymbol]
|
||||||
|
|
||||||
return LockScreenWeatherSnapshot.BatteryInfo(
|
return LockScreenWeatherSnapshot.BatteryInfo(
|
||||||
batteryLevel: clampedLevel,
|
batteryLevel: clampedLevel,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue