|
|
@ -391,8 +391,15 @@ class _VideoCallPageState extends State<VideoCallPage> { |
|
|
/// 构建用户信息 |
|
|
/// 构建用户信息 |
|
|
Widget _buildUserInfo() { |
|
|
Widget _buildUserInfo() { |
|
|
return Obx(() { |
|
|
return Obx(() { |
|
|
// 如果已接通,不显示头像和昵称 |
|
|
|
|
|
if (_isCallConnected) { |
|
|
|
|
|
|
|
|
// 在 Obx 中直接访问响应式变量,确保建立监听关系 |
|
|
|
|
|
final callSession = _callController.currentCall.value; |
|
|
|
|
|
final callDuration = _callController.callDurationSeconds.value; |
|
|
|
|
|
final isCallConnected = callSession != null && callDuration > 0; |
|
|
|
|
|
|
|
|
|
|
|
print('📞 [VideoCallPage] _buildUserInfo Obx 重建,isCallConnected: $isCallConnected, callDuration: $callDuration'); |
|
|
|
|
|
|
|
|
|
|
|
// 如果已接通,不显示头像和昵称(适用于发起方和接收方) |
|
|
|
|
|
if (isCallConnected) { |
|
|
return const SizedBox.shrink(); |
|
|
return const SizedBox.shrink(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -443,8 +450,13 @@ class _VideoCallPageState extends State<VideoCallPage> { |
|
|
/// 构建通话时长/状态文本 |
|
|
/// 构建通话时长/状态文本 |
|
|
Widget _buildCallDuration() { |
|
|
Widget _buildCallDuration() { |
|
|
return Obx(() { |
|
|
return Obx(() { |
|
|
|
|
|
// 在 Obx 中直接访问响应式变量,确保建立监听关系 |
|
|
|
|
|
final callSession = _callController.currentCall.value; |
|
|
|
|
|
final callDuration = _callController.callDurationSeconds.value; |
|
|
|
|
|
final isCallConnected = callSession != null && callDuration > 0; |
|
|
|
|
|
|
|
|
// 如果是被呼叫方且未接通,显示邀请文字 |
|
|
// 如果是被呼叫方且未接通,显示邀请文字 |
|
|
if (!widget.isInitiator && !_isCallConnected) { |
|
|
|
|
|
|
|
|
if (!widget.isInitiator && !isCallConnected) { |
|
|
final isVideoCall = widget.callType == 'video'; |
|
|
final isVideoCall = widget.callType == 'video'; |
|
|
final inviteText = isVideoCall ? '邀请你视频通话' : '邀请你语音通话'; |
|
|
final inviteText = isVideoCall ? '邀请你视频通话' : '邀请你语音通话'; |
|
|
|
|
|
|
|
|
@ -466,19 +478,19 @@ class _VideoCallPageState extends State<VideoCallPage> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果已接通但控制按钮已隐藏,不显示时长 |
|
|
// 如果已接通但控制按钮已隐藏,不显示时长 |
|
|
if (_isCallConnected && !showControls.value) { |
|
|
|
|
|
|
|
|
if (isCallConnected && !showControls.value) { |
|
|
return const SizedBox.shrink(); |
|
|
return const SizedBox.shrink(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 呼叫方或已接通,显示时长或"正在呼叫中" |
|
|
// 呼叫方或已接通,显示时长或"正在呼叫中" |
|
|
final duration = Duration(seconds: _callController.callDurationSeconds.value); |
|
|
|
|
|
|
|
|
final duration = Duration(seconds: callDuration); |
|
|
return Positioned( |
|
|
return Positioned( |
|
|
bottom: MediaQuery.of(context).size.height * 0.25, |
|
|
bottom: MediaQuery.of(context).size.height * 0.25, |
|
|
left: 0, |
|
|
left: 0, |
|
|
right: 0, |
|
|
right: 0, |
|
|
child: Center( |
|
|
child: Center( |
|
|
child: Text( |
|
|
child: Text( |
|
|
_isCallConnected ? _formatDuration(duration) : '正在呼叫中', |
|
|
|
|
|
|
|
|
isCallConnected ? _formatDuration(duration) : '正在呼叫中', |
|
|
style: TextStyle( |
|
|
style: TextStyle( |
|
|
color: Colors.white, |
|
|
color: Colors.white, |
|
|
fontSize: 16.sp, |
|
|
fontSize: 16.sp, |
|
|
@ -493,8 +505,13 @@ class _VideoCallPageState extends State<VideoCallPage> { |
|
|
/// 构建控制按钮 |
|
|
/// 构建控制按钮 |
|
|
Widget _buildControlButtons() { |
|
|
Widget _buildControlButtons() { |
|
|
return Obx(() { |
|
|
return Obx(() { |
|
|
|
|
|
// 在 Obx 中直接访问响应式变量,确保建立监听关系 |
|
|
|
|
|
final callSession = _callController.currentCall.value; |
|
|
|
|
|
final callDuration = _callController.callDurationSeconds.value; |
|
|
|
|
|
final isCallConnected = callSession != null && callDuration > 0; |
|
|
|
|
|
|
|
|
// 如果是被呼叫方且未接通,显示"拒绝"和"接听"按钮 |
|
|
// 如果是被呼叫方且未接通,显示"拒绝"和"接听"按钮 |
|
|
if (!widget.isInitiator && !_isCallConnected) { |
|
|
|
|
|
|
|
|
if (!widget.isInitiator && !isCallConnected) { |
|
|
return Positioned( |
|
|
return Positioned( |
|
|
bottom: 40.h, |
|
|
bottom: 40.h, |
|
|
left: 0, |
|
|
left: 0, |
|
|
@ -524,7 +541,7 @@ class _VideoCallPageState extends State<VideoCallPage> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果已接通但控制按钮已隐藏,不显示按钮 |
|
|
// 如果已接通但控制按钮已隐藏,不显示按钮 |
|
|
if (_isCallConnected && !showControls.value) { |
|
|
|
|
|
|
|
|
if (isCallConnected && !showControls.value) { |
|
|
return const SizedBox.shrink(); |
|
|
return const SizedBox.shrink(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|