From 5706f21724bd9afac01969bfda565947785cf443 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sat, 20 Sep 2025 12:19:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E6=89=8B=E5=92=8C?= =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 85 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 5a0941bdf..b558250f6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_intro/flutter_intro.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; import 'package:get_storage/get_storage.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; @@ -108,27 +111,69 @@ class MainApp extends StatelessWidget { Widget build(BuildContext context) { // 在应用构建时立即初始化深链接处理 _initDeepLinkHandler(); +// 获取保存的主题设置 + final themeMode = ThemeService().getThemeMode(); - // 使用 ScreenUtilInit 包装整个应用 return ScreenUtilInit( - designSize: const Size(375, 812), // 设计稿尺寸,根据你的设计稿调整 - minTextAdapt: true, - splitScreenMode: true, - builder: (context, child) { - return GetMaterialApp( - title: 'VoiTrans', - theme: AppTheme.lightTheme, - darkTheme: AppTheme.darkTheme, - themeMode: ThemeService().getThemeMode(), - initialRoute: Routes.splash, - getPages: AppPages.pages, - initialBinding: InitialBinding(), - translations: AppTranslations(), - locale: Get.deviceLocale, - fallbackLocale: const Locale('en', 'US'), - debugShowCheckedModeBanner: false, - ); - }, - ); + designSize: const Size(375, 812), + minTextAdapt: true, + splitScreenMode: true, + builder: (_, child) { + return GetMaterialApp( + title: 'Voitrans', + theme: AppTheme.lightTheme, + darkTheme: AppTheme.darkTheme, + themeMode: themeMode, // 使用提前获取的主题模式 + initialBinding: InitialBinding(), + initialRoute: Routes.splash, + getPages: AppPages.pages, + debugShowCheckedModeBanner: false, + translations: AppTranslations(), + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + locale: AppTranslations.deviceLocale(), + fallbackLocale: AppTranslations.getSmartFallbackLocale(), + supportedLocales: AppTranslations.supportedLocales, + builder: EasyLoading.init( + builder: (BuildContext context, Widget? widget) { + EasyLoading.instance.userInteractions = false; + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaler: TextScaler.noScaling, + ), + child: Intro( + padding: EdgeInsets.zero, + child: widget!, + ), + ); + }, + ), + ); + }); + + // // 使用 ScreenUtilInit 包装整个应用 + // return ScreenUtilInit( + // designSize: const Size(375, 812), // 设计稿尺寸,根据你的设计稿调整 + // minTextAdapt: true, + // splitScreenMode: true, + // builder: (context, child) { + // return GetMaterialApp( + // title: 'VoiTrans', + // theme: AppTheme.lightTheme, + // darkTheme: AppTheme.darkTheme, + // themeMode: ThemeService().getThemeMode(), + // initialRoute: Routes.splash, + // getPages: AppPages.pages, + // initialBinding: InitialBinding(), + // translations: AppTranslations(), + // locale: Get.deviceLocale, + // fallbackLocale: const Locale('en', 'US'), + // debugShowCheckedModeBanner: false, + // ); + // }, + // ); } }