revanced-manager/lib/main.dart

53 lines
1.8 KiB
Dart
Raw Normal View History

2022-07-30 21:09:59 +02:00
import 'package:flutter/material.dart';
2022-08-06 23:35:35 +02: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 01:51:47 +02: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 10:07:38 +02:00
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:shared_preferences/shared_preferences.dart';
2022-09-20 01:03:37 +02:00
import 'package:timezone/data/latest.dart' as tz;
2022-07-30 21:09:59 +02:00
late SharedPreferences prefs;
2022-08-11 21:05:03 +02:00
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-09 13:10:43 +01:00
locator<GithubAPI>().initialize(repoUrl);
2022-09-20 01:03:37 +02: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-30 21:09:59 +02:00
}
class MyApp extends StatelessWidget {
2023-11-11 13:07:32 +01:00
const MyApp({super.key});
2022-07-30 21:09:59 +02:00
@override
Widget build(BuildContext context) {
return const DynamicThemeBuilder(
title: 'ReVanced Manager',
home: NavigationView(),
2022-07-31 10:00:11 +02:00
);
}
}