diff --git a/lib/pages/discover/live_room_page.dart b/lib/pages/discover/live_room_page.dart index b4fb318..fe13408 100644 --- a/lib/pages/discover/live_room_page.dart +++ b/lib/pages/discover/live_room_page.dart @@ -5,6 +5,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:tdesign_flutter/tdesign_flutter.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:dating_touchme_app/widget/live/live_room_user_header.dart'; import 'package:dating_touchme_app/widget/live/live_room_anchor_showcase.dart'; import 'package:dating_touchme_app/widget/live/live_room_active_speaker.dart'; @@ -64,10 +65,14 @@ class _LiveRoomPageState extends State { ? Get.find() : Get.put(RoomController()); _overlayController = Get.find(); + // 启用屏幕常亮 + WakelockPlus.enable(); } @override void dispose() { + // 禁用屏幕常亮 + WakelockPlus.disable(); _messageController.dispose(); super.dispose(); } diff --git a/lib/widget/live/live_room_anchor_showcase.dart b/lib/widget/live/live_room_anchor_showcase.dart index 68f74aa..b02883a 100644 --- a/lib/widget/live/live_room_anchor_showcase.dart +++ b/lib/widget/live/live_room_anchor_showcase.dart @@ -197,99 +197,97 @@ class _LiveRoomAnchorShowcaseState extends State { child: SizedBox( width: 177.w, height: 175.w, - child: userInfo != null && userInfo.uid != null && joined && engine != null ? AgoraVideoView( - controller: isCurrentUser - ? VideoViewController( - rtcEngine: engine, - canvas: const VideoCanvas(uid: 0), - ) - : VideoViewController.remote( - rtcEngine: engine, - canvas: VideoCanvas(uid: userInfo.uid!), - connection: RtcConnection( - channelId: _rtcManager.currentChannelId ?? '', - ), - ), - ) - : Stack( - children: [ - Image.asset(isLeft ? Assets.imagesMaleEmpty : Assets.imagesFemaleEmpty), - userInfo != null ? Positioned( - top: 5.w, - right: 5.w, - child: Container( + child: userInfo != null && userInfo.uid != null && joined && engine != null ? Stack( + children: [ + Positioned( + top: 5.w, + right: 5.w, + child: Container( + width: 20.w, + height: 20.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.w)), + ), + child: Center( + child: Image.asset( + Assets.imagesGiftIcon, + width: 19.w, + height: 19.w, + ), + ), + ), + ), + Positioned( + bottom: 5.w, + right: 5.w, + child: Container( + width: 47.w, + height: 20.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20.w)), + color: Colors.white, + ), + child: Center( + child: Text( + "加好友", + style: TextStyle( + fontSize: 11.w, + color: const Color.fromRGBO(117, 98, 249, 1), + ), + ), + ), + ), + ), + Positioned( + left: 5.w, + bottom: 5.w, + child: Row( + children: [ + Container( width: 20.w, height: 20.w, decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.w)), + borderRadius: BorderRadius.all(Radius.circular(4.w)), + color: const Color.fromRGBO(0, 0, 0, .65), ), child: Center( child: Image.asset( - Assets.imagesGiftIcon, - width: 19.w, - height: 19.w, + userInfo.isMicrophoneOn + ? Assets.imagesMicOpen + : Assets.imagesMicClose, + width: 10.w, + height: 11.w, ), ), ), - ) : const SizedBox(), - userInfo != null ? Positioned( - bottom: 5.w, - right: 5.w, - child: Container( - width: 47.w, - height: 20.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20.w)), + SizedBox(width: 5.w), + Text( + userInfo.nickName, + style: TextStyle( + fontSize: 11.w, color: Colors.white, - ), - child: Center( - child: Text( - "加好友", - style: TextStyle( - fontSize: 11.w, - color: const Color.fromRGBO(117, 98, 249, 1), - ), - ), - ), - ), - ) : const SizedBox(), - if (userInfo != null) - Positioned( - left: 5.w, - bottom: 5.w, - child: Row( - children: [ - Container( - width: 20.w, - height: 20.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(4.w)), - color: const Color.fromRGBO(0, 0, 0, .65), - ), - child: Center( - child: Image.asset( - userInfo.isMicrophoneOn - ? Assets.imagesMicOpen - : Assets.imagesMicClose, - width: 10.w, - height: 11.w, - ), - ), - ), - SizedBox(width: 5.w), - Text( - userInfo.nickName, - style: TextStyle( - fontSize: 11.w, - color: Colors.white, - fontWeight: FontWeight.w500, - ), - ), - ], + fontWeight: FontWeight.w500, ), ), - ], + ], + ), ), + AgoraVideoView( + controller: isCurrentUser + ? VideoViewController( + rtcEngine: engine, + canvas: const VideoCanvas(uid: 0), + ) + : VideoViewController.remote( + rtcEngine: engine, + canvas: VideoCanvas(uid: userInfo.uid!), + connection: RtcConnection( + channelId: _rtcManager.currentChannelId ?? '', + ), + ), + ) + ], + ) : Image.asset(isLeft ? Assets.imagesMaleEmpty : Assets.imagesFemaleEmpty), ), ), ], diff --git a/pubspec.lock b/pubspec.lock index b283a62..97cd0f3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1674,7 +1674,7 @@ packages: source: hosted version: "15.0.2" wakelock_plus: - dependency: transitive + dependency: "direct main" description: name: wakelock_plus sha256: "9296d40c9adbedaba95d1e704f4e0b434be446e2792948d0e4aa977048104228" diff --git a/pubspec.yaml b/pubspec.yaml index 6f87445..31033b9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,6 +75,7 @@ dependencies: image_picker_android: ^0.8.12+23 flutter_svga: ^0.0.8 url_launcher: ^6.3.2 + wakelock_plus: ^1.4.0 dev_dependencies: flutter_test: