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';
|
2024-02-12 00:22:25 +01:00
|
|
|
import 'package:revanced_manager/gen/strings.g.dart';
|
2023-10-15 11:51:31 +02:00
|
|
|
import 'package:revanced_manager/services/download_manager.dart';
|
2022-09-12 02:41:53 +02:00
|
|
|
import 'package:revanced_manager/services/github_api.dart';
|
2022-08-25 01:51:47 +02:00
|
|
|
import 'package:revanced_manager/services/manager_api.dart';
|
2022-09-12 02:41:53 +02:00
|
|
|
import 'package:revanced_manager/services/revanced_api.dart';
|
2023-12-23 04:16:28 +01:00
|
|
|
import 'package:revanced_manager/services/root_api.dart';
|
2022-09-05 04:32:36 +02:00
|
|
|
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';
|
2023-03-03 12:06:24 +01:00
|
|
|
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
|
|
|
|
2023-03-03 12:06:24 +01:00
|
|
|
late SharedPreferences prefs;
|
2022-08-11 21:05:03 +02:00
|
|
|
Future main() async {
|
2023-02-21 13:21:56 +01:00
|
|
|
await setupLocator();
|
2023-03-03 12:06:24 +01:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await locator<ManagerAPI>().initialize();
|
2024-02-12 00:22:25 +01:00
|
|
|
|
2023-10-15 11:51:31 +02:00
|
|
|
await locator<DownloadManager>().initialize();
|
2023-03-03 12:06:24 +01:00
|
|
|
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();
|
2023-12-23 04:16:28 +01:00
|
|
|
|
|
|
|
// TODO(aAbed): remove in the future, keep it for now during migration.
|
|
|
|
final rootAPI = RootAPI();
|
|
|
|
if (await rootAPI.hasRootPermissions()) {
|
|
|
|
await rootAPI.removeOrphanedFiles();
|
|
|
|
}
|
|
|
|
|
2023-03-03 12:06:24 +01:00
|
|
|
prefs = await SharedPreferences.getInstance();
|
2022-10-15 14:59:50 +02:00
|
|
|
|
2024-02-12 00:22:25 +01:00
|
|
|
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) {
|
2024-02-12 00:22:25 +01:00
|
|
|
return const DynamicThemeBuilder(
|
2022-09-05 04:32:36 +02:00
|
|
|
title: 'ReVanced Manager',
|
2024-02-12 00:22:25 +01:00
|
|
|
home: NavigationView(),
|
2022-07-31 10:00:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|