Browse Source

feat(live): 优化直播间主播展示界面并添加屏幕常亮功能

- 重构主播展示界面,调整UI布局结构
- 在直播间页面集成wakelock_plus插件
- 实现进入直播间时启用屏幕常亮
- 实现离开直播间时禁用屏幕常亮
- 更新pubspec.yaml添加wakelock_plus依赖
- 升级wakelock_plus为直接主依赖项
ios
Jolie 4 months ago
parent
commit
38325671b1
4 changed files with 85 additions and 81 deletions
  1. 5
      lib/pages/discover/live_room_page.dart
  2. 158
      lib/widget/live/live_room_anchor_showcase.dart
  3. 2
      pubspec.lock
  4. 1
      pubspec.yaml

5
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<LiveRoomPage> {
? Get.find<RoomController>()
: Get.put(RoomController());
_overlayController = Get.find<OverlayController>();
//
WakelockPlus.enable();
}
@override
void dispose() {
//
WakelockPlus.disable();
_messageController.dispose();
super.dispose();
}

158
lib/widget/live/live_room_anchor_showcase.dart

@ -197,99 +197,97 @@ class _LiveRoomAnchorShowcaseState extends State<LiveRoomAnchorShowcase> {
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),
),
),
],

2
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"

1
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:

Loading…
Cancel
Save