From d98bf2c18ce17fa366f6553ed54b2265ac84d494 Mon Sep 17 00:00:00 2001 From: jjoonleo Date: Mon, 11 May 2026 19:34:13 +0900 Subject: [PATCH] feat: add sliding home mypage transition --- lib/presentation/shared/router/go_router.dart | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/lib/presentation/shared/router/go_router.dart b/lib/presentation/shared/router/go_router.dart index 0f3d763e..93162eba 100644 --- a/lib/presentation/shared/router/go_router.dart +++ b/lib/presentation/shared/router/go_router.dart @@ -1,4 +1,4 @@ -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:on_time_front/core/di/di_setup.dart'; @@ -112,8 +112,22 @@ GoRouter goRouterConfig( ShellRoute( builder: (context, state, child) => BottomNavBarScaffold(child: child), routes: [ - GoRoute(path: '/home', builder: (context, state) => HomeScreenTmp()), - GoRoute(path: '/myPage', builder: (context, state) => MyPageScreen()), + GoRoute( + path: '/home', + pageBuilder: (context, state) => _buildBottomNavSlidePage( + state: state, + beginOffset: const Offset(-1, 0), + child: HomeScreenTmp(), + ), + ), + GoRoute( + path: '/myPage', + pageBuilder: (context, state) => _buildBottomNavSlidePage( + state: state, + beginOffset: const Offset(1, 0), + child: MyPageScreen(), + ), + ), ], ), GoRoute( @@ -177,6 +191,37 @@ GoRouter goRouterConfig( ); } +CustomTransitionPage _buildBottomNavSlidePage({ + required GoRouterState state, + required Offset beginOffset, + required Widget child, +}) { + final slideTween = Tween( + begin: beginOffset, + end: Offset.zero, + ).chain(CurveTween(curve: Curves.easeOutCubic)); + final secondarySlideTween = Tween( + begin: Offset.zero, + end: beginOffset, + ).chain(CurveTween(curve: Curves.easeOutCubic)); + + return CustomTransitionPage( + key: state.pageKey, + transitionDuration: const Duration(milliseconds: 280), + reverseTransitionDuration: const Duration(milliseconds: 280), + child: child, + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return SlideTransition( + position: secondaryAnimation.drive(secondarySlideTween), + child: SlideTransition( + position: animation.drive(slideTween), + child: child, + ), + ); + }, + ); +} + class _ScheduleStartRouteGate extends StatefulWidget { final Map? extra;