|
|
|
@ -1,6 +1,11 @@ |
|
|
|
import 'package:dating_touchme_app/controller/discover/room_controller.dart'; |
|
|
|
import 'package:dating_touchme_app/controller/overlay_controller.dart'; |
|
|
|
import 'package:dating_touchme_app/generated/assets.dart'; |
|
|
|
import 'package:dating_touchme_app/widget/live/disconnect_mic_dialog.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
|
|
|
|
/// 直播间顶部用户信息与操作区域 |
|
|
|
class LiveRoomUserHeader extends StatelessWidget { |
|
|
|
@ -25,6 +30,11 @@ class LiveRoomUserHeader extends StatelessWidget { |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
// 获取 RoomController 判断当前用户角色 |
|
|
|
final roomController = Get.find<RoomController>(); |
|
|
|
final overlayController = Get.find<OverlayController>(); |
|
|
|
final isHost = roomController.currentRole == CurrentRole.broadcaster; |
|
|
|
|
|
|
|
return Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
|
|
children: [ |
|
|
|
@ -40,20 +50,20 @@ class LiveRoomUserHeader extends StatelessWidget { |
|
|
|
children: [ |
|
|
|
// 支持网络图片和本地资源 |
|
|
|
ClipOval( |
|
|
|
child: Image.network( |
|
|
|
avatarAsset, |
|
|
|
width: 34.w, |
|
|
|
height: 34.w, |
|
|
|
fit: BoxFit.cover, |
|
|
|
errorBuilder: (context, error, stackTrace) { |
|
|
|
return Image.asset( |
|
|
|
Assets.imagesUserAvatar, |
|
|
|
width: 34.w, |
|
|
|
height: 34.w, |
|
|
|
); |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
child: Image.network( |
|
|
|
avatarAsset, |
|
|
|
width: 34.w, |
|
|
|
height: 34.w, |
|
|
|
fit: BoxFit.cover, |
|
|
|
errorBuilder: (context, error, stackTrace) { |
|
|
|
return Image.asset( |
|
|
|
Assets.imagesUserAvatar, |
|
|
|
width: 34.w, |
|
|
|
height: 34.w, |
|
|
|
); |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(width: 7.w), |
|
|
|
Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
@ -61,37 +71,143 @@ class LiveRoomUserHeader extends StatelessWidget { |
|
|
|
children: [ |
|
|
|
Text( |
|
|
|
userName, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 13.w, |
|
|
|
color: Colors.white, |
|
|
|
), |
|
|
|
style: TextStyle(fontSize: 13.w, color: Colors.white), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
GestureDetector( |
|
|
|
onTap: onCloseTap, |
|
|
|
child: Container( |
|
|
|
width: 30.w, |
|
|
|
height: 30.w, |
|
|
|
margin: EdgeInsets.only(right: 15.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(30.w)), |
|
|
|
color: const Color.fromRGBO(0, 0, 0, .3), |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Image.asset( |
|
|
|
closeIconAsset, |
|
|
|
width: 14.w, |
|
|
|
height: 14.w, |
|
|
|
Row( |
|
|
|
children: [ |
|
|
|
// 只有主持人才显示直播设置按钮 |
|
|
|
if (isHost) |
|
|
|
GestureDetector( |
|
|
|
onTap: () { |
|
|
|
SmartDialog.showAttach( |
|
|
|
targetContext: context, |
|
|
|
builder: (context) { |
|
|
|
return Container( |
|
|
|
width: 100.w, |
|
|
|
margin: EdgeInsets.only(left: 160.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: Colors.black.withAlpha(80), |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.w)), |
|
|
|
), |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
SizedBox(height: 15.w), |
|
|
|
GestureDetector( |
|
|
|
onTap: () { |
|
|
|
// 关闭设置弹窗 |
|
|
|
SmartDialog.dismiss(); |
|
|
|
// 弹出解除连麦对话框 |
|
|
|
SmartDialog.show(builder: (context){ |
|
|
|
return DisconnectMicDialog(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
Image.asset(Assets.imagesMicOff, width: 15.w), |
|
|
|
SizedBox(width: 5.w), |
|
|
|
Text( |
|
|
|
'解除连麦', |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.white, |
|
|
|
fontSize: 13.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 15.w), |
|
|
|
GestureDetector( |
|
|
|
onTap: () async { |
|
|
|
// 关闭弹窗 |
|
|
|
SmartDialog.dismiss(); |
|
|
|
// 隐藏 overlay |
|
|
|
overlayController.hide(); |
|
|
|
// 返回上一页 |
|
|
|
Get.back(); |
|
|
|
// 调用结束直播方法 |
|
|
|
await roomController.leaveChannel(); |
|
|
|
}, |
|
|
|
child: Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
Image.asset( |
|
|
|
Assets.imagesExitRoom, |
|
|
|
width: 15.w, |
|
|
|
), |
|
|
|
SizedBox(width: 5.w), |
|
|
|
Text( |
|
|
|
'结束直播', |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.white, |
|
|
|
fontSize: 13.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 15.w), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
}, |
|
|
|
); |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
height: 30.w, |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5.w), |
|
|
|
margin: EdgeInsets.only(right: 15.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(30.w)), |
|
|
|
color: const Color.fromRGBO(0, 0, 0, .3), |
|
|
|
border: Border.all( |
|
|
|
color: const Color.fromRGBO(255, 255, 255, .3), |
|
|
|
width: 1.w, |
|
|
|
), |
|
|
|
), |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Icon( |
|
|
|
Icons.settings_rounded, |
|
|
|
color: Colors.white, |
|
|
|
size: 18.w, |
|
|
|
), |
|
|
|
Text( |
|
|
|
'直播设置', |
|
|
|
style: TextStyle(color: Colors.white, fontSize: 13.sp), |
|
|
|
), |
|
|
|
Icon( |
|
|
|
Icons.keyboard_arrow_down_sharp, |
|
|
|
color: Colors.white, |
|
|
|
size: 18.w, |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
GestureDetector( |
|
|
|
onTap: onCloseTap, |
|
|
|
child: Container( |
|
|
|
width: 30.w, |
|
|
|
height: 30.w, |
|
|
|
margin: EdgeInsets.only(right: 15.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
borderRadius: BorderRadius.all(Radius.circular(30.w)), |
|
|
|
color: const Color.fromRGBO(0, 0, 0, .3), |
|
|
|
), |
|
|
|
child: Center( |
|
|
|
child: Image.asset(closeIconAsset, width: 14.w, height: 14.w), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|