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( return PopScope(
canPop: !isFullScreen, canPop: !isFullScreen,
onPopInvokedWithResult: (bool didPop, Object? result) { onPopInvokedWithResult: (bool didPop, Object? result) {
@@ -180,35 +184,39 @@ class _LiveRoomPageState extends State<LiveRoomPage>
liveRoomCtr: _liveRoomController, liveRoomCtr: _liveRoomController,
onRefresh: _liveRoomController.queryLiveUrl, onRefresh: _liveRoomController.queryLiveUrl,
), ),
danmuWidget: Obx( danmuWidget: !needDm
() => AnimatedOpacity( ? null
opacity: plPlayerController.enableShowDanmaku.value ? 1 : 0, : Obx(
duration: const Duration(milliseconds: 100), () => AnimatedOpacity(
child: DanmakuScreen( opacity: plPlayerController.enableShowDanmaku.value
createdController: (DanmakuController e) { ? 1
plPlayerController.danmakuController = : 0,
_liveRoomController.controller = e; duration: const Duration(milliseconds: 100),
}, child: DanmakuScreen(
option: DanmakuOption( createdController: (DanmakuController e) {
fontSize: _getFontSize(isFullScreen), plPlayerController.danmakuController =
fontWeight: plPlayerController.fontWeight, _liveRoomController.controller = e;
area: plPlayerController.showArea, },
opacity: plPlayerController.danmakuOpacity, option: DanmakuOption(
hideTop: plPlayerController.blockTypes.contains(5), fontSize: _getFontSize(isFullScreen),
hideScroll: plPlayerController.blockTypes.contains(2), fontWeight: plPlayerController.fontWeight,
hideBottom: plPlayerController.blockTypes.contains(4), area: plPlayerController.showArea,
duration: opacity: plPlayerController.danmakuOpacity,
plPlayerController.danmakuDuration / hideTop: plPlayerController.blockTypes.contains(5),
plPlayerController.playbackSpeed, hideScroll: plPlayerController.blockTypes.contains(2),
staticDuration: hideBottom: plPlayerController.blockTypes.contains(4),
plPlayerController.danmakuStaticDuration / duration:
plPlayerController.playbackSpeed, plPlayerController.danmakuDuration /
strokeWidth: plPlayerController.strokeWidth, plPlayerController.playbackSpeed,
lineHeight: plPlayerController.danmakuLineHeight, staticDuration:
plPlayerController.danmakuStaticDuration /
plPlayerController.playbackSpeed,
strokeWidth: plPlayerController.strokeWidth,
lineHeight: plPlayerController.danmakuLineHeight,
),
),
),
), ),
),
),
),
); );
} }
return const SizedBox.shrink(); return const SizedBox.shrink();
@@ -284,33 +292,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
if (_liveRoomController.isPortrait.value) { if (_liveRoomController.isPortrait.value) {
return _buildPP; return _buildPP;
} }
return Column( return _buildPH;
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,
],
);
}, },
) )
: Column( : _buildBodyH,
children: [
Obx(() => _buildAppBar),
_buildBodyH,
],
),
), ),
], ],
), ),
@@ -318,48 +303,62 @@ class _LiveRoomPageState extends State<LiveRoomPage>
); );
} }
Widget get _buildPP => Stack( Widget get _buildPH {
clipBehavior: Clip.none, final isFullScreen = this.isFullScreen;
children: [ final size = Get.size;
_buildAppBar, Widget child = SizedBox(
Column( width: size.width,
children: [ height: isFullScreen ? size.height : size.width * 9 / 16,
Expanded( child: videoPlayerPanel(),
child: Stack( );
clipBehavior: Clip.none, if (isFullScreen) {
children: [ return child;
Obx( }
() => Container( return Column(
margin: isFullScreen children: [
? null _buildAppBar,
: const EdgeInsets.only(top: 56), child,
color: Colors.black, ..._buildBottomWidget,
child: videoPlayerPanel( ],
alignment: isFullScreen ? null : Alignment.topCenter, );
), }
),
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: [
Positioned.fill(child: child),
Positioned(
left: 0,
right: 0,
bottom: 55,
child: SizedBox(
height: Get.height * 0.32,
child: _buildChatWidget(true),
), ),
Obx( ),
() => isFullScreen ],
? const SizedBox.shrink()
: Positioned(
left: 0,
right: 0,
bottom: 55,
child: SizedBox(
height: 125,
child: _buildChatWidget(true),
),
),
),
],
),
), ),
Obx(() => isFullScreen ? const SizedBox.shrink() : _buildInputWidget), ),
], _buildInputWidget,
), ],
], );
); }
PreferredSizeWidget get _buildAppBar { PreferredSizeWidget get _buildAppBar {
final color = Theme.of(context).colorScheme.onSurfaceVariant; final color = Theme.of(context).colorScheme.onSurfaceVariant;
@@ -482,31 +481,40 @@ class _LiveRoomPageState extends State<LiveRoomPage>
double videoWidth = double videoWidth =
clampDouble(context.height / context.width * 1.08, 0.58, 0.75) * clampDouble(context.height / context.width * 1.08, 0.58, 0.75) *
context.width; context.width;
return Expanded( return Obx(
child: Row( () {
children: [ final isFullScreen = this.isFullScreen;
Obx( final size = Get.size;
() { Widget child = Container(
final size = Get.size; margin: EdgeInsets.only(
return Container( bottom: MediaQuery.paddingOf(context).bottom,
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),
);
},
), ),
Expanded( width: isFullScreen ? size.width : videoWidth,
child: Column( height: isFullScreen ? size.height : size.width * 9 / 16,
crossAxisAlignment: CrossAxisAlignment.start, child: videoPlayerPanel(fill: Colors.transparent),
children: _buildBottomWidget, );
if (isFullScreen) {
return child;
}
return Column(
children: [
_buildAppBar,
Expanded(
child: Row(
children: [
child,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _buildBottomWidget,
),
),
],
),
), ),
), ],
], );
), },
); );
} }
@@ -519,7 +527,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
padding: const EdgeInsets.symmetric(vertical: 16), padding: const EdgeInsets.symmetric(vertical: 16),
child: LiveRoomChat( child: LiveRoomChat(
key: chatKey, key: chatKey,
isPP: isPP, isPP: isPP ?? false,
roomId: _roomId, roomId: _roomId,
liveRoomController: _liveRoomController, liveRoomController: _liveRoomController,
), ),

View File

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

View File

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