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), + ], + ), + ); + } +} +