|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_portfolio/routing/routs.dart'; |
| 3 | +import 'package:flutter_portfolio/view/main/main_view.dart'; |
| 4 | +import 'package:flutter_portfolio/view/projects/components/project_details_view.dart'; |
| 5 | +import 'package:flutter_portfolio/view/projects/components/project_media_widgets.dart'; |
| 6 | +import 'package:flutter_portfolio/view/splash/splash_view.dart'; |
| 7 | +import 'package:go_router/go_router.dart'; |
| 8 | +import 'package:flutter_portfolio/model/projects_models_list.dart'; |
| 9 | + |
| 10 | +class AppRouter { |
| 11 | + static final rootNavigatorKey = GlobalKey<NavigatorState>(); |
| 12 | + |
| 13 | + static final router = GoRouter( |
| 14 | + initialLocation: RoutePaths.splash, |
| 15 | + navigatorKey: rootNavigatorKey, |
| 16 | + debugLogDiagnostics: true, |
| 17 | + routes: [ |
| 18 | + GoRoute( |
| 19 | + path: RoutePaths.splash, |
| 20 | + builder: (context, state) => const SplashView(), |
| 21 | + ), |
| 22 | + GoRoute( |
| 23 | + path: RoutePaths.main, |
| 24 | + builder: (context, state) => const MainView(), |
| 25 | + ), |
| 26 | + GoRoute( |
| 27 | + path: RoutePaths.projectDetails, |
| 28 | + builder: (context, state) { |
| 29 | + final idStr = state.pathParameters['id']!; |
| 30 | + final id = int.parse(idStr); |
| 31 | + final p = projectList[id]; |
| 32 | + return ProjectDetailsView( |
| 33 | + projectId: id, |
| 34 | + name: p.name, |
| 35 | + description: p.description, |
| 36 | + images: p.images, |
| 37 | + videos: p.videos, |
| 38 | + featureModels: p.featureModelsList, |
| 39 | + githubLink: p.link, |
| 40 | + ); |
| 41 | + }, |
| 42 | + routes: [ |
| 43 | + GoRoute( |
| 44 | + path: 'viewer/:imageIndex', |
| 45 | + builder: (context, state) { |
| 46 | + final idStr = state.pathParameters['id']!; |
| 47 | + final id = int.parse(idStr); |
| 48 | + final indexStr = state.pathParameters['imageIndex']!; |
| 49 | + final imageIndex = int.parse(indexStr); |
| 50 | + final images = projectList[id].images; |
| 51 | + return ImageGalleryDialog( |
| 52 | + images: images, |
| 53 | + initialIndex: imageIndex, |
| 54 | + ); |
| 55 | + }, |
| 56 | + ), |
| 57 | + ], |
| 58 | + ), |
| 59 | + ], |
| 60 | + ); |
| 61 | +} |
0 commit comments