import React from "react"; import { View, Text, StyleSheet, ViewStyle } from "react-native"; interface BatteryStatusProps { status: 1 | 0 | -1 | null; style?: ViewStyle; } const BatteryStatus: React.FC = ({ status, style }) => { const getStatusConfig = (): { text: string; backgroundColor: string; textColor: string; } => { switch (status) { case 1: return { text: "Charging", backgroundColor: "#006C4D", textColor: "#006C4D", }; case -1: return { text: "Discharging", backgroundColor: "#E5EBFD", textColor: "#1249ED", }; case 0: return { text: "Idle", backgroundColor: "#565F70", textColor: "#565F70", }; case null: return { text: "---", backgroundColor: "#e2e3e5", textColor: "#6c757d", }; default: return { text: "Unknown", backgroundColor: "#f8f9fa", textColor: "#6c757d", }; } }; const config = getStatusConfig(); return ( {config.text} ); }; const styles = StyleSheet.create({ container: { paddingHorizontal: 8, paddingVertical: 2, borderRadius: 4, justifyContent: "center", }, text: { fontSize: 16, fontWeight: "500", }, }); export default BatteryStatus;