import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/services/download_manager.dart'; import 'package:revanced_manager/services/github_api.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/revanced_api.dart'; import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_view.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:timezone/data/latest.dart' as tz; late SharedPreferences prefs; Future main() async { await setupLocator(); WidgetsFlutterBinding.ensureInitialized(); await locator().initialize(); await locator().initialize(); final String apiUrl = locator().getApiUrl(); await locator().initialize(apiUrl); final String repoUrl = locator().getRepoUrl(); locator().initialize(repoUrl); tz.initializeTimeZones(); prefs = await SharedPreferences.getInstance(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { // String rawLocale = prefs.getString('language') ?? 'en_US'; // String replaceLocale = rawLocale.replaceAll('_', '-'); // List localeList = replaceLocale.split('-'); // Locale locale = Locale(localeList[0], localeList[1]); const Locale locale = Locale('en', 'US'); return DynamicThemeBuilder( title: 'ReVanced Manager', home: const NavigationView(), localizationsDelegates: [ FlutterI18nDelegate( translationLoader: FileTranslationLoader( fallbackFile: 'en_US', forcedLocale: locale, basePath: 'assets/i18n', useCountryCode: true, ), missingTranslationHandler: (key, locale) { log( '--> Missing translation: key: $key, languageCode: ${locale?.languageCode}', ); }, ), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], ); } }