mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Updated Battery Icon to Macbook Icon
This commit is contained in:
parent
7e31286ae3
commit
27e3ec9ffd
5 changed files with 30 additions and 6 deletions
|
|
@ -10888,6 +10888,9 @@
|
||||||
},
|
},
|
||||||
"Mac battery at %d percent" : {
|
"Mac battery at %d percent" : {
|
||||||
"comment" : "Mac battery gauge accessibility label"
|
"comment" : "Mac battery gauge accessibility label"
|
||||||
|
},
|
||||||
|
"MacBook icon is available in the circular layout." : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Made ❤️ by Ebullioscopic" : {
|
"Made ❤️ by Ebullioscopic" : {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,12 +158,13 @@ struct LockScreenWeatherWidget: View {
|
||||||
|
|
||||||
private func circularBatterySegment(for info: LockScreenWeatherSnapshot.BatteryInfo) -> some View {
|
private func circularBatterySegment(for info: LockScreenWeatherSnapshot.BatteryInfo) -> some View {
|
||||||
let level = clampedBatteryLevel(info.batteryLevel)
|
let level = clampedBatteryLevel(info.batteryLevel)
|
||||||
|
let symbolName = info.usesLaptopSymbol ? "laptopcomputer" : batteryIconName(for: level)
|
||||||
|
|
||||||
return VStack(spacing: 6) {
|
return VStack(spacing: 6) {
|
||||||
Gauge(value: Double(level), in: 0...100) {
|
Gauge(value: Double(level), in: 0...100) {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
} currentValueLabel: {
|
} currentValueLabel: {
|
||||||
Image(systemName: batteryIconName(for: level))
|
Image(systemName: symbolName)
|
||||||
.font(.system(size: 20, weight: .semibold))
|
.font(.system(size: 20, weight: .semibold))
|
||||||
.foregroundStyle(Color.white)
|
.foregroundStyle(Color.white)
|
||||||
} minimumValueLabel: {
|
} minimumValueLabel: {
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ struct GeneralSettings: View {
|
||||||
@Default(.lockScreenWeatherAQIScale) var lockScreenWeatherAQIScale
|
@Default(.lockScreenWeatherAQIScale) var lockScreenWeatherAQIScale
|
||||||
@Default(.lockScreenWeatherUsesGaugeTint) var lockScreenWeatherUsesGaugeTint
|
@Default(.lockScreenWeatherUsesGaugeTint) var lockScreenWeatherUsesGaugeTint
|
||||||
@Default(.lockScreenWeatherProviderSource) var lockScreenWeatherProviderSource
|
@Default(.lockScreenWeatherProviderSource) var lockScreenWeatherProviderSource
|
||||||
|
@Default(.lockScreenWeatherBatteryUsesLaptopSymbol) var lockScreenWeatherBatteryUsesLaptopSymbol
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
|
@ -403,6 +404,15 @@ struct GeneralSettings: View {
|
||||||
Defaults.Toggle("Show charging percentage", key: .lockScreenWeatherShowsChargingPercentage)
|
Defaults.Toggle("Show charging percentage", key: .lockScreenWeatherShowsChargingPercentage)
|
||||||
}
|
}
|
||||||
Defaults.Toggle("Show battery indicator", key: .lockScreenWeatherShowsBatteryGauge)
|
Defaults.Toggle("Show battery indicator", key: .lockScreenWeatherShowsBatteryGauge)
|
||||||
|
if lockScreenWeatherShowsBatteryGauge {
|
||||||
|
Defaults.Toggle("Use MacBook icon when on battery", key: .lockScreenWeatherBatteryUsesLaptopSymbol)
|
||||||
|
.disabled(lockScreenWeatherWidgetStyle != .circular)
|
||||||
|
if lockScreenWeatherWidgetStyle != .circular {
|
||||||
|
Text("MacBook icon is available in the circular layout.")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
Defaults.Toggle("Show Bluetooth battery", key: .lockScreenWeatherShowsBluetooth)
|
Defaults.Toggle("Show Bluetooth battery", key: .lockScreenWeatherShowsBluetooth)
|
||||||
Defaults.Toggle("Show AQI widget", key: .lockScreenWeatherShowsAQI)
|
Defaults.Toggle("Show AQI widget", key: .lockScreenWeatherShowsAQI)
|
||||||
.disabled(!lockScreenWeatherProviderSource.supportsAirQuality)
|
.disabled(!lockScreenWeatherProviderSource.supportsAirQuality)
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,8 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
let showsCharging = Defaults[.lockScreenWeatherShowsCharging]
|
let showsCharging = Defaults[.lockScreenWeatherShowsCharging]
|
||||||
let chargingInfo = showsCharging ? makeChargingInfo() : nil
|
let chargingInfo = showsCharging ? makeChargingInfo() : nil
|
||||||
let showsBatteryGauge = Defaults[.lockScreenWeatherShowsBatteryGauge]
|
let showsBatteryGauge = Defaults[.lockScreenWeatherShowsBatteryGauge]
|
||||||
let batteryInfo = showsBatteryGauge ? makeBatteryGaugeInfo(isCharging: chargingInfo != nil) : nil
|
let widgetStyle = Defaults[.lockScreenWeatherWidgetStyle]
|
||||||
|
let batteryInfo = showsBatteryGauge ? makeBatteryGaugeInfo(isCharging: chargingInfo != nil, widgetStyle: widgetStyle) : nil
|
||||||
let fallback = LockScreenWeatherSnapshot(
|
let fallback = LockScreenWeatherSnapshot(
|
||||||
temperatureText: snapshot?.temperatureText ?? "--",
|
temperatureText: snapshot?.temperatureText ?? "--",
|
||||||
symbolName: snapshot?.symbolName ?? "cloud.fill",
|
symbolName: snapshot?.symbolName ?? "cloud.fill",
|
||||||
|
|
@ -116,7 +117,7 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
battery: batteryInfo,
|
battery: batteryInfo,
|
||||||
showsLocation: snapshot?.showsLocation ?? false,
|
showsLocation: snapshot?.showsLocation ?? false,
|
||||||
airQuality: (providerSource.supportsAirQuality && Defaults[.lockScreenWeatherShowsAQI]) ? snapshot?.airQuality : nil,
|
airQuality: (providerSource.supportsAirQuality && Defaults[.lockScreenWeatherShowsAQI]) ? snapshot?.airQuality : nil,
|
||||||
widgetStyle: Defaults[.lockScreenWeatherWidgetStyle],
|
widgetStyle: widgetStyle,
|
||||||
showsChargingPercentage: Defaults[.lockScreenWeatherShowsChargingPercentage],
|
showsChargingPercentage: Defaults[.lockScreenWeatherShowsChargingPercentage],
|
||||||
temperatureInfo: snapshot?.temperatureInfo,
|
temperatureInfo: snapshot?.temperatureInfo,
|
||||||
usesGaugeTint: Defaults[.lockScreenWeatherUsesGaugeTint]
|
usesGaugeTint: Defaults[.lockScreenWeatherUsesGaugeTint]
|
||||||
|
|
@ -189,6 +190,8 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
.map { _ in () }.eraseToAnyPublisher(),
|
.map { _ in () }.eraseToAnyPublisher(),
|
||||||
Defaults.publisher(.lockScreenWeatherShowsBatteryGauge, options: [])
|
Defaults.publisher(.lockScreenWeatherShowsBatteryGauge, options: [])
|
||||||
.map { _ in () }.eraseToAnyPublisher(),
|
.map { _ in () }.eraseToAnyPublisher(),
|
||||||
|
Defaults.publisher(.lockScreenWeatherBatteryUsesLaptopSymbol, options: [])
|
||||||
|
.map { _ in () }.eraseToAnyPublisher(),
|
||||||
Defaults.publisher(.lockScreenWeatherWidgetStyle, options: [])
|
Defaults.publisher(.lockScreenWeatherWidgetStyle, options: [])
|
||||||
.map { _ in () }.eraseToAnyPublisher(),
|
.map { _ in () }.eraseToAnyPublisher(),
|
||||||
Defaults.publisher(.lockScreenWeatherTemperatureUnit, options: [])
|
Defaults.publisher(.lockScreenWeatherTemperatureUnit, options: [])
|
||||||
|
|
@ -289,7 +292,7 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
let showsChargingPercentage = Defaults[.lockScreenWeatherShowsChargingPercentage]
|
let showsChargingPercentage = Defaults[.lockScreenWeatherShowsChargingPercentage]
|
||||||
let providerSource = Defaults[.lockScreenWeatherProviderSource]
|
let providerSource = Defaults[.lockScreenWeatherProviderSource]
|
||||||
let airQualityInfo = (Defaults[.lockScreenWeatherShowsAQI] && providerSource.supportsAirQuality) ? payload.airQuality : nil
|
let airQualityInfo = (Defaults[.lockScreenWeatherShowsAQI] && providerSource.supportsAirQuality) ? payload.airQuality : nil
|
||||||
let batteryInfo = Defaults[.lockScreenWeatherShowsBatteryGauge] ? makeBatteryGaugeInfo(isCharging: chargingInfo != nil) : nil
|
let batteryInfo = Defaults[.lockScreenWeatherShowsBatteryGauge] ? makeBatteryGaugeInfo(isCharging: chargingInfo != nil, widgetStyle: widgetStyle) : nil
|
||||||
let usesGaugeTint = Defaults[.lockScreenWeatherUsesGaugeTint]
|
let usesGaugeTint = Defaults[.lockScreenWeatherUsesGaugeTint]
|
||||||
|
|
||||||
return LockScreenWeatherSnapshot(
|
return LockScreenWeatherSnapshot(
|
||||||
|
|
@ -334,7 +337,7 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeBatteryGaugeInfo(isCharging: Bool) -> LockScreenWeatherSnapshot.BatteryInfo? {
|
private func makeBatteryGaugeInfo(isCharging: Bool, widgetStyle: LockScreenWeatherWidgetStyle) -> LockScreenWeatherSnapshot.BatteryInfo? {
|
||||||
guard !isCharging else { return nil }
|
guard !isCharging else { return nil }
|
||||||
|
|
||||||
let battery = BatteryStatusViewModel.shared
|
let battery = BatteryStatusViewModel.shared
|
||||||
|
|
@ -343,7 +346,12 @@ final class LockScreenWeatherManager: ObservableObject {
|
||||||
|
|
||||||
guard clampedLevel >= 0 else { return nil }
|
guard clampedLevel >= 0 else { return nil }
|
||||||
|
|
||||||
return LockScreenWeatherSnapshot.BatteryInfo(batteryLevel: clampedLevel)
|
let usesLaptopSymbol = widgetStyle == .circular && Defaults[.lockScreenWeatherBatteryUsesLaptopSymbol]
|
||||||
|
|
||||||
|
return LockScreenWeatherSnapshot.BatteryInfo(
|
||||||
|
batteryLevel: clampedLevel,
|
||||||
|
usesLaptopSymbol: usesLaptopSymbol
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeBluetoothInfo() -> LockScreenWeatherSnapshot.BluetoothInfo? {
|
private func makeBluetoothInfo() -> LockScreenWeatherSnapshot.BluetoothInfo? {
|
||||||
|
|
@ -427,6 +435,7 @@ struct LockScreenWeatherSnapshot: Equatable {
|
||||||
|
|
||||||
struct BatteryInfo: Equatable {
|
struct BatteryInfo: Equatable {
|
||||||
let batteryLevel: Int
|
let batteryLevel: Int
|
||||||
|
let usesLaptopSymbol: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AirQualityInfo: Equatable {
|
struct AirQualityInfo: Equatable {
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,7 @@ extension Defaults.Keys {
|
||||||
static let lockScreenWeatherShowsChargingPercentage = Key<Bool>("lockScreenWeatherShowsChargingPercentage", default: true)
|
static let lockScreenWeatherShowsChargingPercentage = Key<Bool>("lockScreenWeatherShowsChargingPercentage", default: true)
|
||||||
static let lockScreenWeatherShowsBluetooth = Key<Bool>("lockScreenWeatherShowsBluetooth", default: true)
|
static let lockScreenWeatherShowsBluetooth = Key<Bool>("lockScreenWeatherShowsBluetooth", default: true)
|
||||||
static let lockScreenWeatherShowsBatteryGauge = Key<Bool>("lockScreenWeatherShowsBatteryGauge", default: true)
|
static let lockScreenWeatherShowsBatteryGauge = Key<Bool>("lockScreenWeatherShowsBatteryGauge", default: true)
|
||||||
|
static let lockScreenWeatherBatteryUsesLaptopSymbol = Key<Bool>("lockScreenWeatherBatteryUsesLaptopSymbol", default: false)
|
||||||
static let lockScreenWeatherWidgetStyle = Key<LockScreenWeatherWidgetStyle>("lockScreenWeatherWidgetStyle", default: .circular)
|
static let lockScreenWeatherWidgetStyle = Key<LockScreenWeatherWidgetStyle>("lockScreenWeatherWidgetStyle", default: .circular)
|
||||||
static let lockScreenWeatherTemperatureUnit = Key<LockScreenWeatherTemperatureUnit>("lockScreenWeatherTemperatureUnit", default: .celsius)
|
static let lockScreenWeatherTemperatureUnit = Key<LockScreenWeatherTemperatureUnit>("lockScreenWeatherTemperatureUnit", default: .celsius)
|
||||||
static let lockScreenWeatherShowsAQI = Key<Bool>("lockScreenWeatherShowsAQI", default: false)
|
static let lockScreenWeatherShowsAQI = Key<Bool>("lockScreenWeatherShowsAQI", default: false)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue