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,9 +184,13 @@ class _LiveRoomPageState extends State<LiveRoomPage>
liveRoomCtr: _liveRoomController, liveRoomCtr: _liveRoomController,
onRefresh: _liveRoomController.queryLiveUrl, onRefresh: _liveRoomController.queryLiveUrl,
), ),
danmuWidget: Obx( danmuWidget: !needDm
? null
: Obx(
() => AnimatedOpacity( () => AnimatedOpacity(
opacity: plPlayerController.enableShowDanmaku.value ? 1 : 0, opacity: plPlayerController.enableShowDanmaku.value
? 1
: 0,
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
child: DanmakuScreen( child: DanmakuScreen(
createdController: (DanmakuController e) { createdController: (DanmakuController e) {
@@ -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;
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: [ children: [
_buildAppBar, _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: [ children: [
_buildAppBar,
Expanded( Expanded(
child: Stack( child: Stack(
clipBehavior: Clip.none, clipBehavior: Clip.none,
children: [ children: [
Obx( Positioned.fill(child: child),
() => Container( Positioned(
margin: isFullScreen
? null
: const EdgeInsets.only(top: 56),
color: Colors.black,
child: videoPlayerPanel(
alignment: isFullScreen ? null : Alignment.topCenter,
),
),
),
Obx(
() => isFullScreen
? const SizedBox.shrink()
: Positioned(
left: 0, left: 0,
right: 0, right: 0,
bottom: 55, bottom: 55,
child: SizedBox( child: SizedBox(
height: 125, height: Get.height * 0.32,
child: _buildChatWidget(true), 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,23 +481,28 @@ 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: [
Obx(
() { () {
final isFullScreen = this.isFullScreen;
final size = Get.size; final size = Get.size;
return Container( Widget child = Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom, bottom: MediaQuery.paddingOf(context).bottom,
), ),
color: isFullScreen ? Colors.black : null,
width: isFullScreen ? size.width : videoWidth, width: isFullScreen ? size.width : videoWidth,
height: isFullScreen ? size.height : size.width * 9 / 16, height: isFullScreen ? size.height : size.width * 9 / 16,
child: videoPlayerPanel(fill: Colors.transparent), child: videoPlayerPanel(fill: Colors.transparent),
); );
}, if (isFullScreen) {
), return child;
}
return Column(
children: [
_buildAppBar,
Expanded(
child: Row(
children: [
child,
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, 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), 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;