2022-10-15 11:31:31 +02:00
|
|
|
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
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';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2022-08-06 23:35:35 +02:00
|
|
|
import 'package:revanced_manager/app/app.locator.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-08-29 18:44:45 +02:00
|
|
|
import 'package:revanced_manager/services/patcher_api.dart';
|
2022-09-12 02:41:53 +02:00
|
|
|
import 'package:revanced_manager/services/revanced_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';
|
2022-08-11 21:05:03 +02:00
|
|
|
import 'package:stacked_themes/stacked_themes.dart';
|
2022-10-14 20:05:33 +02:00
|
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
2022-09-20 01:03:37 +02:00
|
|
|
import 'package:timezone/data/latest.dart' as tz;
|
2022-10-15 11:31:31 +02:00
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
|
|
import 'firebase_options.dart';
|
2022-10-17 13:18:39 +02:00
|
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
2022-07-30 21:09:59 +02:00
|
|
|
|
2022-08-11 21:05:03 +02:00
|
|
|
Future main() async {
|
2022-10-17 13:18:39 +02:00
|
|
|
await dotenv.load(fileName: ".env");
|
2022-08-11 21:05:03 +02:00
|
|
|
await ThemeManager.initialise();
|
2022-08-25 01:51:47 +02:00
|
|
|
await setupLocator();
|
2022-08-12 11:42:43 +02:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2022-09-05 04:32:36 +02:00
|
|
|
await locator<ManagerAPI>().initialize();
|
2022-09-19 01:28:26 +02:00
|
|
|
String apiUrl = locator<ManagerAPI>().getApiUrl();
|
|
|
|
await locator<RevancedAPI>().initialize(apiUrl);
|
2022-10-14 22:22:10 +02:00
|
|
|
bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
|
2022-10-15 14:59:50 +02:00
|
|
|
bool isCrashlyticsEnabled = locator<ManagerAPI>().isCrashlyticsEnabled();
|
2022-10-16 20:24:07 +02:00
|
|
|
// Remove this section if you are building from source and don't have firebase config
|
2022-10-15 14:59:50 +02:00
|
|
|
if (isCrashlyticsEnabled) {
|
|
|
|
await Firebase.initializeApp(
|
|
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
|
|
);
|
|
|
|
Firebase.app().setAutomaticDataCollectionEnabled(true);
|
2022-10-16 20:13:33 +02:00
|
|
|
} else {
|
|
|
|
await Firebase.initializeApp(
|
|
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
|
|
);
|
|
|
|
Firebase.app().setAutomaticDataCollectionEnabled(false);
|
2022-10-15 14:59:50 +02:00
|
|
|
}
|
2022-09-12 02:41:53 +02:00
|
|
|
locator<GithubAPI>().initialize();
|
2022-09-19 01:28:26 +02:00
|
|
|
await locator<PatcherAPI>().initialize();
|
2022-09-20 01:03:37 +02:00
|
|
|
tz.initializeTimeZones();
|
2022-10-15 14:59:50 +02:00
|
|
|
|
2022-10-16 20:24:07 +02:00
|
|
|
// Remove this section if you are building from source and don't have sentry configured
|
2022-10-14 20:05:33 +02:00
|
|
|
await SentryFlutter.init(
|
|
|
|
(options) {
|
|
|
|
options
|
2022-10-17 13:18:39 +02:00
|
|
|
..dsn = isSentryEnabled ? dotenv.env['sentryDSN'] : ''
|
2022-10-14 20:05:33 +02:00
|
|
|
..environment = 'alpha'
|
|
|
|
..release = '0.1'
|
|
|
|
..tracesSampleRate = 1.0
|
|
|
|
..anrEnabled = true
|
|
|
|
..enableOutOfMemoryTracking = true
|
2022-10-14 22:22:10 +02:00
|
|
|
..sampleRate = isSentryEnabled ? 1.0 : 0.0
|
|
|
|
..beforeSend = (event, hint) {
|
|
|
|
if (isSentryEnabled) {
|
|
|
|
return event;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} as BeforeSendCallback?;
|
2022-10-14 20:05:33 +02:00
|
|
|
},
|
2022-10-15 11:31:31 +02:00
|
|
|
appRunner: () {
|
2022-10-15 14:59:50 +02:00
|
|
|
if (isCrashlyticsEnabled) {
|
|
|
|
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
|
|
|
|
}
|
2022-10-15 11:31:31 +02:00
|
|
|
runApp(const MyApp());
|
|
|
|
},
|
2022-10-14 20:05:33 +02:00
|
|
|
);
|
2022-07-30 21:09:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-05 04:32:36 +02:00
|
|
|
return DynamicThemeBuilder(
|
|
|
|
title: 'ReVanced Manager',
|
2022-09-06 15:40:49 +02:00
|
|
|
home: const NavigationView(),
|
2022-09-05 04:32:36 +02:00
|
|
|
localizationsDelegates: [
|
|
|
|
FlutterI18nDelegate(
|
|
|
|
translationLoader: FileTranslationLoader(
|
2022-09-25 11:08:25 +02:00
|
|
|
fallbackFile: 'en_US',
|
2022-09-05 04:32:36 +02:00
|
|
|
basePath: 'assets/i18n',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate
|
|
|
|
],
|
2022-07-31 10:00:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|