import React from 'react'; import { View, Text, StyleSheet, TouchableOpacity, Platform } from 'react-native'; import { useConnectionStore } from '../../stores/connectionStore'; import { useDeviceStore } from '../../stores/deviceStore'; import { useDataStore } from '../../stores/dataStore'; import { formatBattery, formatTemperature } from '../../utils/format'; import { Colors } from '../../design/tokens'; function Pill({ label, value, color, onPress, }: { label: string; value: string; color: string; onPress?: () => void; }) { const inner = ( {label} {value} ); if (onPress) return {inner}; return inner; } export function GlobalStatusBar() { const { status, showModal } = useConnectionStore(); const { deviceStatus, batteryVolt, temperature, gpsStatus, sdStatus } = useDeviceStore(); const frame = useDataStore((s) => s.currentFrame); const meta = frame?.meta; const connected = status === 'connected'; const connColor = connected ? Colors.green.fg : status === 'connecting' ? Colors.amber.fg : Colors.text.ghost; const connLabel = connected ? '已连接' : status === 'connecting' ? '连接中' : status === 'reconnecting' ? '重连' : '未连接'; const hasGps = gpsStatus > 0 || (meta?.gpsStatus ?? 0) > 0; const hasSd = sdStatus > 0; const running = deviceStatus === 'running'; const single = deviceStatus === 'single'; const stateColor = running ? Colors.green.fg : single ? Colors.teal.fg : Colors.text.ghost; const stateLabel = running ? '● 运行' : single ? '◎ 单次' : '○ 停止'; return ( {/* Connection — tappable */} {/* Device run state */} {connected && ( {stateLabel} )} {/* GPS */} {/* SD */} {/* Battery */} {batteryVolt > 0 && ( )} {/* Temperature */} {temperature > 0 && ( )} {/* Frame counter — right-aligned */} {frame && ( #{frame.frameId} )} ); } const S = StyleSheet.create({ bar: { flexDirection: 'row', backgroundColor: Colors.bg.void, paddingHorizontal: 10, paddingVertical: 7, alignItems: 'center', flexWrap: 'wrap', gap: 5, borderBottomWidth: 1, borderBottomColor: Colors.bg.border, }, pill: { flexDirection: 'row', alignItems: 'center', gap: 4, backgroundColor: Colors.bg.raised, borderRadius: 5, borderWidth: 1, borderColor: Colors.bg.border, paddingHorizontal: 6, paddingVertical: 2, }, dot: { width: 5, height: 5, borderRadius: 3 }, pillLabel: { color: Colors.text.ghost, fontSize: 9, fontWeight: '600', letterSpacing: 0.5 }, pillValue: { fontSize: 9, fontWeight: '700', fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace' }, stateText: { fontSize: 10, fontWeight: '700', letterSpacing: 0.3 }, frameCount: { marginLeft: 'auto' as any }, frameCountText: { color: Colors.text.ghost, fontSize: 10, fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace', }, });