Skip to content

Commit 64e12f7

Browse files
authored
Merge pull request #510 from DevKor-github/codexd/slide-home-mypage-transition
2 parents 356c8ef + d98bf2c commit 64e12f7

1 file changed

Lines changed: 48 additions & 3 deletions

File tree

lib/presentation/shared/router/go_router.dart

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:flutter/widgets.dart';
1+
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:go_router/go_router.dart';
44
import 'package:on_time_front/core/di/di_setup.dart';
@@ -112,8 +112,22 @@ GoRouter goRouterConfig(
112112
ShellRoute(
113113
builder: (context, state, child) => BottomNavBarScaffold(child: child),
114114
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+
),
117131
],
118132
),
119133
GoRoute(
@@ -177,6 +191,37 @@ GoRouter goRouterConfig(
177191
);
178192
}
179193

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+
180225
class _ScheduleStartRouteGate extends StatefulWidget {
181226
final Map<String, dynamic>? extra;
182227

0 commit comments

Comments
 (0)