revanced-manager/lib/main.dart

53 lines
1.8 KiB
Dart
Raw Permalink Normal View History

2022-07-31 00:39:59 +05:30
import 'package:flutter/material.dart';
2022-08-06 22:35:35 +01:00
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/gen/strings.g.dart';
import 'package:revanced_manager/services/download_manager.dart';
import 'package:revanced_manager/services/github_api.dart';
2022-08-25 00:51:47 +01:00
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
2022-09-05 09:07:38 +01:00
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:shared_preferences/shared_preferences.dart';
2022-09-20 00:03:37 +01:00
import 'package:timezone/data/latest.dart' as tz;
2022-07-31 00:39:59 +05:30
late SharedPreferences prefs;
2022-08-12 00:35:03 +05:30
Future main() async {
await setupLocator();
WidgetsFlutterBinding.ensureInitialized();
await locator<ManagerAPI>().initialize();
await locator<DownloadManager>().initialize();
final String apiUrl = locator<ManagerAPI>().getApiUrl();
await locator<RevancedAPI>().initialize(apiUrl);
final String repoUrl = locator<ManagerAPI>().getRepoUrl();
2022-12-10 01:10:43 +13:00
locator<GithubAPI>().initialize(repoUrl);
2022-09-20 00:03:37 +01:00
tz.initializeTimeZones();
// TODO(aAbed): remove in the future, keep it for now during migration.
final rootAPI = RootAPI();
if (await rootAPI.hasRootPermissions()) {
await rootAPI.removeOrphanedFiles();
}
prefs = await SharedPreferences.getInstance();
final managerAPI = locator<ManagerAPI>();
final locale = managerAPI.getLocale();
LocaleSettings.setLocaleRaw(locale);
runApp(TranslationProvider(child: const MyApp()));
2022-07-31 00:39:59 +05:30
}
class MyApp extends StatelessWidget {
2023-11-11 19:07:32 +07:00
const MyApp({super.key});
2022-07-31 00:39:59 +05:30
@override
Widget build(BuildContext context) {
return const DynamicThemeBuilder(
title: 'ReVanced Manager',
home: NavigationView(),
2022-07-31 13:30:11 +05:30
);
}
}