Browse Source
feat(im): 添加视频通话邀请弹框功能
feat(im): 添加视频通话邀请弹框功能
- 在IMManager中添加视频通话消息处理逻辑 - 解析CALL类型消息并显示视频通话邀请弹框 - 实现通话邀请的接听、拒绝和跳转功能 - 添加VideoCallInviteDialog组件用于显示通话邀请 - 优化消息通知弹框的边距样式 - 在pubspec.yaml中添加必要的资源文件路径配置master
4 changed files with 322 additions and 4 deletions
Split View
Diff Options
-
159lib/im/im_manager.dart
-
2lib/widget/message/message_notification_dialog.dart
-
157lib/widget/message/video_call_invite_dialog.dart
-
8pubspec.yaml
@ -0,0 +1,157 @@ |
|||
import 'package:cached_network_image/cached_network_image.dart'; |
|||
import 'package:dating_touchme_app/generated/assets.dart'; |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|||
|
|||
/// 视频通话邀请弹框 |
|||
class VideoCallInviteDialog extends StatelessWidget { |
|||
final String avatarUrl; |
|||
final String nickName; |
|||
final VoidCallback? onTap; // 点击弹框主体区域(只跳转,不接通) |
|||
final VoidCallback? onAccept; // 点击接通按钮(接通并跳转) |
|||
final VoidCallback? onReject; // 点击挂断按钮(拒绝) |
|||
|
|||
const VideoCallInviteDialog({ |
|||
super.key, |
|||
required this.avatarUrl, |
|||
required this.nickName, |
|||
this.onTap, |
|||
this.onAccept, |
|||
this.onReject, |
|||
}); |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
return GestureDetector( |
|||
onTap: onTap, |
|||
child: Container( |
|||
margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 30.h), |
|||
padding: EdgeInsets.all(16.w), |
|||
decoration: BoxDecoration( |
|||
color: Colors.black.withOpacity(0.9), |
|||
borderRadius: BorderRadius.circular(16.w), |
|||
boxShadow: [ |
|||
BoxShadow( |
|||
color: Colors.black.withOpacity(0.3), |
|||
blurRadius: 12, |
|||
offset: Offset(0, 4.h), |
|||
), |
|||
], |
|||
), |
|||
child: Row( |
|||
children: [ |
|||
// 左侧:头像和昵称、文案 |
|||
Expanded( |
|||
child: Row( |
|||
children: [ |
|||
// 头像 |
|||
ClipOval( |
|||
child: avatarUrl.isNotEmpty |
|||
? CachedNetworkImage( |
|||
imageUrl: avatarUrl, |
|||
width: 56.w, |
|||
height: 56.w, |
|||
fit: BoxFit.cover, |
|||
placeholder: (context, url) => Image.asset( |
|||
Assets.imagesUserAvatar, |
|||
width: 56.w, |
|||
height: 56.w, |
|||
fit: BoxFit.cover, |
|||
), |
|||
errorWidget: (context, url, error) => Image.asset( |
|||
Assets.imagesUserAvatar, |
|||
width: 56.w, |
|||
height: 56.w, |
|||
fit: BoxFit.cover, |
|||
), |
|||
) |
|||
: Image.asset( |
|||
Assets.imagesUserAvatar, |
|||
width: 56.w, |
|||
height: 56.w, |
|||
fit: BoxFit.cover, |
|||
), |
|||
), |
|||
SizedBox(width: 12.w), |
|||
// 昵称和文案 |
|||
Expanded( |
|||
child: Column( |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: [ |
|||
// 昵称 |
|||
Text( |
|||
nickName, |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
fontWeight: FontWeight.w600, |
|||
color: Colors.white, |
|||
), |
|||
maxLines: 1, |
|||
overflow: TextOverflow.ellipsis, |
|||
), |
|||
SizedBox(height: 4.h), |
|||
// 邀请文案 |
|||
Text( |
|||
'邀请你视频通话', |
|||
style: TextStyle( |
|||
fontSize: 13.sp, |
|||
color: Colors.white.withOpacity(0.8), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
SizedBox(width: 12.w), |
|||
// 右侧:接通和挂断按钮 |
|||
Row( |
|||
children: [ |
|||
// 挂断按钮 |
|||
GestureDetector( |
|||
onTap: onReject, |
|||
behavior: HitTestBehavior.opaque, |
|||
child: Container( |
|||
width: 44.w, |
|||
height: 44.w, |
|||
decoration: BoxDecoration( |
|||
color: Colors.red, |
|||
shape: BoxShape.circle, |
|||
), |
|||
child: Icon( |
|||
Icons.call_end, |
|||
color: Colors.white, |
|||
size: 24.w, |
|||
), |
|||
), |
|||
), |
|||
SizedBox(width: 12.w), |
|||
// 接通按钮 |
|||
GestureDetector( |
|||
onTap: onAccept, |
|||
behavior: HitTestBehavior.opaque, |
|||
child: Container( |
|||
width: 44.w, |
|||
height: 44.w, |
|||
decoration: BoxDecoration( |
|||
color: Colors.green, |
|||
shape: BoxShape.circle, |
|||
), |
|||
child: Icon( |
|||
Icons.call, |
|||
color: Colors.white, |
|||
size: 24.w, |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
], |
|||
), |
|||
), |
|||
); |
|||
} |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save