51 lines
1.9 KiB
Dart
51 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
|
import 'package:unit2/screens/unit2/homepage.dart/components/menu.dart';
|
|
import 'package:unit2/screens/unit2/login/login.dart';
|
|
import 'package:unit2/utils/global_context.dart';
|
|
import '../bloc/user/user_bloc.dart';
|
|
import '../screens/profile/profile.dart';
|
|
import '../screens/unit2/basic-info/basic-info.dart';
|
|
import '../screens/unit2/homepage.dart/components/drawer-screen.dart';
|
|
import '../screens/unit2/login/qr_login.dart';
|
|
|
|
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':
|
|
// BlocProvider.of<UserBloc>( NavigationService.navigatorKey.currentContext!).add(LoadLoggedInUser());
|
|
return MaterialPageRoute(builder: (_) {
|
|
return const DrawerScreen();
|
|
});
|
|
case '/basic-info':
|
|
return MaterialPageRoute(builder: (_) {
|
|
return const BasicInfo();
|
|
});
|
|
case '/qr-login':
|
|
return MaterialPageRoute(builder: (_) {
|
|
return const QRLogin();
|
|
});
|
|
case '/profile':
|
|
return MaterialPageRoute(builder: (_) {
|
|
ProfileArguments arguments = routeSettings.arguments as ProfileArguments;
|
|
return BlocProvider(
|
|
create: (context) => ProfileBloc()..add(LoadProfile(token: arguments.token,userID: arguments.userID)),
|
|
child: const ProfileInfo(),
|
|
);
|
|
});
|
|
default:
|
|
return MaterialPageRoute(builder: (context) {
|
|
return Container();
|
|
});
|
|
}
|
|
}
|
|
}
|