Browse Source

feat(message): 添加通话类型选择对话框

- 创建了 CallTypeSelectionDialog 组件用于选择通话类型
- 实现了语音通话和视频通话选项的UI界面
- 在聊天页面中集成了通话类型选择功能
- 将原有的视频通话回调替换为显示选择对话框
- 添加了通话类型选择的业务逻辑处理
master
Jolie 3 months ago
parent
commit
29c6ec1ba9
2 changed files with 157 additions and 13 deletions
  1. 64
      lib/pages/message/chat_page.dart
  2. 106
      lib/widget/message/call_type_selection_dialog.dart

64
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/chat_input_bar.dart';
import '../../../widget/message/message_item.dart'; import '../../../widget/message/message_item.dart';
import '../../../widget/message/chat_gift_popup.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 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'chat_settings_page.dart'; import 'chat_settings_page.dart';
import 'video_call_page.dart'; import 'video_call_page.dart';
@ -135,6 +136,53 @@ class _ChatPageState extends State<ChatPage> {
); );
} }
//
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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GetBuilder<ChatController>( return GetBuilder<ChatController>(
@ -310,19 +358,9 @@ class _ChatPageState extends State<ChatPage> {
// ); // );
// }, // },
// //
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);
}, },
), ),
], ],

106
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),
],
),
);
}
}
Loading…
Cancel
Save