mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 08:38:37 +00:00
@@ -4,6 +4,7 @@ import 'package:PiliPlus/build_config.dart';
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_toast.dart';
|
||||
import 'package:PiliPlus/common/widgets/mouse_back.dart';
|
||||
import 'package:PiliPlus/common/widgets/scale_app.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/models/common/theme/theme_color_type.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/controller.dart';
|
||||
@@ -46,7 +47,7 @@ import 'package:window_manager/window_manager.dart' hide calcWindowPosition;
|
||||
WebViewEnvironment? webViewEnvironment;
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
ScaledWidgetsFlutterBinding.ensureInitialized();
|
||||
MediaKit.ensureInitialized();
|
||||
tmpDirPath = (await getTemporaryDirectory()).path;
|
||||
appSupportDirPath = (await getApplicationSupportDirectory()).path;
|
||||
@@ -57,6 +58,7 @@ void main() async {
|
||||
if (kDebugMode) debugPrint('GStorage init error: $e');
|
||||
exit(0);
|
||||
}
|
||||
ScaledWidgetsFlutterBinding.instance.setScaleFactor(Pref.uiScale);
|
||||
|
||||
if (PlatformUtils.isDesktop) {
|
||||
final customDownPath = Pref.downloadPath;
|
||||
@@ -298,29 +300,16 @@ class MyApp extends StatelessWidget {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final textScaler = TextScaler.linear(Pref.defaultTextScale);
|
||||
if (uiScale != 1.0) {
|
||||
// Apply full UI scaling for desktop
|
||||
final actualSize = mediaQuery.size;
|
||||
final scaledSize = actualSize / uiScale;
|
||||
child = MediaQuery(
|
||||
data: mediaQuery.copyWith(
|
||||
// Tell child the logical size it should layout to
|
||||
size: scaledSize,
|
||||
textScaler: textScaler,
|
||||
size: mediaQuery.size / uiScale,
|
||||
padding: mediaQuery.padding / uiScale,
|
||||
viewPadding: mediaQuery.viewPadding / uiScale,
|
||||
viewInsets: mediaQuery.viewInsets / uiScale,
|
||||
viewPadding: mediaQuery.viewPadding / uiScale,
|
||||
devicePixelRatio: mediaQuery.devicePixelRatio * uiScale,
|
||||
),
|
||||
// Use OverflowBox to let child layout to scaledSize,
|
||||
// then FittedBox scales it to fit actualSize
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fill,
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: scaledSize.width,
|
||||
height: scaledSize.height,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
child: child!,
|
||||
);
|
||||
} else {
|
||||
child = MediaQuery(
|
||||
|
||||
Reference in New Issue
Block a user