From 29c6ec1ba930208e88c38ef52999a71d84a2da12 Mon Sep 17 00:00:00 2001 From: Jolie <412895109@qq.com> Date: Sat, 27 Dec 2025 18:03:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(message):=20=E6=B7=BB=E5=8A=A0=E9=80=9A?= =?UTF-8?q?=E8=AF=9D=E7=B1=BB=E5=9E=8B=E9=80=89=E6=8B=A9=E5=AF=B9=E8=AF=9D?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 创建了 CallTypeSelectionDialog 组件用于选择通话类型 - 实现了语音通话和视频通话选项的UI界面 - 在聊天页面中集成了通话类型选择功能 - 将原有的视频通话回调替换为显示选择对话框 - 添加了通话类型选择的业务逻辑处理 --- lib/pages/message/chat_page.dart | 64 ++++++++--- .../message/call_type_selection_dialog.dart | 106 ++++++++++++++++++ 2 files changed, 157 insertions(+), 13 deletions(-) create mode 100644 lib/widget/message/call_type_selection_dialog.dart diff --git a/lib/pages/message/chat_page.dart b/lib/pages/message/chat_page.dart index 5603578..f2ee51d 100644 --- a/lib/pages/message/chat_page.dart +++ b/lib/pages/message/chat_page.dart @@ -13,6 +13,7 @@ import '../../model/home/marriage_data.dart'; import '../../../widget/message/chat_input_bar.dart'; import '../../../widget/message/message_item.dart'; import '../../../widget/message/chat_gift_popup.dart'; +import '../../../widget/message/call_type_selection_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'chat_settings_page.dart'; import 'video_call_page.dart'; @@ -135,6 +136,53 @@ class _ChatPageState extends State { ); } + // 显示通话类型选择弹框 + void _showCallTypeSelectionDialog(ChatController controller) { + // 隐藏键盘 + FocusScope.of(context).unfocus(); + SmartDialog.show( + builder: (context) { + return CallTypeSelectionDialog( + onVoiceCall: () async { + // 发起语音通话并跳转到视频通话页面 + await CallManager.instance.initiateCall( + targetUserId: widget.userId, + callType: CallType.voice, + chatController: controller, + ); + // 跳转到视频通话页面 + Get.to(() => VideoCallPage( + targetUserId: widget.userId, + userData: widget.userData ?? controller.userData, + isInitiator: true, + )); + }, + onVideoCall: () async { + // 发起视频通话并跳转到视频通话页面 + await CallManager.instance.initiateCall( + targetUserId: widget.userId, + callType: CallType.video, + chatController: controller, + ); + // 跳转到视频通话页面 + Get.to(() => VideoCallPage( + targetUserId: widget.userId, + userData: widget.userData ?? controller.userData, + isInitiator: true, + )); + }, + ); + }, + alignment: Alignment.bottomCenter, + animationType: SmartAnimationType.centerFade_otherSlide, + maskColor: Colors.black.withOpacity(0.5), + maskWidget: GestureDetector( + onTap: () => SmartDialog.dismiss(), + child: Container(color: Colors.transparent), + ), + ); + } + @override Widget build(BuildContext context) { return GetBuilder( @@ -310,19 +358,9 @@ class _ChatPageState extends State { // ); // }, // 视频通话回调 - onVideoCall: () async { - // 发起视频通话并跳转到视频通话页面 - await CallManager.instance.initiateCall( - targetUserId: widget.userId, - callType: CallType.video, - chatController: controller, - ); - // 跳转到视频通话页面 - Get.to(() => VideoCallPage( - targetUserId: widget.userId, - userData: widget.userData ?? controller.userData, - isInitiator: true, - )); + onVideoCall: () { + // 显示通话类型选择弹框 + _showCallTypeSelectionDialog(controller); }, ), ], diff --git a/lib/widget/message/call_type_selection_dialog.dart b/lib/widget/message/call_type_selection_dialog.dart new file mode 100644 index 0000000..3c793ea --- /dev/null +++ b/lib/widget/message/call_type_selection_dialog.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; + +/// 通话类型选择弹框 +class CallTypeSelectionDialog extends StatelessWidget { + final VoidCallback? onVoiceCall; + final VoidCallback? onVideoCall; + + const CallTypeSelectionDialog({ + super.key, + this.onVoiceCall, + this.onVideoCall, + }); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(12.w), + topRight: Radius.circular(12.w), + ), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + // 语音通话选项 + InkWell( + onTap: () { + SmartDialog.dismiss(); + onVoiceCall?.call(); + }, + child: Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 16.w), + child: Center( + child: Text( + '语音通话 (35玫瑰/分钟)', + style: TextStyle( + fontSize: 16.sp, + color: const Color.fromRGBO(51, 51, 51, 1), + ), + ), + ), + ), + ), + // 分隔线 + Divider( + height: 1, + thickness: 1, + color: const Color.fromRGBO(240, 240, 240, 1), + ), + // 视频通话选项 + InkWell( + onTap: () { + SmartDialog.dismiss(); + onVideoCall?.call(); + }, + child: Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 16.w), + child: Center( + child: Text( + '视频通话 (35玫瑰/分钟)', + style: TextStyle( + fontSize: 16.sp, + color: const Color.fromRGBO(51, 51, 51, 1), + ), + ), + ), + ), + ), + // 分隔线 + Divider( + height: 1, + thickness: 1, + color: const Color.fromRGBO(240, 240, 240, 1), + ), + // 取消选项 + InkWell( + onTap: () { + SmartDialog.dismiss(); + }, + child: Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 16.w), + child: Center( + child: Text( + '取消', + style: TextStyle( + fontSize: 16.sp, + color: const Color.fromRGBO(51, 51, 51, 1), + ), + ), + ), + ), + ), + SizedBox(height: MediaQuery.of(context).padding.bottom), + ], + ), + ); + } +} +