revanced-manager/lib/main.dart

65 lines
2.0 KiB
Dart
Raw Normal View History

2022-07-30 21:09:59 +02:00
import 'package:flutter/material.dart';
2022-08-07 01:37:12 +02:00
import 'package:flutter_i18n/flutter_i18n.dart';
2022-08-07 02:13:27 +02:00
// ignore: depend_on_referenced_packages
2022-08-07 01:37:12 +02:00
import 'package:flutter_localizations/flutter_localizations.dart';
2022-08-06 23:35:35 +02:00
import 'package:revanced_manager/app/app.locator.dart';
2022-08-25 01:51:47 +02:00
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_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';
2022-08-14 20:40:34 +02:00
import 'package:revanced_manager/ui/views/root_checker/root_checker_view.dart';
2022-08-11 21:05:03 +02:00
import 'package:stacked_themes/stacked_themes.dart';
2022-07-30 21:09:59 +02:00
2022-08-11 21:05:03 +02:00
Future main() async {
await ThemeManager.initialise();
2022-08-25 01:51:47 +02:00
await setupLocator();
WidgetsFlutterBinding.ensureInitialized();
await locator<ManagerAPI>().initialize();
2022-07-30 21:09:59 +02:00
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DynamicThemeBuilder(
title: 'ReVanced Manager',
home: FutureBuilder<Widget>(
future: _init(context),
builder: (context, snapshot) {
if (snapshot.hasData) {
return snapshot.data!;
} else {
return Center(
child: CircularProgressIndicator(
color: Theme.of(context).colorScheme.secondary,
),
);
}
},
2022-08-11 21:05:03 +02:00
),
localizationsDelegates: [
FlutterI18nDelegate(
translationLoader: FileTranslationLoader(
fallbackFile: 'en',
basePath: 'assets/i18n',
),
),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
],
2022-07-31 10:00:11 +02:00
);
}
2022-08-14 20:40:34 +02:00
Future<Widget> _init(BuildContext context) async {
2022-08-25 01:51:47 +02:00
await locator<ManagerAPI>().initialize();
await locator<PatcherAPI>().initialize();
2022-08-25 01:51:47 +02:00
bool? isRooted = locator<ManagerAPI>().isRooted();
2022-08-14 20:40:34 +02:00
if (isRooted != null) {
2022-09-05 10:07:38 +02:00
return const NavigationView();
2022-08-14 20:40:34 +02:00
}
return const RootCheckerView();
}
2022-07-31 10:00:11 +02:00
}