Files
PiliPlus/lib/utils/max_screen_size.dart
dom d27f5f315c drop
Signed-off-by: dom <githubaccount56556@proton.me>
2026-05-01 14:27:27 +08:00

34 lines
884 B
Dart

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() {
return _initScreenSize();
}
static Future<void> _initScreenSize() async {
final res = await Utils.channel.invokeMethod('maxScreenSize');
_handleRes(res);
}
static void _handleRes(dynamic res) {
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);
}
}