import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:moody/utils/slide_direction.dart'; import 'package:moody/utils/widgets/question_slider_widget.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/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, const StartPage()), ), GoRoute( path: '/moods', builder: (context, state) => const StatisticPage(), ), GoRoute( path: '/settings', pageBuilder: (context, state) => _noAnimationTransition(context, state, const SettingsPage()), ), GoRoute( path: '/statistic', // ignore: prefer_const_constructors pageBuilder: (context, state) => _noAnimationTransition(context, state, StatisticPage()), ), GoRoute( path: '/home', pageBuilder: (context, state) => _noAnimationTransition(context, state, const HomePage()), ), GoRoute( path: '/first', pageBuilder: (context, state) => _noAnimationTransition(context, state, const FirstPage()), ), GoRoute( path: '/color', pageBuilder: (context, state) => _noAnimationTransition(context, state, const ColorPage()), ), GoRoute( path: '/write', builder: (context, state) { final sliderdata = state.extra as SliderChangeData; return WritePage(sliderData: sliderdata); }, ), 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, ); } } /* A Slide Transition that will may be used in future versions 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) { 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; }, ); }