11import 'package:flutter/material.dart' ;
22import 'package:flutter/services.dart' ;
3+ import 'package:provider/provider.dart' ;
34import 'package:tencent_calls_uikit/tencent_calls_uikit.dart' ;
45import 'package:tencent_live_uikit/common/widget/global.dart' ;
56import 'package:tencent_live_uikit/component/float_window/global_float_window_manager.dart' ;
@@ -24,58 +25,76 @@ class MyApp extends StatefulWidget {
2425}
2526
2627class _MyAppState extends State <MyApp > {
28+ late final ThemeState _themeState;
29+
2730 @override
2831 void initState () {
2932 super .initState ();
33+ _themeState = ThemeState ();
34+ _initializeApp ();
35+ }
36+
37+ Future <void > _initializeApp () async {
3038 GlobalFloatWindowManager .instance.enableFloatWindowFeature (true );
39+ await AppBuilder .init (path: 'assets/appConfig.json' );
3140 }
3241
3342 @override
3443 Widget build (BuildContext context) {
35- final themeState = ThemeState ();
36- themeState.setThemeMode (ThemeType .dark);
37- return ComponentTheme (
38- themeState: themeState,
39- child: MaterialApp (
40- debugShowCheckedModeBanner: false ,
41- navigatorObservers: [
42- TUILiveKitNavigatorObserver .instance,
43- RoomNavigatorObserver .instance,
44- TUICallKit .navigatorObserver
45- ],
46- localizationsDelegates: const [
47- ...AppLocalizations .localizationsDelegates,
48- ...LiveKitLocalizations .localizationsDelegates,
49- ...BarrageLocalizations .localizationsDelegates,
50- ...GiftLocalizations .localizationsDelegates,
51- ...RoomLocalizations .localizationsDelegates,
52- ],
53- supportedLocales: const [
54- Locale ('en' ),
55- Locale .fromSubtags (languageCode: 'zh' , scriptCode: 'Hans' ),
56- Locale .fromSubtags (languageCode: 'zh' , scriptCode: 'Hant' ),
57- Locale ('zh' ),
58- ],
59- builder: (context, child) => Scaffold (
60- resizeToAvoidBottomInset: false ,
61- body: GestureDetector (
62- onTap: () {
63- hideKeyboard (context);
64- },
65- child: child,
44+ return MultiProvider (
45+ providers: [
46+ ChangeNotifierProvider .value (value: LocaleProvider ()),
47+ ],
48+ child: Builder (builder: (context) {
49+ return ComponentTheme (
50+ themeState: _themeState,
51+ child: MaterialApp (
52+ debugShowCheckedModeBanner: false ,
53+ navigatorObservers: [
54+ TUILiveKitNavigatorObserver .instance,
55+ RoomNavigatorObserver .instance,
56+ TUICallKit .navigatorObserver
57+ ],
58+ localizationsDelegates: const [
59+ ...AppLocalizations .localizationsDelegates,
60+ ...LiveKitLocalizations .localizationsDelegates,
61+ ...BarrageLocalizations .localizationsDelegates,
62+ ...GiftLocalizations .localizationsDelegates,
63+ ...RoomLocalizations .localizationsDelegates,
64+ AtomicLocalizations .delegate,
65+ ],
66+ supportedLocales: const [
67+ Locale ('en' ),
68+ Locale .fromSubtags (languageCode: 'zh' , scriptCode: 'Hans' ),
69+ Locale .fromSubtags (languageCode: 'zh' , scriptCode: 'Hant' ),
70+ Locale ('zh' ),
71+ ],
72+ locale: Provider .of <LocaleProvider >(context).locale,
73+ builder: (context, child) => Scaffold (
74+ resizeToAvoidBottomInset: false ,
75+ body: GestureDetector (
76+ onTap: () {
77+ hideKeyboard (context);
78+ },
79+ child: child,
80+ ),
81+ ),
82+ home: PopScope (
83+ canPop: false ,
84+ child: Navigator (
85+ key: Global .secondaryNavigatorKey,
86+ initialRoute: '/login_widget' ,
87+ onGenerateRoute: (settings) {
88+ if (settings.name == '/login_widget' ) {
89+ return MaterialPageRoute (builder: (BuildContext context) => const LoginWidget ());
90+ }
91+ return null ;
92+ },
93+ ),
94+ ),
6695 ),
67- ),
68- home: Navigator (
69- key: Global .secondaryNavigatorKey,
70- initialRoute: '/login_widget' ,
71- onGenerateRoute: (settings) {
72- if (settings.name == '/login_widget' ) {
73- return MaterialPageRoute (builder: (BuildContext context) => const LoginWidget ());
74- }
75- return null ;
76- },
77- ),
78- ),
96+ );
97+ }),
7998 );
8099 }
81100
0 commit comments