import React from 'react'; import { View, Text, StyleSheet, TouchableOpacity, Image, StatusBar, } from 'react-native'; import { MaterialCommunityIcons } from '@expo/vector-icons'; import { callStore } from '../../stores/callStore'; import { RTCView } from 'react-native-webrtc'; const formatDuration = (seconds: number): string => { const mins = Math.floor(seconds / 60); const secs = seconds % 60; return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`; }; const CallScreen: React.FC = () => { const currentCall = callStore((s) => s.currentCall); const callDuration = callStore((s) => s.callDuration); const peerStream = callStore((s) => s.peerStream); const endCall = callStore((s) => s.endCall); const toggleMute = callStore((s) => s.toggleMute); const toggleSpeaker = callStore((s) => s.toggleSpeaker); const isMinimized = callStore((s) => s.isMinimized); const toggleMinimize = callStore((s) => s.toggleMinimize); // Don't render full screen when minimized or no call if (!currentCall || isMinimized) return null; const getStatusText = (): string => { switch (currentCall.status) { case 'ringing': return '正在等待对方接听...'; case 'connecting': return '连接中...'; case 'connected': return formatDuration(callDuration); case 'ending': return '通话已结束'; default: return ''; } }; const handleEndCall = () => { endCall('hangup'); }; const handleToggleMute = () => { toggleMute(); }; const handleToggleSpeaker = () => { toggleSpeaker(); }; const handleMinimize = () => { toggleMinimize(); }; return ( {/* Background - single consistent color */} {/* Remote video preview */} {peerStream && ( )} {/* Top area: minimize button */} {/* Center: Peer info */} {currentCall.peerAvatar ? ( ) : ( {currentCall.peerName?.charAt(0).toUpperCase() || '?'} )} {currentCall.peerName || '未知用户'} {getStatusText()} {/* Bottom controls */} {/* Mute */} {currentCall.isMuted ? '取消静音' : '静音'} {/* Speaker */} {currentCall.isSpeakerOn ? '免提' : '听筒'} {/* End call - prominent red button */} 挂断 ); }; const CONTROL_CIRCLE_SIZE = 56; const END_CALL_SIZE = 64; const styles = StyleSheet.create({ container: { ...StyleSheet.absoluteFillObject, backgroundColor: '#1A1A2E', zIndex: 9999, }, background: { ...StyleSheet.absoluteFillObject, backgroundColor: '#1A1A2E', }, topBar: { position: 'absolute', top: 50, left: 0, right: 0, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', height: 44, }, topButton: { width: 44, height: 44, borderRadius: 22, backgroundColor: 'rgba(255, 255, 255, 0.1)', justifyContent: 'center', alignItems: 'center', }, centerArea: { position: 'absolute', top: '28%', left: 0, right: 0, alignItems: 'center', paddingHorizontal: 30, }, avatarOuter: { marginBottom: 16, }, avatar: { width: 100, height: 100, borderRadius: 50, backgroundColor: '#3A3A5C', }, avatarPlaceholder: { justifyContent: 'center', alignItems: 'center', }, avatarText: { fontSize: 40, color: '#fff', fontWeight: '600', }, peerName: { fontSize: 22, fontWeight: '600', color: '#FFFFFF', marginBottom: 6, textAlign: 'center', maxWidth: 280, }, status: { fontSize: 14, color: 'rgba(255, 255, 255, 0.5)', letterSpacing: 0.3, }, remoteVideoContainer: { position: 'absolute', top: 70, right: 20, width: 100, height: 140, borderRadius: 14, overflow: 'hidden', backgroundColor: '#1A1A2E', }, remoteVideo: { width: '100%', height: '100%', }, controls: { position: 'absolute', bottom: 60, left: 0, right: 0, alignItems: 'center', }, controlRow: { flexDirection: 'row', justifyContent: 'center', gap: 36, marginBottom: 24, }, controlButton: { alignItems: 'center', width: 70, }, controlCircle: { width: CONTROL_CIRCLE_SIZE, height: CONTROL_CIRCLE_SIZE, borderRadius: CONTROL_CIRCLE_SIZE / 2, backgroundColor: 'rgba(255, 255, 255, 0.12)', justifyContent: 'center', alignItems: 'center', }, controlCircleActive: { backgroundColor: '#FFFFFF', }, controlButtonActive: {}, controlLabel: { fontSize: 11, color: 'rgba(255, 255, 255, 0.55)', marginTop: 8, }, controlLabelActive: { color: '#FFFFFF', fontWeight: '500', }, endCallButton: { alignItems: 'center', }, endCallCircle: { width: END_CALL_SIZE, height: END_CALL_SIZE, borderRadius: END_CALL_SIZE / 2, backgroundColor: '#E54D42', justifyContent: 'center', alignItems: 'center', }, endCallLabel: { fontSize: 11, color: 'rgba(255, 255, 255, 0.55)', marginTop: 8, }, }); export default CallScreen;