feat: 横屏全屏时展示视频标题
This commit is contained in:
@ -19,6 +19,8 @@ import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
|
|||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
import 'package:pilipala/http/danmaku.dart';
|
import 'package:pilipala/http/danmaku.dart';
|
||||||
import 'package:pilipala/services/shutdown_timer_service.dart';
|
import 'package:pilipala/services/shutdown_timer_service.dart';
|
||||||
|
import '../../../../models/video_detail_res.dart';
|
||||||
|
import '../introduction/index.dart';
|
||||||
|
|
||||||
class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
|
class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
|
||||||
const HeaderControl({
|
const HeaderControl({
|
||||||
@ -48,11 +50,31 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
final Box<dynamic> videoStorage = GStrorage.video;
|
final Box<dynamic> videoStorage = GStrorage.video;
|
||||||
late List<double> speedsList;
|
late List<double> speedsList;
|
||||||
double buttonSpace = 8;
|
double buttonSpace = 8;
|
||||||
|
bool showTitle = false;
|
||||||
|
late String heroTag;
|
||||||
|
late VideoIntroController videoIntroController;
|
||||||
|
late VideoDetailData videoDetail;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
videoInfo = widget.videoDetailCtr!.data;
|
videoInfo = widget.videoDetailCtr!.data;
|
||||||
speedsList = widget.controller!.speedsList;
|
speedsList = widget.controller!.speedsList;
|
||||||
|
fullScreenStatusListener();
|
||||||
|
heroTag = Get.arguments['heroTag'];
|
||||||
|
videoIntroController = Get.put(VideoIntroController(), tag: heroTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fullScreenStatusListener() {
|
||||||
|
widget.videoDetailCtr!.plPlayerController.isFullScreen
|
||||||
|
.listen((bool isFullScreen) {
|
||||||
|
if (isFullScreen) {
|
||||||
|
showTitle = true;
|
||||||
|
} else {
|
||||||
|
showTitle = false;
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 设置面板
|
/// 设置面板
|
||||||
@ -342,8 +364,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
},
|
},
|
||||||
dense: true,
|
dense: true,
|
||||||
contentPadding: const EdgeInsets.only(),
|
contentPadding: const EdgeInsets.only(),
|
||||||
title:
|
title: const Text("额外等待视频播放完毕", style: titleStyle),
|
||||||
const Text("额外等待视频播放完毕", style: titleStyle),
|
|
||||||
trailing: Switch(
|
trailing: Switch(
|
||||||
// thumb color (round icon)
|
// thumb color (round icon)
|
||||||
activeColor: Theme.of(context).colorScheme.primary,
|
activeColor: Theme.of(context).colorScheme.primary,
|
||||||
@ -891,7 +912,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
final DanmakuOption currentOption =
|
final DanmakuOption currentOption =
|
||||||
danmakuController.option;
|
danmakuController.option;
|
||||||
final DanmakuOption updatedOption =
|
final DanmakuOption updatedOption =
|
||||||
currentOption.copyWith(strokeWidth: val);
|
currentOption.copyWith(strokeWidth: val);
|
||||||
danmakuController.updateOption(updatedOption);
|
danmakuController.updateOption(updatedOption);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
},
|
},
|
||||||
@ -1047,6 +1068,8 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
);
|
);
|
||||||
|
final bool isLandscape =
|
||||||
|
MediaQuery.of(context).orientation == Orientation.landscape;
|
||||||
return AppBar(
|
return AppBar(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
@ -1081,21 +1104,47 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(width: buttonSpace),
|
SizedBox(width: buttonSpace),
|
||||||
ComBtn(
|
if (showTitle && isLandscape) ...[
|
||||||
icon: const Icon(
|
Column(
|
||||||
FontAwesomeIcons.house,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
size: 15,
|
children: [
|
||||||
color: Colors.white,
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxWidth: 200),
|
||||||
|
child: Text(
|
||||||
|
videoIntroController.videoDetail.value.title!,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (videoIntroController.isShowOnlineTotal)
|
||||||
|
Text(
|
||||||
|
'${videoIntroController.total.value}人正在看',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
] else ...[
|
||||||
|
ComBtn(
|
||||||
|
icon: const Icon(
|
||||||
|
FontAwesomeIcons.house,
|
||||||
|
size: 15,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
fuc: () async {
|
||||||
|
// 销毁播放器实例
|
||||||
|
await widget.controller!.dispose(type: 'all');
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.popUntil(
|
||||||
|
context, (Route<dynamic> route) => route.isFirst);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
fuc: () async {
|
],
|
||||||
// 销毁播放器实例
|
|
||||||
await widget.controller!.dispose(type: 'all');
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.popUntil(
|
|
||||||
context, (Route<dynamic> route) => route.isFirst);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
// ComBtn(
|
// ComBtn(
|
||||||
// icon: const Icon(
|
// icon: const Icon(
|
||||||
|
Reference in New Issue
Block a user