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';
|
2024-02-12 02:22:25 +03:00
|
|
|
import 'package:revanced_manager/gen/strings.g.dart';
|
2023-10-15 02:51:31 -07:00
|
|
|
import 'package:revanced_manager/services/download_manager.dart';
|
2022-09-12 01:41:53 +01:00
|
|
|
import 'package:revanced_manager/services/github_api.dart';
|
2022-08-25 00:51:47 +01:00
|
|
|
import 'package:revanced_manager/services/manager_api.dart';
|
2022-09-12 01:41:53 +01:00
|
|
|
import 'package:revanced_manager/services/revanced_api.dart';
|
2023-12-23 09:01:28 +05:45
|
|
|
import 'package:revanced_manager/services/root_api.dart';
|
2022-09-05 03:32:36 +01:00
|
|
|
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';
|
2023-03-03 18:06:24 +07:00
|
|
|
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
|
|
|
|
2023-03-03 18:06:24 +07:00
|
|
|
late SharedPreferences prefs;
|
2022-08-12 00:35:03 +05:30
|
|
|
Future main() async {
|
2023-02-21 18:06:56 +05:45
|
|
|
await setupLocator();
|
2023-03-03 18:06:24 +07:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await locator<ManagerAPI>().initialize();
|
2024-02-12 02:22:25 +03:00
|
|
|
|
2023-10-15 02:51:31 -07:00
|
|
|
await locator<DownloadManager>().initialize();
|
2023-03-03 18:06:24 +07:00
|
|
|
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();
|
2023-12-23 09:01:28 +05:45
|
|
|
|
|
|
|
// 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 18:06:24 +07:00
|
|
|
prefs = await SharedPreferences.getInstance();
|
2022-10-15 18:29:50 +05:30
|
|
|
|
2024-02-12 02:22:25 +03:00
|
|
|
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) {
|
2024-02-12 02:22:25 +03:00
|
|
|
return const DynamicThemeBuilder(
|
2022-09-05 03:32:36 +01:00
|
|
|
title: 'ReVanced Manager',
|
2024-02-12 02:22:25 +03:00
|
|
|
home: NavigationView(),
|
2022-07-31 13:30:11 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|