diff --git a/lib/views/pages/locate_blood_banks/locate_blood_banks.dart b/lib/views/pages/locate_blood_banks/locate_blood_banks.dart index 18e1f0f..7af7dca 100644 --- a/lib/views/pages/locate_blood_banks/locate_blood_banks.dart +++ b/lib/views/pages/locate_blood_banks/locate_blood_banks.dart @@ -24,6 +24,10 @@ class _LocateBloodBanksState extends State { return Scaffold( appBar: AppBar( + leading: IconButton(onPressed: (){ + Navigator.pop(context); + }, icon: Icon(Icons.arrow_back_ios)), + centerTitle: true, title: const Text('Locate Blood Banks'), ), body: Column( diff --git a/lib/views/pages/login/login.dart b/lib/views/pages/login/login.dart index 3fe3d84..a6073f0 100644 --- a/lib/views/pages/login/login.dart +++ b/lib/views/pages/login/login.dart @@ -70,13 +70,20 @@ class _LoginPageState extends State { body: BlocConsumer( listener: (context, state) { if (state is Authenticated) { - Navigator.push( + Navigator.pushReplacement( context, - MaterialPageRoute( - builder: (context) => HomePage( + PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => HomePage( email: emailController.text, name: state.user.name, ), + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + transitionDuration: const Duration(milliseconds: 900), // Adjust duration as needed ), ); } @@ -96,7 +103,7 @@ class _LoginPageState extends State { Image.asset( 'assets/images/login.jpg', width: double.infinity, - height: double.infinity, + height: 670, fit: BoxFit.cover, ), diff --git a/lib/views/pages/main_home/home_pages/home_screen.dart b/lib/views/pages/main_home/home_pages/home_screen.dart index d12d0bd..a345540 100644 --- a/lib/views/pages/main_home/home_pages/home_screen.dart +++ b/lib/views/pages/main_home/home_pages/home_screen.dart @@ -75,9 +75,17 @@ class _HomeScreenState extends State { onPressed: () { Navigator.push( context, - MaterialPageRoute( - builder: (context) => const LocateBloodBanks(), - )); + PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => const LocateBloodBanks(), + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + transitionDuration: const Duration(milliseconds: 900), // Adjust duration as needed + ),); + }, ), HomeCard( diff --git a/lib/views/pages/main_home/homepage.dart b/lib/views/pages/main_home/homepage.dart index 9e693d5..b4a7c64 100644 --- a/lib/views/pages/main_home/homepage.dart +++ b/lib/views/pages/main_home/homepage.dart @@ -22,9 +22,8 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { - final controller = - Get.put(NavigationController(widget.name ?? "No Name", widget.email!)); - print(widget.name); + final controller = Get.put(NavigationController(widget.name ?? "No Name", widget.email!)); + return Scaffold( bottomNavigationBar: Obx( () => NavigationBar( @@ -56,7 +55,13 @@ class _HomePageState extends State { ), ), body: Obx( - () => controller.getScreens()[controller.selectedIndex.value], + () => AnimatedSwitcher( + duration: const Duration(milliseconds: 800), // Duration of the fade effect + transitionBuilder: (Widget child, Animation animation) { + return FadeTransition(opacity: animation, child: child); + }, + child: controller.getScreens()[controller.selectedIndex.value], + ), ), ); } diff --git a/lib/views/pages/profile/profile_screen.dart b/lib/views/pages/profile/profile_screen.dart index 104666f..d15c52d 100644 --- a/lib/views/pages/profile/profile_screen.dart +++ b/lib/views/pages/profile/profile_screen.dart @@ -30,6 +30,8 @@ class _ProfileScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( + automaticallyImplyLeading: false, + centerTitle: true, title: const Text('Profile'), ), body: BlocBuilder( diff --git a/lib/views/pages/register/signup.dart b/lib/views/pages/register/signup.dart index f00c84c..bd81b90 100644 --- a/lib/views/pages/register/signup.dart +++ b/lib/views/pages/register/signup.dart @@ -151,15 +151,23 @@ class _SignuppageState extends State { showSnackBar(context, state.message); } if (state is Authenticated) { - Navigator.push( + Navigator.pushReplacement( context, - MaterialPageRoute( - builder: (context) => HomePage( + PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => HomePage( name: nameController.text, email: emailController.text.trim(), ), + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + transitionDuration: const Duration(milliseconds: 900), // Adjust duration as needed ), ); + } }, builder: (context, state) { diff --git a/lib/views/pages/welcome/welcome_screen.dart b/lib/views/pages/welcome/welcome_screen.dart index 7635fb4..cbcddf6 100644 --- a/lib/views/pages/welcome/welcome_screen.dart +++ b/lib/views/pages/welcome/welcome_screen.dart @@ -10,10 +10,29 @@ class FrontPage extends StatelessWidget { var screenWidth = MediaQuery.of(context).size.width; var screenHeight = MediaQuery.of(context).size.height; + // Define the transition effect function + Route _createRoute(Widget page) { + return PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => page, + transitionsBuilder: (context, animation, secondaryAnimation, child) { + const begin = 0.0; + const end = 6.0; + const curve = Curves.easeInOut; + + var tween = Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); + return FadeTransition( + opacity: animation.drive(tween), + child: child, + ); + }, + transitionDuration: const Duration(milliseconds: 700), // Increase the duration to 700ms + ); + } + return Scaffold( body: Stack( children: [ - //IMAGE + // IMAGE Image.asset( 'assets/images/home.png', fit: BoxFit.cover, @@ -25,56 +44,49 @@ class FrontPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ InkWell( - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const Signuppage(), - )), + onTap: () => Navigator.of(context).push(_createRoute(const Signuppage())), child: Center( child: Container( height: screenHeight * 0.07, width: screenWidth * 0.85, decoration: const BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.all(Radius.circular(30))), + color: Colors.red, + borderRadius: BorderRadius.all(Radius.circular(30)), + ), child: const Center( child: Text( 'Sign up', style: TextStyle( - color: Colors.black, - fontSize: 25, - fontWeight: FontWeight.w500), + color: Colors.black, + fontSize: 25, + fontWeight: FontWeight.w500, + ), ), ), ), ), ), - const SizedBox( - height: 20, - ), + const SizedBox(height: 20), Padding( padding: EdgeInsets.only(bottom: screenHeight * 0.04), child: InkWell( - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const LoginPage(), - )), + onTap: () => Navigator.of(context).pushReplacement(_createRoute(const LoginPage())), child: Center( child: Container( height: screenHeight * 0.07, width: screenWidth * 0.85, decoration: BoxDecoration( - color: Colors.green.shade900, - borderRadius: - const BorderRadius.all(Radius.circular(30))), + color: Colors.green.shade900, + borderRadius: const BorderRadius.all(Radius.circular(30)), + ), child: const Center( child: Text( 'Login', style: TextStyle( - color: Colors.white, - fontSize: 25, - fontWeight: FontWeight.w500), + color: Colors.white, + fontSize: 25, + fontWeight: FontWeight.w500, + ), ), ), ),