From b892cc485f366614036f12e7ded6152d1df03256 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 4 Apr 2025 10:06:19 +0800 Subject: [PATCH] slide transition of menu --- lib/main.dart | 114 ++++++++++++++++++++++++++++--- lib/pages/add_category_page.dart | 2 +- lib/pages/add_generics_page.dart | 2 +- lib/pages/add_manufacturer.dart | 2 +- lib/pages/add_medicine_page.dart | 2 +- lib/pages/add_type_page.dart | 2 +- lib/pages/delete_stock_page.dart | 2 +- lib/pages/main_page.dart | 2 +- 8 files changed, 113 insertions(+), 15 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 9bc75e4..d0b65a0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -84,45 +84,143 @@ final _router = GoRouter( path: '/main', builder: (context, state) => const MainPage(), ), + // GoRoute( + // name: 'addmanufactorer', + // path: '/addmanufactorer', + // builder: (context, state) => const AddManufacturerPage(), + // ), GoRoute( name: 'addmanufactorer', path: '/addmanufactorer', - builder: (context, state) => const AddManufacturerPage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const AddManufacturerPage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), + // GoRoute( + // name: 'addmedicines', + // path: '/addmedicines', + // builder: (context, state) => const AddMedicinePage(), + // ), GoRoute( name: 'addmedicines', path: '/addmedicines', - builder: (context, state) => const AddMedicinePage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const AddMedicinePage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), + // GoRoute( + // name: 'addgenerics', + // path: '/addgenerics', + // builder: (context, state) => const AddGenericsPage(), + // ), GoRoute( name: 'addgenerics', path: '/addgenerics', - builder: (context, state) => const AddGenericsPage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const AddGenericsPage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), + // GoRoute( + // name: 'addtype', + // path: '/addtype', + // builder: (context, state) => const AddTypePage(), + // ), GoRoute( name: 'addtype', path: '/addtype', - builder: (context, state) => const AddTypePage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const AddTypePage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), + // GoRoute( + // name: 'addcategory', + // path: '/addcategory', + // builder: (context, state) => const AddCategoryPage(), + // ), GoRoute( name: 'addcategory', path: '/addcategory', - builder: (context, state) => const AddCategoryPage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const AddCategoryPage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), GoRoute( name: 'addstock', path: '/addstock', builder: (context, state) => const AddStockPage(), ), - GoRoute( + // GoRoute( + // name: 'liststocks', + // path: '/liststocks', + // builder: (context, state) => const ListStocksPage(), + // ), + GoRoute( name: 'liststocks', path: '/liststocks', - builder: (context, state) => const ListStocksPage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const ListStocksPage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), + // GoRoute( + // name: 'deletestock', + // path: '/deletestock', + // builder: (context, state) => const DeleteStockPage(), + // ), GoRoute( name: 'deletestock', path: '/deletestock', - builder: (context, state) => const DeleteStockPage(), + pageBuilder: (BuildContext context, GoRouterState state) => CustomTransitionPage( + key: state.pageKey, + child: const DeleteStockPage(), + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, + Widget child) => + SlideTransition( + position: animation.drive( + Tween(begin: Offset(0.95, 0), end: Offset.zero).chain(CurveTween(curve: Curves.easeIn))), + child: child), + ), ), GoRoute( name: 'customer', diff --git a/lib/pages/add_category_page.dart b/lib/pages/add_category_page.dart index 7792f2f..6412409 100644 --- a/lib/pages/add_category_page.dart +++ b/lib/pages/add_category_page.dart @@ -44,7 +44,7 @@ class _AddCategoryPageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { - context.push('/main'); + context.pop(); } }); } else { diff --git a/lib/pages/add_generics_page.dart b/lib/pages/add_generics_page.dart index a7b49eb..3160232 100644 --- a/lib/pages/add_generics_page.dart +++ b/lib/pages/add_generics_page.dart @@ -45,7 +45,7 @@ class _AddGenericsPageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { - context.push('/main'); + context.pop(); } }); } diff --git a/lib/pages/add_manufacturer.dart b/lib/pages/add_manufacturer.dart index de6a67a..a9e6ac2 100644 --- a/lib/pages/add_manufacturer.dart +++ b/lib/pages/add_manufacturer.dart @@ -46,7 +46,7 @@ class _AddManufacturerPageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { - context.push('/main'); + context.pop(); } }); } diff --git a/lib/pages/add_medicine_page.dart b/lib/pages/add_medicine_page.dart index 3a1a0e9..fe436f0 100644 --- a/lib/pages/add_medicine_page.dart +++ b/lib/pages/add_medicine_page.dart @@ -136,7 +136,7 @@ class _AddMedicinePageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { - context.push('/main'); + context.pop(); } }); } diff --git a/lib/pages/add_type_page.dart b/lib/pages/add_type_page.dart index 69c30be..6d07acc 100644 --- a/lib/pages/add_type_page.dart +++ b/lib/pages/add_type_page.dart @@ -44,7 +44,7 @@ class _AddTypePageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { - context.push('/main'); + context.pop(); } }); } diff --git a/lib/pages/delete_stock_page.dart b/lib/pages/delete_stock_page.dart index 1e07eaf..e3078e5 100644 --- a/lib/pages/delete_stock_page.dart +++ b/lib/pages/delete_stock_page.dart @@ -43,7 +43,7 @@ class _DeleteStockPageState extends State { final result = await checkResult(context, _stockList, 'Generics'); if (result) { if (mounted) { - context.push('/main'); + context.pop(); } } else { setState(() => {}); diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index dca62d2..ac9f487 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -243,7 +243,7 @@ class _MainPageState extends State { color: 'yellow'), const Gap(40), ButtonWithProgressWidget( - trigger: _isLoading, progressText: 'Logging Out', buttonText: 'Logout', onPressed: signOut) + trigger: _isLoading, progressText: 'Logging Out', buttonText: 'Logout', onPressed: signOut), ], ), ),