90 lines
3.2 KiB
Dart
90 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:ocbo_esign_mobile/blocs/qr/qr_bloc.dart';
|
|
import 'package:ocbo_esign_mobile/blocs/user/user_bloc.dart';
|
|
import 'package:ocbo_esign_mobile/pages/approval_page.dart';
|
|
import 'package:ocbo_esign_mobile/pages/index_page.dart';
|
|
import 'package:ocbo_esign_mobile/pages/login_page.dart';
|
|
import 'package:ocbo_esign_mobile/pages/validate_detail_page.dart';
|
|
import 'package:ocbo_esign_mobile/pages/validate_page.dart';
|
|
|
|
Future<void> main() async {
|
|
await dotenv.load(fileName: ".env");
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
final _router = GoRouter(
|
|
initialLocation: '/',
|
|
routes: [
|
|
GoRoute(name: 'index', path: '/', builder: (context, state) => const IndexPage()),
|
|
GoRoute(
|
|
name: 'login',
|
|
path: '/login',
|
|
builder: (context, state) => const LoginPage(),
|
|
pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage<void>(
|
|
key: state.pageKey,
|
|
child: const LoginPage(),
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
return SlideTransition(
|
|
position: Tween<Offset>(begin: Offset(-1.0, 0.0), end: Offset.zero).animate(animation),
|
|
child: child,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
GoRoute(name: 'approval', path: '/approval', builder: (context, state) => const ApprovalPage()),
|
|
GoRoute(
|
|
name: 'validate',
|
|
path: '/validate',
|
|
builder: (context, state) => const ValidatePage(),
|
|
pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage<void>(
|
|
key: state.pageKey,
|
|
child: const ValidatePage(),
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
return SlideTransition(
|
|
position: Tween<Offset>(begin: Offset(1.0, 0.0), end: Offset.zero).animate(animation),
|
|
child: child,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
// GoRoute(name: 'validate', path: '/validate', builder: (context, state) => const ValidatePage()),
|
|
// GoRoute(name: 'details', path: '/details', builder: (context, state) => const ValidateDetailPage()),
|
|
GoRoute(
|
|
name: 'details',
|
|
path: '/details',
|
|
builder: (context, state) => const ValidateDetailPage(),
|
|
pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage<void>(
|
|
key: state.pageKey,
|
|
child: const ValidateDetailPage(),
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
return SlideTransition(
|
|
position: Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset.zero).animate(animation),
|
|
child: child,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MultiBlocProvider(
|
|
providers: [
|
|
BlocProvider(create: (context) => UserBloc()),
|
|
BlocProvider(create: (context) => QrBloc()),
|
|
],
|
|
child: MaterialApp.router(
|
|
debugShowCheckedModeBanner: false,
|
|
theme: ThemeData(useMaterial3: true),
|
|
routerConfig: _router,
|
|
),
|
|
);
|
|
}
|
|
}
|