mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-16 07:06:14 +08:00
mod: horizontal live room
Closes #62 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:PiliPlus/http/live.dart';
|
import 'package:PiliPlus/http/live.dart';
|
||||||
import 'package:PiliPlus/pages/live_room/widgets/chat.dart';
|
import 'package:PiliPlus/pages/live_room/widgets/chat.dart';
|
||||||
@@ -73,11 +74,11 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
_updateFontSize();
|
_updateFontSize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (context.orientation == Orientation.landscape) {
|
// if (context.orientation == Orientation.landscape) {
|
||||||
plPlayerController.triggerFullScreen(status: true);
|
// plPlayerController.triggerFullScreen(status: true);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateFontSize() async {
|
void _updateFontSize() async {
|
||||||
@@ -130,12 +131,18 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget get videoPlayerPanel {
|
final GlobalKey videoPlayerKey = GlobalKey();
|
||||||
|
final GlobalKey playerKey = GlobalKey();
|
||||||
|
|
||||||
|
Widget videoPlayerPanel([Color? fill]) {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
|
key: videoPlayerKey,
|
||||||
future: _futureBuilderFuture,
|
future: _futureBuilderFuture,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
if (snapshot.hasData && snapshot.data['status']) {
|
if (snapshot.hasData && snapshot.data['status']) {
|
||||||
return PLVideoPlayer(
|
return PLVideoPlayer(
|
||||||
|
key: playerKey,
|
||||||
|
fill: fill,
|
||||||
plPlayerController: plPlayerController,
|
plPlayerController: plPlayerController,
|
||||||
bottomControl: BottomControl(
|
bottomControl: BottomControl(
|
||||||
controller: plPlayerController,
|
controller: plPlayerController,
|
||||||
@@ -176,11 +183,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget get childWhenDisabled {
|
Widget childWhenDisabled(bool isPortrait) {
|
||||||
return Scaffold(
|
return ColoredBox(
|
||||||
primary: true,
|
color: Colors.black,
|
||||||
backgroundColor: Colors.black,
|
child: Stack(
|
||||||
body: Stack(
|
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
@@ -221,16 +227,56 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Column(
|
isPortrait
|
||||||
|
? Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
AppBar(
|
_buildAppBar,
|
||||||
|
..._buildBodyP,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
children: [
|
||||||
|
_buildAppBar,
|
||||||
|
_buildBodyH,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_updateFontSize();
|
||||||
|
});
|
||||||
|
return OrientationBuilder(
|
||||||
|
builder: (BuildContext context, Orientation orientation) {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
return PiPSwitcher(
|
||||||
|
getChildWhenDisabled: () =>
|
||||||
|
childWhenDisabled(orientation == Orientation.portrait),
|
||||||
|
getChildWhenEnabled: () => videoPlayerPanel,
|
||||||
|
floating: floating,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return childWhenDisabled(orientation == Orientation.portrait);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color get _color => Color(0xFFEEEEEE);
|
||||||
|
|
||||||
|
Widget get _buildAppBar => AppBar(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
titleTextStyle: TextStyle(color: Colors.white),
|
titleTextStyle: TextStyle(color: Colors.white),
|
||||||
toolbarHeight:
|
toolbarHeight:
|
||||||
MediaQuery.of(context).orientation == Orientation.portrait
|
MediaQuery.of(context).orientation == Orientation.portrait ? 56 : 0,
|
||||||
? 56
|
|
||||||
: 0,
|
|
||||||
title: FutureBuilder(
|
title: FutureBuilder(
|
||||||
future: _futureBuilder,
|
future: _futureBuilder,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@@ -245,8 +291,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_node.unfocus();
|
_node.unfocus();
|
||||||
dynamic uid = _liveRoomController
|
dynamic uid =
|
||||||
.roomInfoH5.value.roomInfo?.uid;
|
_liveRoomController.roomInfoH5.value.roomInfo?.uid;
|
||||||
Get.toNamed(
|
Get.toNamed(
|
||||||
'/member?mid=$uid',
|
'/member?mid=$uid',
|
||||||
arguments: {
|
arguments: {
|
||||||
@@ -258,8 +304,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
width: 34,
|
width: 34,
|
||||||
height: 34,
|
height: 34,
|
||||||
type: 'avatar',
|
type: 'avatar',
|
||||||
src: _liveRoomController.roomInfoH5.value
|
src: _liveRoomController
|
||||||
.anchorInfo!.baseInfo!.face,
|
.roomInfoH5.value.anchorInfo!.baseInfo!.face,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
@@ -267,13 +313,12 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
_liveRoomController.roomInfoH5.value
|
_liveRoomController
|
||||||
.anchorInfo!.baseInfo!.uname!,
|
.roomInfoH5.value.anchorInfo!.baseInfo!.uname!,
|
||||||
style: const TextStyle(fontSize: 14),
|
style: const TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 1),
|
const SizedBox(height: 1),
|
||||||
if (_liveRoomController
|
if (_liveRoomController.roomInfoH5.value.watchedShow !=
|
||||||
.roomInfoH5.value.watchedShow !=
|
|
||||||
null)
|
null)
|
||||||
Text(
|
Text(
|
||||||
_liveRoomController.roomInfoH5.value
|
_liveRoomController.roomInfoH5.value
|
||||||
@@ -312,17 +357,67 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
|
||||||
|
Widget get _buildBodyH {
|
||||||
|
double videoWidth =
|
||||||
|
max(context.height / context.width * 1.04, 0.58) * context.width;
|
||||||
|
return Expanded(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => PopScope(
|
||||||
|
canPop: plPlayerController.isFullScreen.value != true,
|
||||||
|
onPopInvokedWithResult: (bool didPop, Object? result) {
|
||||||
|
if (plPlayerController.isFullScreen.value == true) {
|
||||||
|
plPlayerController.triggerFullScreen(status: false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Listener(
|
||||||
|
onPointerDown: (_) {
|
||||||
|
_node.unfocus();
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
width: plPlayerController.isFullScreen.value
|
||||||
|
? Get.size.width
|
||||||
|
: videoWidth,
|
||||||
|
height: plPlayerController.isFullScreen.value
|
||||||
|
? Get.size.height
|
||||||
|
: Get.size.width * 9 / 16,
|
||||||
|
child: MediaQuery.removePadding(
|
||||||
|
removeRight: true,
|
||||||
|
context: context,
|
||||||
|
child: videoPlayerPanel(Colors.transparent),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
body: SafeArea(
|
||||||
|
left: false,
|
||||||
|
top: false,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: _buildBottomWidget,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> get _buildBodyP => [
|
||||||
Obx(
|
Obx(
|
||||||
() => PopScope(
|
() => PopScope(
|
||||||
canPop: plPlayerController.isFullScreen.value != true,
|
canPop: plPlayerController.isFullScreen.value != true,
|
||||||
onPopInvokedWithResult: (bool didPop, Object? result) {
|
onPopInvokedWithResult: (bool didPop, Object? result) {
|
||||||
if (plPlayerController.isFullScreen.value == true) {
|
if (plPlayerController.isFullScreen.value == true) {
|
||||||
plPlayerController.triggerFullScreen(status: false);
|
plPlayerController.triggerFullScreen(status: false);
|
||||||
// if (MediaQuery.of(context).orientation ==
|
|
||||||
// Orientation.landscape) {
|
|
||||||
// verticalScreenForTwoSeconds();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Listener(
|
child: Listener(
|
||||||
@@ -331,15 +426,20 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: Get.size.width,
|
width: Get.size.width,
|
||||||
height: MediaQuery.of(context).orientation ==
|
height: plPlayerController.isFullScreen.value
|
||||||
Orientation.landscape
|
|
||||||
? Get.size.height
|
? Get.size.height
|
||||||
: Get.size.width * 9 / 16,
|
: Get.size.width * 9 / 16,
|
||||||
child: videoPlayerPanel,
|
child: videoPlayerPanel(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
..._buildBottomWidget,
|
||||||
|
];
|
||||||
|
|
||||||
|
final GlobalKey chatKey = GlobalKey();
|
||||||
|
|
||||||
|
List<Widget> get _buildBottomWidget => [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Listener(
|
child: Listener(
|
||||||
onPointerDown: (_) {
|
onPointerDown: (_) {
|
||||||
@@ -348,6 +448,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
child: LiveRoomChat(
|
child: LiveRoomChat(
|
||||||
|
key: chatKey,
|
||||||
roomId: _roomId,
|
roomId: _roomId,
|
||||||
liveRoomController: _liveRoomController,
|
liveRoomController: _liveRoomController,
|
||||||
),
|
),
|
||||||
@@ -423,31 +524,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
],
|
];
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_updateFontSize();
|
|
||||||
});
|
|
||||||
if (Platform.isAndroid) {
|
|
||||||
return PiPSwitcher(
|
|
||||||
getChildWhenDisabled: () => childWhenDisabled,
|
|
||||||
getChildWhenEnabled: () => videoPlayerPanel,
|
|
||||||
floating: floating,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return childWhenDisabled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Color get _color => Color(0xFFEEEEEE);
|
|
||||||
|
|
||||||
void _onSendMsg(msg) async {
|
void _onSendMsg(msg) async {
|
||||||
if (!_isLogin) {
|
if (!_isLogin) {
|
||||||
@@ -458,6 +536,9 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
roomId: _liveRoomController.roomId, msg: msg);
|
roomId: _liveRoomController.roomId, msg: msg);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
_ctr.clear();
|
_ctr.clear();
|
||||||
|
if (mounted) {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
}
|
||||||
SmartDialog.showToast('发送成功');
|
SmartDialog.showToast('发送成功');
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class ReplyPage extends CommonPublishPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ReplyPageState extends CommonPublishPageState<ReplyPage> {
|
class _ReplyPageState extends CommonPublishPageState<ReplyPage> {
|
||||||
RxBool _syncToDynamic = false.obs;
|
final RxBool _syncToDynamic = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class PLVideoPlayer extends StatefulWidget {
|
|||||||
this.customWidgets,
|
this.customWidgets,
|
||||||
this.showEpisodes,
|
this.showEpisodes,
|
||||||
this.showViewPoints,
|
this.showViewPoints,
|
||||||
|
this.fill,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ class PLVideoPlayer extends StatefulWidget {
|
|||||||
final List<Widget>? customWidgets;
|
final List<Widget>? customWidgets;
|
||||||
final Function? showEpisodes;
|
final Function? showEpisodes;
|
||||||
final VoidCallback? showViewPoints;
|
final VoidCallback? showViewPoints;
|
||||||
|
final Color? fill;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
|
State<PLVideoPlayer> createState() => _PLVideoPlayerState();
|
||||||
@@ -844,6 +846,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
flipX: plPlayerController.flipX.value,
|
flipX: plPlayerController.flipX.value,
|
||||||
flipY: plPlayerController.flipY.value,
|
flipY: plPlayerController.flipY.value,
|
||||||
child: Video(
|
child: Video(
|
||||||
|
fill: widget.fill ?? Colors.black,
|
||||||
key: plPlayerController.key,
|
key: plPlayerController.key,
|
||||||
controller: videoController,
|
controller: videoController,
|
||||||
controls: NoVideoControls,
|
controls: NoVideoControls,
|
||||||
|
|||||||
Reference in New Issue
Block a user