Files
PiliPlus/lib/utils/max_screen_size.dart
My-Responsitories d4d9fc3405 refa: jni (#2244)
* refa: jni

* refa: jni
2026-05-30 20:10:35 +08:00

36 lines
990 B
Dart

import 'dart:io' show Platform;
import 'package:PiliPlus/utils/android/android_helper.dart';
import 'package:PiliPlus/utils/android/bindings.g.dart';
abstract final class MaxScreenSize {
static int? _maxWidth;
static int? _maxHeight;
static void init() {
_initScreenSize();
if (AndroidHelper.isFoldable) {
AndroidHelper$ToDart.onUserLeaveHint = Runnable.implement(
$Runnable(run: _initScreenSize),
);
}
}
static void _initScreenSize() {
final size = PiliAndroidHelper.maxScreenSize();
if (size != null) {
_maxWidth = size.$1;
_maxHeight = size.$2;
}
}
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);
}
}