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 11b6f241b0
commit 7b51b6900f
5 changed files with 80 additions and 14 deletions

View File

@@ -0,0 +1,25 @@
import 'dart:io' show Platform;
import 'package:PiliPlus/utils/utils.dart';
abstract final class MaxScreenSize {
static int? _maxWidth;
static int? _maxHeight;
static Future<void> init() async {
final res = await Utils.channel.invokeMethod('maxScreenSize');
if (res is Map) {
_maxWidth = res['maxWidth'];
_maxHeight = res['maxHeight'];
}
}
static bool isWindowMode({required num width, required num height}) {
if (!Platform.isAndroid) return false;
width = width.round();
height = height.round();
final hasWidthMatch = width == _maxWidth || width == _maxHeight;
final hasHeightMatch = height == _maxWidth || height == _maxHeight;
return !(hasWidthMatch && hasHeightMatch);
}
}