|
|
|
@ -107,6 +107,7 @@ class _LiveRoomPageState extends State<LiveRoomPage> { |
|
|
|
_messageController.dispose(); |
|
|
|
_inputDialogController.dispose(); |
|
|
|
_inputDialogFocusNode.dispose(); |
|
|
|
SmartDialog.dismiss(); |
|
|
|
// 退出房间时清空RTM消息 |
|
|
|
if (Get.isRegistered<RoomController>()) { |
|
|
|
final roomController = Get.find<RoomController>(); |
|
|
|
@ -183,9 +184,14 @@ class _LiveRoomPageState extends State<LiveRoomPage> { |
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
// 刷新玫瑰数量 |
|
|
|
await _roomController.getVirtualAccount(); |
|
|
|
_roomController.setDialogDismiss(true); |
|
|
|
SmartDialog.show( |
|
|
|
backType: SmartBackType.block, |
|
|
|
alignment: Alignment.bottomCenter, |
|
|
|
maskColor: TDTheme.of(context).fontGyColor2, |
|
|
|
onDismiss: () { |
|
|
|
_roomController.setDialogDismiss(false); |
|
|
|
}, |
|
|
|
builder: (_) => Obx(() { |
|
|
|
// 优先使用 API 返回的 giftProducts,如果为空则使用后备列表 |
|
|
|
final giftProducts = _roomController.giftProducts; |
|
|
|
@ -204,9 +210,13 @@ class _LiveRoomPageState extends State<LiveRoomPage> { |
|
|
|
void _showRechargePopup() { |
|
|
|
// 隐藏键盘 |
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
_roomController.setDialogDismiss(true); |
|
|
|
SmartDialog.show( |
|
|
|
alignment: Alignment.bottomCenter, |
|
|
|
maskColor: TDTheme.of(context).fontGyColor2, |
|
|
|
onDismiss: (){ |
|
|
|
_roomController.setDialogDismiss(false); |
|
|
|
}, |
|
|
|
builder: (_) => const LiveRechargePopup(), |
|
|
|
); |
|
|
|
} |
|
|
|
@ -233,151 +243,164 @@ class _LiveRoomPageState extends State<LiveRoomPage> { |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
return Obx(() { |
|
|
|
return PopScope( |
|
|
|
canPop: !_roomController.isDialogShowing.value, |
|
|
|
onPopInvokedWithResult: (bool didPop, Object? result) async { |
|
|
|
// SmartDialog.dismiss(); |
|
|
|
// print('256>22>>' + didPop.toString()); |
|
|
|
// if (didPop) return; |
|
|
|
|
|
|
|
return PopScope( |
|
|
|
onPopInvokedWithResult: (bool didPop, Object? result) async { |
|
|
|
SmartDialog.dismiss(); |
|
|
|
// 退出房间时清空RTM消息 |
|
|
|
if (Get.isRegistered<RoomController>()) { |
|
|
|
final roomController = Get.find<RoomController>(); |
|
|
|
roomController.chatMessages.clear(); |
|
|
|
} |
|
|
|
// 如果还没有执行 pop,手动调用 Get.back() |
|
|
|
if (!didPop) { |
|
|
|
Get.back(); |
|
|
|
} |
|
|
|
// 等待页面关闭后再显示小窗口,确保小窗口能正确显示 |
|
|
|
Future.delayed(const Duration(milliseconds: 200), () { |
|
|
|
_overlayController.show(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Scaffold( |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
body: Stack( |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
decoration: BoxDecoration( |
|
|
|
gradient: LinearGradient( |
|
|
|
begin: Alignment.topCenter, |
|
|
|
end: Alignment.bottomCenter, |
|
|
|
colors: [ |
|
|
|
Color.fromRGBO(248, 242, 255, 1), |
|
|
|
Color.fromRGBO(247, 247, 247, 1), |
|
|
|
], |
|
|
|
// 如果有对话框显示,关闭对话框 |
|
|
|
if (_roomController.isDialogShowing.value) { |
|
|
|
SmartDialog.dismiss(); |
|
|
|
return; // 阻止页面返回 |
|
|
|
} |
|
|
|
// 退出房间时清空RTM消息 |
|
|
|
if (Get.isRegistered<RoomController>()) { |
|
|
|
final roomController = Get.find<RoomController>(); |
|
|
|
roomController.chatMessages.clear(); |
|
|
|
} |
|
|
|
// 如果还没有执行 pop,手动调用 Get.back() |
|
|
|
if (!didPop) { |
|
|
|
Get.back(); |
|
|
|
} |
|
|
|
// 等待页面关闭后再显示小窗口,确保小窗口能正确显示 |
|
|
|
Future.delayed(const Duration(milliseconds: 200), () { |
|
|
|
_overlayController.show(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Scaffold( |
|
|
|
resizeToAvoidBottomInset: false, |
|
|
|
body: Stack( |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
decoration: BoxDecoration( |
|
|
|
gradient: LinearGradient( |
|
|
|
begin: Alignment.topCenter, |
|
|
|
end: Alignment.bottomCenter, |
|
|
|
colors: [ |
|
|
|
Color.fromRGBO(248, 242, 255, 1), |
|
|
|
Color.fromRGBO(247, 247, 247, 1), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Container( |
|
|
|
decoration: const BoxDecoration( |
|
|
|
gradient: LinearGradient( |
|
|
|
begin: Alignment.bottomCenter, |
|
|
|
end: Alignment.topCenter, |
|
|
|
colors: [ |
|
|
|
Color.fromRGBO(19, 16, 47, 1), |
|
|
|
Color.fromRGBO(19, 16, 47, 1), |
|
|
|
], |
|
|
|
Container( |
|
|
|
decoration: const BoxDecoration( |
|
|
|
gradient: LinearGradient( |
|
|
|
begin: Alignment.bottomCenter, |
|
|
|
end: Alignment.topCenter, |
|
|
|
colors: [ |
|
|
|
Color.fromRGBO(19, 16, 47, 1), |
|
|
|
Color.fromRGBO(19, 16, 47, 1), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
SizedBox(height: 10.w), |
|
|
|
Obx(() { |
|
|
|
final detail = _roomController.rtcChannelDetail.value; |
|
|
|
final anchorInfo = detail?.anchorInfo; |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
top: MediaQuery.of(context).padding.top, |
|
|
|
), |
|
|
|
child: Column( |
|
|
|
children: [ |
|
|
|
SizedBox(height: 10.w), |
|
|
|
Obx(() { |
|
|
|
final detail = _roomController.rtcChannelDetail.value; |
|
|
|
final anchorInfo = detail?.anchorInfo; |
|
|
|
|
|
|
|
final userName = anchorInfo?.nickName ?? '用户'; |
|
|
|
final avatarAsset = anchorInfo?.profilePhoto ?? Assets.imagesUserAvatar; |
|
|
|
const popularityText = '0'; // TODO: 使用真实数据 |
|
|
|
final userName = anchorInfo?.nickName ?? '用户'; |
|
|
|
final avatarAsset = |
|
|
|
anchorInfo?.profilePhoto ?? Assets.imagesUserAvatar; |
|
|
|
const popularityText = '0'; // TODO: 使用真实数据 |
|
|
|
|
|
|
|
return LiveRoomUserHeader( |
|
|
|
userName: userName, |
|
|
|
popularityText: popularityText, |
|
|
|
avatarAsset: avatarAsset, |
|
|
|
onCloseTap: () { |
|
|
|
SmartDialog.dismiss(); |
|
|
|
// 退出房间时清空RTM消息 |
|
|
|
if (Get.isRegistered<RoomController>()) { |
|
|
|
final roomController = Get.find<RoomController>(); |
|
|
|
roomController.chatMessages.clear(); |
|
|
|
} |
|
|
|
Get.back(); |
|
|
|
// 等待页面关闭后再显示小窗口,确保小窗口能正确显示 |
|
|
|
Future.delayed(const Duration(milliseconds: 200), () { |
|
|
|
_overlayController.show(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
); |
|
|
|
}), |
|
|
|
SizedBox(height: 7.w), |
|
|
|
LiveRoomAnchorShowcase(), |
|
|
|
SizedBox(height: 5.w), |
|
|
|
const LiveRoomActiveSpeaker(), |
|
|
|
SizedBox(height: 9.w), |
|
|
|
Expanded(child: const LiveRoomNoticeChatPanel()), |
|
|
|
// 根据键盘状态显示/隐藏 LiveRoomActionBar |
|
|
|
if (MediaQuery.of(context).viewInsets.bottom == 0) |
|
|
|
SafeArea( |
|
|
|
top: false, |
|
|
|
child: Padding( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
bottom: 10.w, |
|
|
|
left: 0, |
|
|
|
right: 0, |
|
|
|
), |
|
|
|
child: LiveRoomActionBar( |
|
|
|
messageController: _messageController, |
|
|
|
onMessageChanged: (value) { |
|
|
|
message = value; |
|
|
|
}, |
|
|
|
onSendTap: _sendMessage, |
|
|
|
onGiftTap: _showGiftPopup, |
|
|
|
onChargeTap: _showRechargePopup, |
|
|
|
onInputTap: _openInputDialog, |
|
|
|
return LiveRoomUserHeader( |
|
|
|
userName: userName, |
|
|
|
popularityText: popularityText, |
|
|
|
avatarAsset: avatarAsset, |
|
|
|
onCloseTap: () { |
|
|
|
SmartDialog.dismiss(); |
|
|
|
// 退出房间时清空RTM消息 |
|
|
|
if (Get.isRegistered<RoomController>()) { |
|
|
|
final roomController = Get.find<RoomController>(); |
|
|
|
roomController.chatMessages.clear(); |
|
|
|
} |
|
|
|
Get.back(); |
|
|
|
// 等待页面关闭后再显示小窗口,确保小窗口能正确显示 |
|
|
|
Future.delayed(const Duration(milliseconds: 200), () { |
|
|
|
_overlayController.show(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
); |
|
|
|
}), |
|
|
|
SizedBox(height: 7.w), |
|
|
|
LiveRoomAnchorShowcase(), |
|
|
|
SizedBox(height: 5.w), |
|
|
|
const LiveRoomActiveSpeaker(), |
|
|
|
SizedBox(height: 9.w), |
|
|
|
Expanded(child: const LiveRoomNoticeChatPanel()), |
|
|
|
// 根据键盘状态显示/隐藏 LiveRoomActionBar |
|
|
|
if (MediaQuery.of(context).viewInsets.bottom == 0) |
|
|
|
SafeArea( |
|
|
|
top: false, |
|
|
|
child: Padding( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
bottom: 10.w, |
|
|
|
left: 0, |
|
|
|
right: 0, |
|
|
|
), |
|
|
|
child: LiveRoomActionBar( |
|
|
|
messageController: _messageController, |
|
|
|
onMessageChanged: (value) { |
|
|
|
message = value; |
|
|
|
}, |
|
|
|
onSendTap: _sendMessage, |
|
|
|
onGiftTap: _showGiftPopup, |
|
|
|
onChargeTap: _showRechargePopup, |
|
|
|
onInputTap: _openInputDialog, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
// SVGA 动画播放组件 |
|
|
|
const SvgaPlayerWidget(), |
|
|
|
// 输入对话框 |
|
|
|
if (_showInputDialog) ...[ |
|
|
|
// 遮罩层,点击时隐藏对话框和键盘(放在对话框下方,对话框会在上面拦截点击) |
|
|
|
Positioned.fill( |
|
|
|
child: GestureDetector( |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
onTap: () { |
|
|
|
// 隐藏键盘 |
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
// 隐藏对话框 |
|
|
|
_hideInputDialog(); |
|
|
|
}, |
|
|
|
child: Container(color: Colors.transparent), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
// 输入对话框(放在遮罩层上面,会自动拦截点击事件) |
|
|
|
AnimatedPositioned( |
|
|
|
duration: const Duration(milliseconds: 200), |
|
|
|
curve: Curves.easeOut, |
|
|
|
left: 0, |
|
|
|
right: 0, |
|
|
|
bottom: MediaQuery.of(context).viewInsets.bottom, |
|
|
|
child: _InputDialogWidget( |
|
|
|
controller: _inputDialogController, |
|
|
|
focusNode: _inputDialogFocusNode, |
|
|
|
onSend: _sendInputDialogMessage, |
|
|
|
onClose: _hideInputDialog, |
|
|
|
// SVGA 动画播放组件 |
|
|
|
const SvgaPlayerWidget(), |
|
|
|
// 输入对话框 |
|
|
|
if (_showInputDialog) ...[ |
|
|
|
// 遮罩层,点击时隐藏对话框和键盘(放在对话框下方,对话框会在上面拦截点击) |
|
|
|
Positioned.fill( |
|
|
|
child: GestureDetector( |
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
onTap: () { |
|
|
|
// 隐藏键盘 |
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
// 隐藏对话框 |
|
|
|
_hideInputDialog(); |
|
|
|
}, |
|
|
|
child: Container(color: Colors.transparent), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
// 输入对话框(放在遮罩层上面,会自动拦截点击事件) |
|
|
|
AnimatedPositioned( |
|
|
|
duration: const Duration(milliseconds: 200), |
|
|
|
curve: Curves.easeOut, |
|
|
|
left: 0, |
|
|
|
right: 0, |
|
|
|
bottom: MediaQuery.of(context).viewInsets.bottom, |
|
|
|
child: _InputDialogWidget( |
|
|
|
controller: _inputDialogController, |
|
|
|
focusNode: _inputDialogFocusNode, |
|
|
|
onSend: _sendInputDialogMessage, |
|
|
|
onClose: _hideInputDialog, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
], |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|