2022-12-27 03:19:49 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import 'package:selfprivacy/logic/appsettingscubit.dart';
|
|
|
|
import 'package:selfprivacy/logic/config.dart';
|
|
|
|
import 'package:selfprivacy/ui/root.dart';
|
|
|
|
import 'package:wakelock/wakelock.dart';
|
|
|
|
import 'package:timezone/data/latest.dart' as tz;
|
|
|
|
|
|
|
|
class SimpleBlocObserver extends BlocObserver {
|
|
|
|
SimpleBlocObserver();
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
await HiveConfig.init();
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
|
|
|
|
|
|
try {
|
|
|
|
await Wakelock.enable();
|
|
|
|
} on PlatformException catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
await getItSetup();
|
|
|
|
tz.initializeTimeZones();
|
|
|
|
|
|
|
|
BlocOverrides.runZoned(
|
|
|
|
() => runApp(const MyApp()),
|
|
|
|
blocObserver: SimpleBlocObserver(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({
|
|
|
|
super.key,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) =>
|
|
|
|
AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle.light, // Manually changing appbar color
|
|
|
|
child: BlocAndProviderConfig(
|
|
|
|
child: BlocBuilder<AppSettingsCubit, AppSettingsState>(
|
|
|
|
builder: (
|
|
|
|
final BuildContext context,
|
|
|
|
final AppSettingsState appSettings,
|
|
|
|
) =>
|
|
|
|
MaterialApp(
|
|
|
|
scaffoldMessengerKey:
|
|
|
|
getIt.get<NavigationService>().scaffoldMessengerKey,
|
|
|
|
navigatorKey: getIt.get<NavigationService>().navigatorKey,
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: 'Admin Panel',
|
|
|
|
home: const RootPage(),
|
|
|
|
builder: (final BuildContext context, final Widget? widget) {
|
|
|
|
Widget error = const Text('...rendering error...');
|
|
|
|
if (widget is Scaffold || widget is Navigator) {
|
|
|
|
error = Scaffold(body: Center(child: error));
|
|
|
|
}
|
|
|
|
ErrorWidget.builder =
|
|
|
|
(final FlutterErrorDetails errorDetails) => error;
|
|
|
|
return widget!;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|