mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-04 09:09:48 +08:00
handle foldable screen size
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,13 +1,33 @@
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/services.dart' show MethodChannel;
|
||||
|
||||
abstract final class MaxScreenSize {
|
||||
static int? _maxWidth;
|
||||
static int? _maxHeight;
|
||||
|
||||
static Future<void> init() async {
|
||||
static Future<void> init() {
|
||||
return Future.wait([_initFoldable(), _initScreenSize()]);
|
||||
}
|
||||
|
||||
static Future<void> _initFoldable() async {
|
||||
final isFoldable = await Utils.channel.invokeMethod('isFoldable');
|
||||
if (isFoldable == true) {
|
||||
const MethodChannel('ScreenChannel').setMethodCallHandler((call) async {
|
||||
if (call.method == 'onConfigChanged') {
|
||||
_handleRes(call.arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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'];
|
||||
|
||||
Reference in New Issue
Block a user