125 lines
4.0 KiB
Dart
125 lines
4.0 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:manager_app/Models/managerContext.dart';
|
|
import 'package:manager_app/Screens/Main/main_screen.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:responsive_framework/responsive_framework.dart';
|
|
import 'Helpers/FileHelper.dart';
|
|
import 'Models/session.dart';
|
|
import 'Screens/login_screen.dart';
|
|
import 'Screens/Policy/policy_screen.dart';
|
|
import 'app_context.dart';
|
|
import 'constants.dart';
|
|
//import 'package:window_size/window_size.dart';
|
|
|
|
Future<void> main() async {
|
|
String initialRoute;
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
initialRoute = '/login';
|
|
|
|
var session = await loadJsonSessionFile();
|
|
|
|
ManagerAppContext managerAppContext = new ManagerAppContext();
|
|
|
|
final MyApp myApp = MyApp(
|
|
initialRoute: initialRoute,
|
|
session: session,
|
|
managerAppContext: managerAppContext
|
|
//context: localContext,
|
|
);
|
|
|
|
await Firebase.initializeApp(
|
|
// Replace with actual values
|
|
options: FirebaseOptions(
|
|
apiKey: "AIzaSyCFXuDsslqHiPpK6WTcxdIvTDP3ioaaxp4",
|
|
authDomain: "mymuseum-3b97f.firebaseapp.com",
|
|
projectId: "mymuseum-3b97f",
|
|
storageBucket: "mymuseum-3b97f.appspot.com",
|
|
messagingSenderId: "1034665398515",
|
|
appId: "1:1034665398515:web:688e2a7b3465e621d6a786",
|
|
measurementId: "G-EKKHJLJ1E9"
|
|
),
|
|
);
|
|
|
|
runApp(myApp);
|
|
}
|
|
|
|
class MyApp extends StatefulWidget {
|
|
final String initialRoute;
|
|
final Session session;
|
|
final ManagerAppContext managerAppContext;
|
|
MyApp({required this.initialRoute, required this.session, required this.managerAppContext});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
_MyAppState createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
final GlobalKey<_MyAppState> mainKey = GlobalKey();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider<AppContext>(
|
|
create: (_) => AppContext(widget.managerAppContext),
|
|
child: MaterialApp(
|
|
key: mainKey,
|
|
builder: (context, child) => ResponsiveBreakpoints.builder(
|
|
child: child!,
|
|
breakpoints: [
|
|
const Breakpoint(start: 0, end: 450, name: MOBILE),
|
|
const Breakpoint(start: 451, end: 800, name: TABLET),
|
|
const Breakpoint(start: 801, end: 1920, name: DESKTOP),
|
|
const Breakpoint(start: 1921, end: double.infinity, name: '4K'),
|
|
],
|
|
),
|
|
scrollBehavior: MyCustomScrollBehavior(),
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'MyInfoMate - Manager',
|
|
initialRoute: widget.initialRoute,
|
|
/*supportedLocales: [
|
|
const Locale('en', 'US'),
|
|
//const Locale('fr', 'FR'),
|
|
],*/
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.blue,
|
|
primaryColor: kPrimaryColor,
|
|
scaffoldBackgroundColor: kBackgroundColor,
|
|
//fontFamily: "Vollkorn",
|
|
textTheme: TextTheme(bodyLarge: TextStyle(color: kBodyTextColor)),
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
),
|
|
routes: {
|
|
'/login': (context) => LoginScreen(session: widget.session),
|
|
'/main': (context) => MainScreen(),
|
|
'/policy': (context) => PolicyScreen(),
|
|
'/policy/mdlf': (context) => PolicyScreen(param: "mdlf"),
|
|
'/policy/fort': (context) => PolicyScreen(param: "fort"),
|
|
},
|
|
onUnknownRoute: (settings) => MaterialPageRoute(
|
|
builder: (context) => Container(child: Center(child: Text("Not found"))),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<Session> loadJsonSessionFile() async {
|
|
Session session = await FileHelper().readSession();
|
|
//print(session);
|
|
return session;
|
|
}
|
|
|
|
class MyCustomScrollBehavior extends MaterialScrollBehavior {
|
|
// Override behavior methods and getters like dragDevices
|
|
@override
|
|
Set<PointerDeviceKind> get dragDevices => {
|
|
PointerDeviceKind.touch,
|
|
PointerDeviceKind.mouse,
|
|
};
|
|
}
|