maps/mobile/lib/app/router.dart
2026-03-30 09:22:16 +02:00

55 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../features/map/presentation/screens/map_screen.dart';
import '../features/search/presentation/screens/search_screen.dart';
import '../features/routing/presentation/screens/route_screen.dart';
import '../features/settings/presentation/screens/settings_screen.dart';
import '../features/offline/presentation/screens/offline_screen.dart';
import '../features/places/presentation/screens/place_detail_screen.dart';
final routerConfig = GoRouter(
initialLocation: '/',
routes: [
GoRoute(
path: '/',
builder: (context, state) => const MapScreen(),
),
GoRoute(
path: '/search',
pageBuilder: (context, state) => CustomTransitionPage(
key: state.pageKey,
child: const SearchScreen(),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(opacity: animation, child: child);
},
),
),
GoRoute(
path: '/route',
builder: (context, state) {
final extra = state.extra as Map<String, dynamic>?;
return RouteScreen(
destinationLat: extra?['destLat'] as double?,
destinationLon: extra?['destLon'] as double?,
destinationName: extra?['destName'] as String?,
);
},
),
GoRoute(
path: '/settings',
builder: (context, state) => const SettingsScreen(),
),
GoRoute(
path: '/offline',
builder: (context, state) => const OfflineScreen(),
),
GoRoute(
path: '/place/:osmType/:osmId',
builder: (context, state) {
final osmType = state.pathParameters['osmType']!;
final osmId = int.parse(state.pathParameters['osmId']!);
return PlaceDetailScreen(osmType: osmType, osmId: osmId);
},
),
],
);