Skip to content

Commit 7a2c110

Browse files
Updated battery info display to have colors.
1 parent b96f6c3 commit 7a2c110

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

components/BatteryInfo.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const BatteryInfo = () => {
2222
openBatteryOptimizationSettings,
2323
} = useBattery();
2424

25+
const batteryPercent = batteryLevel !== null ? batteryLevel * 100 : null;
26+
2527
const [animatedWidth] = useState(new Animated.Value(0));
2628
const [pulseOpacity] = useState(new Animated.Value(1));
2729

@@ -121,7 +123,10 @@ const BatteryInfo = () => {
121123
inputRange: [0, 100],
122124
outputRange: ["5%", "100%"], // Ensure minimum width for visibility
123125
}),
124-
backgroundColor: getBatteryColor(batteryLevel * 100),
126+
backgroundColor:
127+
batteryPercent !== null
128+
? getBatteryColor(batteryPercent)
129+
: styles.batteryBarContainer.backgroundColor,
125130
opacity: pulseOpacity, // Charging animation effect
126131
},
127132
]}

0 commit comments

Comments
 (0)