fix: 顶部播放控制条重载,界面尺寸微调

This commit is contained in:
orz12
2024-03-22 13:41:11 +08:00
parent 74ac540753
commit 9943cc099b

View File

@@ -57,6 +57,7 @@ class _HeaderControlState extends State<HeaderControl> {
late StreamSubscription<bool> fullScreenStatusListener; late StreamSubscription<bool> fullScreenStatusListener;
late bool horizontalScreen; late bool horizontalScreen;
RxString now = ''.obs; RxString now = ''.obs;
late Timer clock;
@override @override
void initState() { void initState() {
@@ -89,6 +90,7 @@ class _HeaderControlState extends State<HeaderControl> {
void dispose() { void dispose() {
widget.floating?.dispose(); widget.floating?.dispose();
fullScreenStatusListener.cancel(); fullScreenStatusListener.cancel();
clock.cancel();
super.dispose(); super.dispose();
} }
@@ -1040,11 +1042,11 @@ class _HeaderControlState extends State<HeaderControl> {
} }
startClock() { startClock() {
Timer.periodic(const Duration(seconds: 1), (Timer t) { clock = Timer.periodic(const Duration(seconds: 1), (Timer t) {
if (!mounted) { if (!mounted) {
return; return;
} }
now.value = DateTime.now().toString().split(' ')[1].substring(0, 8); now.value = DateTime.now().toString().split(' ')[1].substring(0, 5);
}); });
} }
@@ -1053,6 +1055,8 @@ class _HeaderControlState extends State<HeaderControl> {
final _ = widget.controller!; final _ = widget.controller!;
// final bool isLandscape = // final bool isLandscape =
// MediaQuery.of(context).orientation == Orientation.landscape; // MediaQuery.of(context).orientation == Orientation.landscape;
return LayoutBuilder(builder: (context, boxConstraints) {
return AppBar( return AppBar(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
foregroundColor: Colors.white, foregroundColor: Colors.white,
@@ -1097,10 +1101,7 @@ class _HeaderControlState extends State<HeaderControl> {
children: [ children: [
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints( constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).orientation == maxWidth: boxConstraints.maxWidth / 2 - 60,
Orientation.landscape
? 400
: 140,
maxHeight: 25), maxHeight: 25),
child: Marquee( child: Marquee(
text: videoIntroController.videoDetail.value.title!, text: videoIntroController.videoDetail.value.title!,
@@ -1160,7 +1161,8 @@ class _HeaderControlState extends State<HeaderControl> {
MediaQuery.of(context).orientation == MediaQuery.of(context).orientation ==
Orientation.landscape) || Orientation.landscape) ||
(!isFullScreen && (!isFullScreen &&
MediaQuery.of(context).orientation == Orientation.landscape && MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen)) ...[ !horizontalScreen)) ...[
// const Spacer(), // const Spacer(),
// show current datetime // show current datetime
@@ -1173,7 +1175,9 @@ class _HeaderControlState extends State<HeaderControl> {
), ),
), ),
), ),
const SizedBox(width: 15,), const SizedBox(
width: 15,
),
], ],
// ComBtn( // ComBtn(
// icon: const Icon( // icon: const Icon(
@@ -1210,8 +1214,10 @@ class _HeaderControlState extends State<HeaderControl> {
), ),
onPressed: () { onPressed: () {
_.isOpenDanmu.value = !_.isOpenDanmu.value; _.isOpenDanmu.value = !_.isOpenDanmu.value;
setting.put(
SettingBoxKey.enableShowDanmaku, _.isOpenDanmu.value);
SmartDialog.showToast( SmartDialog.showToast(
_.isOpenDanmu.value ? '已临时开启弹幕' : '已临时关闭弹幕', "${_.isOpenDanmu.value ? '开启' : '关闭'}弹幕",
displayTime: const Duration(seconds: 1)); displayTime: const Duration(seconds: 1));
}, },
icon: Icon( icon: Icon(
@@ -1271,6 +1277,7 @@ class _HeaderControlState extends State<HeaderControl> {
], ],
), ),
); );
});
} }
} }