2022-11-28 08:03:13 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2022-11-28 02:26:36 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-11-28 08:03:13 +00:00
|
|
|
import 'package:device_preview/device_preview.dart';
|
2022-12-05 08:06:45 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2023-01-18 07:54:44 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-04-05 00:54:24 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
2023-03-02 05:28:33 +00:00
|
|
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
2023-02-01 08:03:05 +00:00
|
|
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
2023-02-27 06:26:27 +00:00
|
|
|
import 'package:unit2/theme-data.dart/colors.dart';
|
2023-01-23 05:46:09 +00:00
|
|
|
import 'package:unit2/utils/app_router.dart';
|
2023-01-23 03:02:59 +00:00
|
|
|
import 'package:unit2/utils/global_context.dart';
|
|
|
|
import 'package:unit2/utils/global_context.dart';
|
2023-04-05 00:54:24 +00:00
|
|
|
import 'package:path_provider/path_provider.dart' as path_provider;
|
2022-11-28 08:03:13 +00:00
|
|
|
import './utils/router.dart';
|
|
|
|
import './utils/global.dart';
|
2022-11-28 02:26:36 +00:00
|
|
|
|
2023-04-05 00:54:24 +00:00
|
|
|
Future main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
var appDirectory = await path_provider.getApplicationDocumentsDirectory();
|
|
|
|
await Hive.initFlutter(appDirectory.path);
|
|
|
|
CREDENTIALS = await Hive.openBox<dynamic>('credentials');
|
|
|
|
SOSCONTACTS = await Hive.openBox<String>('soscontacts');
|
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
|
|
|
|
.then((_) {
|
|
|
|
runApp(MyApp());
|
|
|
|
});
|
2022-11-28 02:26:36 +00:00
|
|
|
}
|
|
|
|
|
2022-11-28 08:03:13 +00:00
|
|
|
// void main() => runApp(
|
|
|
|
// DevicePreview(
|
|
|
|
// enabled: !kReleaseMode,
|
|
|
|
// builder: (context) => const MyApp(), // Wrap your app
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
|
2022-11-28 02:26:36 +00:00
|
|
|
class MyApp extends StatelessWidget {
|
2023-01-23 05:46:09 +00:00
|
|
|
AppRouter? _appRouter;
|
2022-11-28 02:26:36 +00:00
|
|
|
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-01-23 05:46:09 +00:00
|
|
|
_appRouter = AppRouter();
|
2022-11-28 08:03:13 +00:00
|
|
|
final mediaQueryData =
|
|
|
|
MediaQueryData.fromWindow(WidgetsBinding.instance.window);
|
|
|
|
screenWidth = mediaQueryData.size.width;
|
|
|
|
screenHeight = mediaQueryData.size.height;
|
|
|
|
blockSizeHorizontal = screenWidth / 100;
|
|
|
|
blockSizeVertical = screenHeight / 100;
|
|
|
|
safeAreaHorizontal =
|
|
|
|
mediaQueryData.padding.left + mediaQueryData.padding.right;
|
|
|
|
safeAreaVertical =
|
|
|
|
mediaQueryData.padding.top + mediaQueryData.padding.bottom;
|
|
|
|
safeBlockHorizontal = (screenWidth - safeAreaHorizontal) / 100;
|
|
|
|
safeBlockVertical = (screenHeight - safeAreaVertical) / 100;
|
2023-01-23 05:46:09 +00:00
|
|
|
|
2023-01-23 03:02:59 +00:00
|
|
|
return MultiBlocProvider(
|
|
|
|
providers: [
|
|
|
|
BlocProvider(
|
2023-01-23 05:46:09 +00:00
|
|
|
create: (_) => UserBloc(),
|
2023-01-23 03:02:59 +00:00
|
|
|
),
|
2023-04-05 00:54:24 +00:00
|
|
|
BlocProvider(
|
2023-03-02 05:28:33 +00:00
|
|
|
create: (_) => ProfileBloc(),
|
|
|
|
),
|
2023-01-23 03:02:59 +00:00
|
|
|
],
|
2023-01-23 05:46:09 +00:00
|
|
|
child: MaterialApp(
|
|
|
|
navigatorKey: NavigationService.navigatorKey,
|
2023-01-18 07:54:44 +00:00
|
|
|
// useInheritedMediaQuery: true,
|
|
|
|
// locale: DevicePreview.locale(context),
|
|
|
|
// builder: DevicePreview.appBuilder,
|
2023-01-23 05:46:09 +00:00
|
|
|
// routeInformationParser: goRouter.routeInformationParser,
|
|
|
|
// routerDelegate: goRouter.routerDelegate,
|
2023-01-18 07:54:44 +00:00
|
|
|
// routeInformationProvider: goRouter.routeInformationProvider,
|
2023-04-05 00:54:24 +00:00
|
|
|
|
2023-01-18 07:54:44 +00:00
|
|
|
title: 'uniT2 - Universal Tracker and Tracer',
|
|
|
|
theme: ThemeData(
|
2023-02-27 06:26:27 +00:00
|
|
|
primarySwatch: Colors.red,
|
2023-01-18 07:54:44 +00:00
|
|
|
appBarTheme: const AppBarTheme(
|
|
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
|
|
statusBarBrightness: Brightness.dark,
|
|
|
|
statusBarColor: Colors.black),
|
|
|
|
),
|
|
|
|
fontFamily: 'LexendDeca',
|
2022-12-05 08:06:45 +00:00
|
|
|
),
|
2023-01-18 07:54:44 +00:00
|
|
|
debugShowCheckedModeBanner: false,
|
2023-01-23 05:46:09 +00:00
|
|
|
onGenerateRoute: _appRouter!.onGenerateRoute,
|
2022-11-28 02:26:36 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|