@@ -22,7 +22,11 @@ const icons: Record<string, icon> = {
22
22
iconName : 'battery.25percent' ,
23
23
color : Color . red ( ) ,
24
24
} ,
25
- 'battery.50' : {
25
+ 'battery.50.green' : {
26
+ iconName : 'battery.50percent' ,
27
+ color : Color . green ( ) ,
28
+ } ,
29
+ 'battery.50.orange' : {
26
30
iconName : 'battery.50percent' ,
27
31
color : Color . orange ( ) ,
28
32
} ,
@@ -144,9 +148,9 @@ export function getChargeCompletionString(
144
148
}
145
149
146
150
export function getBatteryPercentColor ( batteryPercent : number ) : Color {
147
- if ( batteryPercent >= 50 ) {
151
+ if ( batteryPercent >= 45 ) {
148
152
return Color . green ( )
149
- } else if ( batteryPercent >= 30 ) {
153
+ } else if ( batteryPercent >= 35 ) {
150
154
return Color . orange ( )
151
155
}
152
156
return Color . red ( )
@@ -204,16 +208,21 @@ export function getChargingIcon(isCharging: boolean, isPluggedIn: boolean, isWid
204
208
205
209
export function calculateBatteryIcon ( batteryPercent : number ) : string {
206
210
let percentRounded = 0
211
+ let colorExtra = ''
207
212
if ( batteryPercent > 90 ) {
208
213
percentRounded = 100
209
- } else if ( batteryPercent > 60 ) {
214
+ } else if ( batteryPercent >= 65 ) {
210
215
percentRounded = 75
211
- } else if ( batteryPercent > 40 ) {
216
+ } else if ( batteryPercent >= 45 ) {
217
+ percentRounded = 50
218
+ colorExtra = '.green'
219
+ } else if ( batteryPercent >= 35 ) {
212
220
percentRounded = 50
213
- } else if ( batteryPercent > 15 ) {
221
+ colorExtra = '.orange'
222
+ } else if ( batteryPercent >= 15 ) {
214
223
percentRounded = 25
215
224
}
216
- return `battery.${ percentRounded } `
225
+ return `battery.${ percentRounded } ${ colorExtra } `
217
226
}
218
227
219
228
export async function tintSFSymbol ( name : string , image : Image , color : Color , rotateDegree ?: number ) {
0 commit comments