|
1 | | -import 'package:flutter/widgets.dart'; |
| 1 | +import 'package:flutter/material.dart'; |
2 | 2 | import 'package:flutter_bloc/flutter_bloc.dart'; |
3 | 3 | import 'package:go_router/go_router.dart'; |
4 | 4 | import 'package:on_time_front/core/di/di_setup.dart'; |
@@ -112,8 +112,22 @@ GoRouter goRouterConfig( |
112 | 112 | ShellRoute( |
113 | 113 | builder: (context, state, child) => BottomNavBarScaffold(child: child), |
114 | 114 | routes: [ |
115 | | - GoRoute(path: '/home', builder: (context, state) => HomeScreenTmp()), |
116 | | - GoRoute(path: '/myPage', builder: (context, state) => MyPageScreen()), |
| 115 | + GoRoute( |
| 116 | + path: '/home', |
| 117 | + pageBuilder: (context, state) => _buildBottomNavSlidePage( |
| 118 | + state: state, |
| 119 | + beginOffset: const Offset(-1, 0), |
| 120 | + child: HomeScreenTmp(), |
| 121 | + ), |
| 122 | + ), |
| 123 | + GoRoute( |
| 124 | + path: '/myPage', |
| 125 | + pageBuilder: (context, state) => _buildBottomNavSlidePage( |
| 126 | + state: state, |
| 127 | + beginOffset: const Offset(1, 0), |
| 128 | + child: MyPageScreen(), |
| 129 | + ), |
| 130 | + ), |
117 | 131 | ], |
118 | 132 | ), |
119 | 133 | GoRoute( |
@@ -177,6 +191,37 @@ GoRouter goRouterConfig( |
177 | 191 | ); |
178 | 192 | } |
179 | 193 |
|
| 194 | +CustomTransitionPage<void> _buildBottomNavSlidePage({ |
| 195 | + required GoRouterState state, |
| 196 | + required Offset beginOffset, |
| 197 | + required Widget child, |
| 198 | +}) { |
| 199 | + final slideTween = Tween<Offset>( |
| 200 | + begin: beginOffset, |
| 201 | + end: Offset.zero, |
| 202 | + ).chain(CurveTween(curve: Curves.easeOutCubic)); |
| 203 | + final secondarySlideTween = Tween<Offset>( |
| 204 | + begin: Offset.zero, |
| 205 | + end: beginOffset, |
| 206 | + ).chain(CurveTween(curve: Curves.easeOutCubic)); |
| 207 | + |
| 208 | + return CustomTransitionPage<void>( |
| 209 | + key: state.pageKey, |
| 210 | + transitionDuration: const Duration(milliseconds: 280), |
| 211 | + reverseTransitionDuration: const Duration(milliseconds: 280), |
| 212 | + child: child, |
| 213 | + transitionsBuilder: (context, animation, secondaryAnimation, child) { |
| 214 | + return SlideTransition( |
| 215 | + position: secondaryAnimation.drive(secondarySlideTween), |
| 216 | + child: SlideTransition( |
| 217 | + position: animation.drive(slideTween), |
| 218 | + child: child, |
| 219 | + ), |
| 220 | + ); |
| 221 | + }, |
| 222 | + ); |
| 223 | +} |
| 224 | + |
180 | 225 | class _ScheduleStartRouteGate extends StatefulWidget { |
181 | 226 | final Map<String, dynamic>? extra; |
182 | 227 |
|
|
0 commit comments