main.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:flutter/material.dart';
  2. import 'package:revanced_manager/app/app.locator.dart';
  3. import 'package:revanced_manager/gen/strings.g.dart';
  4. import 'package:revanced_manager/services/download_manager.dart';
  5. import 'package:revanced_manager/services/github_api.dart';
  6. import 'package:revanced_manager/services/manager_api.dart';
  7. import 'package:revanced_manager/services/revanced_api.dart';
  8. import 'package:revanced_manager/services/root_api.dart';
  9. import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
  10. import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
  11. import 'package:shared_preferences/shared_preferences.dart';
  12. import 'package:timezone/data/latest.dart' as tz;
  13. late SharedPreferences prefs;
  14. Future main() async {
  15. await setupLocator();
  16. WidgetsFlutterBinding.ensureInitialized();
  17. await locator<ManagerAPI>().initialize();
  18. await locator<DownloadManager>().initialize();
  19. final String apiUrl = locator<ManagerAPI>().getApiUrl();
  20. await locator<RevancedAPI>().initialize(apiUrl);
  21. final String repoUrl = locator<ManagerAPI>().getRepoUrl();
  22. locator<GithubAPI>().initialize(repoUrl);
  23. tz.initializeTimeZones();
  24. // TODO(aAbed): remove in the future, keep it for now during migration.
  25. final rootAPI = RootAPI();
  26. if (await rootAPI.hasRootPermissions()) {
  27. await rootAPI.removeOrphanedFiles();
  28. }
  29. prefs = await SharedPreferences.getInstance();
  30. final managerAPI = locator<ManagerAPI>();
  31. final locale = managerAPI.getLocale();
  32. LocaleSettings.setLocaleRaw(locale);
  33. runApp(TranslationProvider(child: const MyApp()));
  34. }
  35. class MyApp extends StatelessWidget {
  36. const MyApp({super.key});
  37. @override
  38. Widget build(BuildContext context) {
  39. return const DynamicThemeBuilder(
  40. title: 'ReVanced Manager',
  41. home: NavigationView(),
  42. );
  43. }
  44. }