opt live room

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-02 18:41:56 +08:00
parent f0e2a63d11
commit 4b9f251dae
3 changed files with 137 additions and 126 deletions

View File

@@ -152,7 +152,11 @@ class _LiveRoomPageState extends State<LiveRoomPage>
}
}
Widget videoPlayerPanel({Color? fill, Alignment? alignment}) {
Widget videoPlayerPanel({
Color? fill,
Alignment? alignment,
bool needDm = true,
}) {
return PopScope(
canPop: !isFullScreen,
onPopInvokedWithResult: (bool didPop, Object? result) {
@@ -180,9 +184,13 @@ class _LiveRoomPageState extends State<LiveRoomPage>
liveRoomCtr: _liveRoomController,
onRefresh: _liveRoomController.queryLiveUrl,
),
danmuWidget: Obx(
danmuWidget: !needDm
? null
: Obx(
() => AnimatedOpacity(
opacity: plPlayerController.enableShowDanmaku.value ? 1 : 0,
opacity: plPlayerController.enableShowDanmaku.value
? 1
: 0,
duration: const Duration(milliseconds: 100),
child: DanmakuScreen(
createdController: (DanmakuController e) {
@@ -284,33 +292,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
if (_liveRoomController.isPortrait.value) {
return _buildPP;
}
return Column(
children: [
_buildAppBar,
Obx(
() {
final size = Get.size;
return Container(
color: Colors.black,
width: size.width,
height: isFullScreen
? size.height
: size.width * 9 / 16,
child: videoPlayerPanel(),
);
},
),
..._buildBottomWidget,
],
);
return _buildPH;
},
)
: Column(
children: [
Obx(() => _buildAppBar),
_buildBodyH,
],
),
: _buildBodyH,
),
],
),
@@ -318,48 +303,62 @@ class _LiveRoomPageState extends State<LiveRoomPage>
);
}
Widget get _buildPP => Stack(
clipBehavior: Clip.none,
Widget get _buildPH {
final isFullScreen = this.isFullScreen;
final size = Get.size;
Widget child = SizedBox(
width: size.width,
height: isFullScreen ? size.height : size.width * 9 / 16,
child: videoPlayerPanel(),
);
if (isFullScreen) {
return child;
}
return Column(
children: [
_buildAppBar,
Column(
child,
..._buildBottomWidget,
],
);
}
Widget get _buildPP {
final isFullScreen = this.isFullScreen;
final child = videoPlayerPanel(
alignment: isFullScreen ? null : Alignment.topCenter,
needDm: isFullScreen,
);
if (isFullScreen) {
return child;
}
return Column(
children: [
_buildAppBar,
Expanded(
child: Stack(
clipBehavior: Clip.none,
children: [
Obx(
() => Container(
margin: isFullScreen
? null
: const EdgeInsets.only(top: 56),
color: Colors.black,
child: videoPlayerPanel(
alignment: isFullScreen ? null : Alignment.topCenter,
),
),
),
Obx(
() => isFullScreen
? const SizedBox.shrink()
: Positioned(
Positioned.fill(child: child),
Positioned(
left: 0,
right: 0,
bottom: 55,
child: SizedBox(
height: 125,
height: Get.height * 0.32,
child: _buildChatWidget(true),
),
),
),
],
),
),
Obx(() => isFullScreen ? const SizedBox.shrink() : _buildInputWidget),
],
),
_buildInputWidget,
],
);
}
PreferredSizeWidget get _buildAppBar {
final color = Theme.of(context).colorScheme.onSurfaceVariant;
@@ -482,23 +481,28 @@ class _LiveRoomPageState extends State<LiveRoomPage>
double videoWidth =
clampDouble(context.height / context.width * 1.08, 0.58, 0.75) *
context.width;
return Expanded(
child: Row(
children: [
Obx(
return Obx(
() {
final isFullScreen = this.isFullScreen;
final size = Get.size;
return Container(
Widget child = Container(
margin: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom,
),
color: isFullScreen ? Colors.black : null,
width: isFullScreen ? size.width : videoWidth,
height: isFullScreen ? size.height : size.width * 9 / 16,
child: videoPlayerPanel(fill: Colors.transparent),
);
},
),
if (isFullScreen) {
return child;
}
return Column(
children: [
_buildAppBar,
Expanded(
child: Row(
children: [
child,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -507,6 +511,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
),
],
),
),
],
);
},
);
}
@@ -519,7 +527,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
padding: const EdgeInsets.symmetric(vertical: 16),
child: LiveRoomChat(
key: chatKey,
isPP: isPP,
isPP: isPP ?? false,
roomId: _roomId,
liveRoomController: _liveRoomController,
),

View File

@@ -11,16 +11,22 @@ class LiveRoomChat extends StatelessWidget {
super.key,
required this.roomId,
required this.liveRoomController,
this.isPP,
this.isPP = false,
});
final int roomId;
final LiveRoomController liveRoomController;
final bool? isPP;
final bool isPP;
bool get disableAutoScroll => liveRoomController.disableAutoScroll.value;
@override
Widget build(BuildContext context) {
late final bg = isPP
? Colors.black.withValues(alpha: 0.4)
: const Color(0x15FFFFFF);
late final nameColor = isPP
? Colors.white.withValues(alpha: 0.9)
: Colors.white.withValues(alpha: 0.6);
return Stack(
clipBehavior: Clip.none,
children: [
@@ -42,9 +48,7 @@ class LiveRoomChat extends StatelessWidget {
vertical: 5,
),
decoration: BoxDecoration(
color: isPP == true
? Colors.black.withValues(alpha: 0.3)
: const Color(0x15FFFFFF),
color: bg,
borderRadius: const BorderRadius.all(Radius.circular(18)),
),
child: Text.rich(
@@ -53,7 +57,7 @@ class LiveRoomChat extends StatelessWidget {
TextSpan(
text: '${item['name']}: ',
style: TextStyle(
color: Colors.white.withValues(alpha: 0.6),
color: nameColor,
fontSize: 14,
),
recognizer: TapGestureRecognizer()

View File

@@ -1317,7 +1317,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
},
),
// if (BuildConfig.isDebug)
// Positioned(
// right: 25,
// top: 125,
@@ -1325,7 +1324,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
// onPressed: () {
// transformationController.value = Matrix4.identity()
// ..translate(0.5, 0.5)
// ..scale(1.2)
// ..scale(0.5)
// ..translate(-0.5, -0.5);
// showRestoreScaleBtn.value = true;