improve handling android window mode

Closes #1908

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-29 11:39:38 +08:00
parent 52d8813fdc
commit 7e044e61e2
5 changed files with 80 additions and 14 deletions

View File

@@ -39,6 +39,7 @@ import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/size_ext.dart';
import 'package:PiliPlus/utils/extension/theme_ext.dart';
import 'package:PiliPlus/utils/image_utils.dart';
import 'package:PiliPlus/utils/max_screen_size.dart';
import 'package:PiliPlus/utils/mobile_observer.dart';
import 'package:PiliPlus/utils/page_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
@@ -100,6 +101,10 @@ class _LiveRoomPageState extends State<LiveRoomPage>
final size = MediaQuery.sizeOf(context);
maxWidth = size.width;
maxHeight = size.height;
isWindowMode = MaxScreenSize.isWindowMode(
width: maxWidth,
height: maxHeight,
);
isPortrait = size.isPortrait;
plPlayerController.screenRatio = maxHeight / maxWidth;
}
@@ -194,6 +199,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
late double maxWidth;
late double maxHeight;
bool isWindowMode = false;
late EdgeInsets padding;
late bool isPortrait;
@@ -402,7 +408,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
primary: !plPlayerController.removeSafeArea,
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: isFullScreen && !isPortrait
appBar: isWindowMode && isFullScreen && !isPortrait
? null
: _buildAppBar(isFullScreen),
body: isPortrait
@@ -424,7 +430,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
Widget _buildPH(bool isFullScreen) {
final height = maxWidth / Style.aspectRatio16x9;
final videoHeight = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: height;
final bottomHeight = maxHeight - padding.top - height - kToolbarHeight;
return Column(
@@ -453,7 +459,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
Widget _buildPP(bool isFullScreen) {
final bottomHeight = 70 + padding.bottom;
final videoHeight = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: maxHeight - bottomHeight;
return Stack(
clipBehavior: Clip.none,
@@ -707,7 +713,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
final videoHeight = maxHeight - padding.top - kToolbarHeight;
final width = isFullScreen ? maxWidth : videoWidth;
final height = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: videoHeight;
return Padding(
padding: isFullScreen

View File

@@ -55,6 +55,7 @@ import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/scroll_controller_ext.dart';
import 'package:PiliPlus/utils/extension/theme_ext.dart';
import 'package:PiliPlus/utils/image_utils.dart';
import 'package:PiliPlus/utils/max_screen_size.dart';
import 'package:PiliPlus/utils/mobile_observer.dart';
import 'package:PiliPlus/utils/num_utils.dart';
import 'package:PiliPlus/utils/page_utils.dart';
@@ -453,6 +454,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
final size = MediaQuery.sizeOf(context);
maxWidth = size.width;
maxHeight = size.height;
isWindowMode = MaxScreenSize.isWindowMode(
width: maxWidth,
height: maxHeight,
);
videoDetailController.plPlayerController.screenRatio = maxHeight / maxWidth;
final shortestSide = size.shortestSide;
@@ -471,8 +476,9 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
: Theme.of(context);
}
bool get removeAppBar =>
videoDetailController.removeSafeArea || (isFullScreen && !isPortrait);
bool removeAppBar(bool isFullScreen) =>
videoDetailController.removeSafeArea ||
(isWindowMode && isFullScreen && !isPortrait);
Widget get childWhenDisabled {
return Obx(
@@ -480,7 +486,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
final isFullScreen = this.isFullScreen;
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: removeAppBar
appBar: removeAppBar(isFullScreen)
? null
: PreferredSize(
preferredSize: const Size.fromHeight(0),
@@ -520,7 +526,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
onlyOneScrollInBody: true,
pinnedHeaderSliverHeightBuilder: () {
double pinnedHeight = this.isFullScreen || !isPortrait
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: videoDetailController.isExpanding ||
videoDetailController.isCollapsing
? videoDetailController.animHeight
@@ -546,7 +552,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
},
headerSliverBuilder: (context, innerBoxIsScrolled) {
final height = isFullScreen || !isPortrait
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: videoDetailController.isExpanding ||
videoDetailController.isCollapsing
? videoDetailController.animHeight
@@ -782,7 +788,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
final isFullScreen = this.isFullScreen;
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: removeAppBar
appBar: removeAppBar(isFullScreen)
? null
: AppBar(backgroundColor: Colors.black, toolbarHeight: 0),
body: Padding(
@@ -923,7 +929,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
final videoWidth = isFullScreen ? maxWidth : width;
final double height = width / Style.aspectRatio16x9;
final videoHeight = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: height;
if (height > maxHeight) {
return childSplit(Style.aspectRatio16x9);
@@ -1017,7 +1023,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
final isFullScreen = this.isFullScreen;
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: removeAppBar
appBar: removeAppBar(isFullScreen)
? null
: AppBar(backgroundColor: Colors.black, toolbarHeight: 0),
body: Padding(
@@ -1049,7 +1055,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
final shouldShowSeasonPanel = _shouldShowSeasonPanel;
final double height = maxHeight / 2.5;
final videoHeight = isFullScreen
? maxHeight - (isPortrait ? padding.top : 0)
? maxHeight - (isWindowMode && !isPortrait ? 0 : padding.top)
: height;
final bottomHeight = maxHeight - height - padding.top;
return Column(
@@ -1298,6 +1304,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
late bool isPortrait;
late double maxWidth;
late double maxHeight;
bool isWindowMode = false;
late EdgeInsets padding;
@override