2023-01-23 05:46:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-09-01 03:22:48 +00:00
|
|
|
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
|
2023-02-01 08:03:05 +00:00
|
|
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
2023-06-21 00:22:43 +00:00
|
|
|
import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart';
|
2023-04-11 06:08:10 +00:00
|
|
|
import 'package:unit2/bloc/sos/sos_bloc.dart';
|
2023-09-01 03:22:48 +00:00
|
|
|
import 'package:unit2/model/passo/property_info.dart';
|
|
|
|
import 'package:unit2/screens/passo/passo_dashboard.dart';
|
|
|
|
import 'package:unit2/screens/passo/building_home.dart';
|
2023-04-11 06:08:10 +00:00
|
|
|
import 'package:unit2/screens/sos/index.dart';
|
2023-07-28 02:21:42 +00:00
|
|
|
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart';
|
2023-02-01 08:03:05 +00:00
|
|
|
import 'package:unit2/screens/unit2/homepage.dart/components/menu.dart';
|
2023-01-23 05:46:09 +00:00
|
|
|
import 'package:unit2/screens/unit2/login/login.dart';
|
2023-07-28 02:21:42 +00:00
|
|
|
import 'package:unit2/screens/unit2/roles/rbac/rbac.dart';
|
2023-01-23 05:46:09 +00:00
|
|
|
import 'package:unit2/utils/global_context.dart';
|
2023-07-28 02:21:42 +00:00
|
|
|
import '../bloc/rbac/rbac_bloc.dart';
|
2023-02-01 08:03:05 +00:00
|
|
|
import '../bloc/user/user_bloc.dart';
|
2023-01-26 02:15:00 +00:00
|
|
|
import '../screens/profile/profile.dart';
|
2023-01-23 08:23:20 +00:00
|
|
|
import '../screens/unit2/basic-info/basic-info.dart';
|
2023-01-23 05:46:09 +00:00
|
|
|
import '../screens/unit2/homepage.dart/components/drawer-screen.dart';
|
2023-01-23 08:23:20 +00:00
|
|
|
import '../screens/unit2/login/qr_login.dart';
|
2023-06-06 06:54:51 +00:00
|
|
|
import '../screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart';
|
2023-01-23 05:46:09 +00:00
|
|
|
|
|
|
|
class AppRouter {
|
|
|
|
Route onGenerateRoute(RouteSettings routeSettings) {
|
|
|
|
switch (routeSettings.name) {
|
|
|
|
case '/':
|
|
|
|
BlocProvider.of<UserBloc>(
|
|
|
|
NavigationService.navigatorKey.currentContext!)
|
|
|
|
.add(GetApkVersion());
|
|
|
|
return MaterialPageRoute(builder: (_) {
|
|
|
|
return const UniT2Login();
|
|
|
|
});
|
|
|
|
case '/module-screen':
|
2023-01-26 02:15:00 +00:00
|
|
|
// BlocProvider.of<UserBloc>( NavigationService.navigatorKey.currentContext!).add(LoadLoggedInUser());
|
2023-01-23 05:46:09 +00:00
|
|
|
return MaterialPageRoute(builder: (_) {
|
|
|
|
return const DrawerScreen();
|
|
|
|
});
|
2023-01-23 08:23:20 +00:00
|
|
|
case '/basic-info':
|
2023-01-26 02:15:00 +00:00
|
|
|
return MaterialPageRoute(builder: (_) {
|
|
|
|
return const BasicInfo();
|
|
|
|
});
|
2023-01-23 08:23:20 +00:00
|
|
|
case '/qr-login':
|
2023-01-26 02:15:00 +00:00
|
|
|
return MaterialPageRoute(builder: (_) {
|
|
|
|
return const QRLogin();
|
|
|
|
});
|
|
|
|
case '/profile':
|
2023-04-11 06:08:10 +00:00
|
|
|
ProfileArguments arguments =
|
|
|
|
routeSettings.arguments as ProfileArguments;
|
|
|
|
BlocProvider.of<ProfileBloc>(
|
2023-03-02 05:28:33 +00:00
|
|
|
NavigationService.navigatorKey.currentContext!)
|
2023-04-11 06:08:10 +00:00
|
|
|
.add(LoadProfile(token: arguments.token, userID: arguments.userID));
|
2023-01-26 02:15:00 +00:00
|
|
|
return MaterialPageRoute(builder: (_) {
|
2023-03-02 05:28:33 +00:00
|
|
|
return const ProfileInfo();
|
2023-01-26 02:15:00 +00:00
|
|
|
});
|
2023-04-11 06:08:10 +00:00
|
|
|
case '/sos':
|
|
|
|
return MaterialPageRoute(builder: (BuildContext context) {
|
2023-06-21 00:22:43 +00:00
|
|
|
return BlocProvider(
|
2023-04-13 08:45:19 +00:00
|
|
|
create: (_) => SosBloc()..add(LoadUserLocation()),
|
2023-04-11 06:08:10 +00:00
|
|
|
child: const SosScreen(),
|
|
|
|
);
|
|
|
|
});
|
2023-06-21 00:22:43 +00:00
|
|
|
case '/pass-check':
|
2023-07-28 02:35:36 +00:00
|
|
|
PassCheckArguments arguments =
|
|
|
|
routeSettings.arguments as PassCheckArguments;
|
2023-06-21 00:22:43 +00:00
|
|
|
return MaterialPageRoute(builder: (BuildContext context) {
|
2023-07-28 02:35:36 +00:00
|
|
|
return BlocProvider(
|
|
|
|
create: (context) => PassCheckBloc()
|
|
|
|
..add(GetPassCheckAreas(
|
|
|
|
roleId: arguments.roleId, userId: arguments.userId)),
|
|
|
|
child: QRCodeScannerSettings(
|
|
|
|
roleId: arguments.roleId,
|
|
|
|
userId: arguments.userId,
|
|
|
|
),
|
2023-06-21 00:22:43 +00:00
|
|
|
);
|
|
|
|
});
|
2023-07-28 02:35:36 +00:00
|
|
|
case '/passo-home':
|
2023-09-01 03:22:48 +00:00
|
|
|
return MaterialPageRoute(builder: (BuildContext context) {
|
|
|
|
return PassoDashBoard();
|
|
|
|
});
|
|
|
|
// BlocProvider.of<UserBloc>( NavigationService.navigatorKey.currentContext!).add(LoadLoggedInUser());
|
|
|
|
// return MaterialPageRoute(builder: (_) {
|
|
|
|
// return const PassoHome();
|
|
|
|
// });
|
|
|
|
case '/rbac':
|
|
|
|
return MaterialPageRoute(builder: (BuildContext context) {
|
|
|
|
return BlocProvider(
|
|
|
|
create: (_) => RbacBloc()..add(SetRbacScreen()),
|
|
|
|
child: const RBACScreen(),
|
2023-06-21 00:22:43 +00:00
|
|
|
);
|
2023-07-28 02:35:36 +00:00
|
|
|
});
|
2023-01-23 05:46:09 +00:00
|
|
|
default:
|
|
|
|
return MaterialPageRoute(builder: (context) {
|
|
|
|
return Container();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|