import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:moody/utils/SlideDirection.dart'; import 'package:moody/views/color_page/color_page.dart'; import 'package:moody/views/entry_view/entry_page.dart'; import 'package:moody/views/first_page/first_page.dart'; import 'package:moody/views/home_page/home_page.dart'; import 'package:moody/views/home_page/kalendartryhome_page.dart'; import 'package:moody/views/settings_page/settings_page.dart'; import 'package:moody/views/start_page/start_page.dart'; import 'package:moody/views/statistic/statistic_page.dart'; import 'package:moody/views/write_page/write_page.dart'; void main() => runApp(const MyApp()); final GoRouter _router = GoRouter( routes: [ GoRoute( path: '/', pageBuilder: (context, state) => _noAnimationTransition(context, state, StartPage()), ), GoRoute( path: '/moods', builder: (context, state) => CalendarPage(), ), GoRoute( path: '/settings', pageBuilder: (context, state) => _noAnimationTransition(context, state, SettingsPage()), ), GoRoute( path: '/statistic', pageBuilder: (context, state) => _noAnimationTransition(context, state, StatisticPage()), ), GoRoute( path: '/home', pageBuilder: (context, state) => _noAnimationTransition(context, state, HomePage()), ), GoRoute( path: '/first', pageBuilder: (context, state) => _noAnimationTransition(context, state, FirstPage()), ), GoRoute( path: '/color', pageBuilder: (context, state) => _noAnimationTransition(context, state, ColorPage()), ), GoRoute( path: '/write', builder: (context, state) { final moodPercentage = state.extra as double; return WritePage(moodPercentage: moodPercentage); }, ), GoRoute( path: '/entry', builder: (context, state) { final date = state.extra as DateTime; return EntryPage( date: date, ); }, ), ], ); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp.router( theme: ThemeData(fontFamily: 'ABCFavorit'), routerConfig: _router, ); } } CustomTransitionPage _createSlideTransition(BuildContext context, GoRouterState state, Widget child, SlideDirection direction) { var beginOffset = direction == SlideDirection.left ? Offset(1.0, 0.0) : Offset(-1.0, 0.0); return CustomTransitionPage( key: state.pageKey, child: child, transitionsBuilder: (context, animation, secondaryAnimation, child) { var end = Offset.zero; var curve = Curves.easeInOut; var tween = Tween(begin: beginOffset, end: end).chain(CurveTween(curve: curve)); var offsetAnimation = animation.drive(tween); return SlideTransition( position: offsetAnimation, child: child, ); }, ); } SlideDirection determineSlideDirection( String currentRoute, String targetRoute) { print(currentRoute); print(targetRoute); if (currentRoute == targetRoute) { print("Sameroute pls fix!!"); } if (targetRoute == "/statistic") { return SlideDirection.right; } else if (targetRoute == "/settings") { return SlideDirection.left; } else if (targetRoute == "/") { if (currentRoute == "/statistic") { return SlideDirection.left; } else if (currentRoute == "/settings") { return SlideDirection.right; } } return currentRoute.compareTo(targetRoute) < 0 ? SlideDirection.left : SlideDirection.right; } CustomTransitionPage _noAnimationTransition( BuildContext context, GoRouterState state, Widget child) { return CustomTransitionPage( key: state.pageKey, child: child, transitionsBuilder: (context, animation, secondaryAnimation, child) { // Simply return the child with no animation return child; }, ); }