mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt: live danmaku fontsize
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -88,9 +88,7 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
|||||||
if (_controller != null) {
|
if (_controller != null) {
|
||||||
_controller!.updateOption(
|
_controller!.updateOption(
|
||||||
_controller!.option.copyWith(
|
_controller!.option.copyWith(
|
||||||
fontSize: isFullScreen == false || widget.isPipMode == true
|
fontSize: _getFontSize(isFullScreen),
|
||||||
? 15 * fontSizeVal
|
|
||||||
: 15 * fontSizeVal * 1.2,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -157,6 +155,11 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double _getFontSize(isFullScreen) =>
|
||||||
|
isFullScreen == false || widget.isPipMode == true
|
||||||
|
? 15 * fontSizeVal
|
||||||
|
: 15 * fontSizeVal * 1.2;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(builder: (context, box) {
|
return LayoutBuilder(builder: (context, box) {
|
||||||
@@ -170,10 +173,7 @@ class _PlDanmakuState extends State<PlDanmaku> with WidgetsBindingObserver {
|
|||||||
playerController.danmakuController = _controller = e;
|
playerController.danmakuController = _controller = e;
|
||||||
},
|
},
|
||||||
option: DanmakuOption(
|
option: DanmakuOption(
|
||||||
fontSize: playerController.isFullScreen.value == false ||
|
fontSize: _getFontSize(playerController.isFullScreen.value),
|
||||||
widget.isPipMode == true
|
|
||||||
? 15 * fontSizeVal
|
|
||||||
: 15 * fontSizeVal * 1.2,
|
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight,
|
||||||
area: showArea,
|
area: showArea,
|
||||||
opacity: opacityVal,
|
opacity: opacityVal,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:PiliPalaX/pages/live_room/widgets/chat.dart';
|
|||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import 'package:floating/floating.dart';
|
import 'package:floating/floating.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
@@ -50,6 +51,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
late double strokeWidth;
|
late double strokeWidth;
|
||||||
late int fontWeight;
|
late int fontWeight;
|
||||||
int latestAddedPosition = -1;
|
int latestAddedPosition = -1;
|
||||||
|
bool? _isFullScreen;
|
||||||
|
bool? _isPipMode;
|
||||||
|
|
||||||
void playCallBack() {
|
void playCallBack() {
|
||||||
plPlayerController.play();
|
plPlayerController.play();
|
||||||
@@ -68,6 +71,30 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
_futureBuilderFuture = _liveRoomController.queryLiveInfo();
|
_futureBuilderFuture = _liveRoomController.queryLiveInfo();
|
||||||
plPlayerController.autoEnterFullscreen();
|
plPlayerController.autoEnterFullscreen();
|
||||||
_liveRoomController.liveMsg();
|
_liveRoomController.liveMsg();
|
||||||
|
plPlayerController.isFullScreen.listen((isFullScreen) {
|
||||||
|
if (isFullScreen != _isFullScreen) {
|
||||||
|
_isFullScreen = isFullScreen;
|
||||||
|
_updateFontSize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateFontSize() async {
|
||||||
|
_isPipMode =
|
||||||
|
await const MethodChannel("floating").invokeMethod('inPipAlready');
|
||||||
|
if (_liveRoomController.controller != null) {
|
||||||
|
_liveRoomController.controller!.updateOption(
|
||||||
|
_liveRoomController.controller!.option.copyWith(
|
||||||
|
fontSize: _getFontSize(plPlayerController.isFullScreen.value),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double _getFontSize(isFullScreen) {
|
||||||
|
return isFullScreen == false || _isPipMode != false
|
||||||
|
? 15 * fontSizeVal
|
||||||
|
: 15 * fontSizeVal * 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> videoSourceInit() async {
|
Future<void> videoSourceInit() async {
|
||||||
@@ -106,9 +133,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Widget get videoPlayerPanel {
|
||||||
Widget build(BuildContext context) {
|
return FutureBuilder(
|
||||||
Widget videoPlayerPanel = FutureBuilder(
|
|
||||||
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']) {
|
||||||
@@ -129,7 +155,8 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
_liveRoomController.controller = e;
|
_liveRoomController.controller = e;
|
||||||
},
|
},
|
||||||
option: DanmakuOption(
|
option: DanmakuOption(
|
||||||
fontSize: 15 * fontSizeVal,
|
fontSize:
|
||||||
|
_getFontSize(plPlayerController.isFullScreen.value),
|
||||||
fontWeight: fontWeight,
|
fontWeight: fontWeight,
|
||||||
area: showArea,
|
area: showArea,
|
||||||
opacity: opacityVal,
|
opacity: opacityVal,
|
||||||
@@ -152,8 +179,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget childWhenDisabled = Scaffold(
|
Widget get childWhenDisabled {
|
||||||
|
return Scaffold(
|
||||||
primary: true,
|
primary: true,
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: Stack(
|
body: Stack(
|
||||||
@@ -415,6 +444,13 @@ class _LiveRoomPageState extends State<LiveRoomPage>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_updateFontSize();
|
||||||
|
});
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
return PiPSwitcher(
|
return PiPSwitcher(
|
||||||
childWhenDisabled: childWhenDisabled,
|
childWhenDisabled: childWhenDisabled,
|
||||||
|
|||||||
Reference in New Issue
Block a user