112 lines
3.5 KiB
Dart
112 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../features/dashboard/dashboard_screen.dart';
|
|
import '../features/map/map_screen.dart';
|
|
import '../features/history/history_screen.dart';
|
|
import '../features/records/records_screen.dart';
|
|
import '../features/settings/settings_screen.dart';
|
|
import '../features/settings/diagnostics_screen.dart';
|
|
import '../features/garage/garage_screen.dart';
|
|
import '../features/garage/add_motorcycle_screen.dart';
|
|
import '../features/garage/motorcycle_detail_screen.dart';
|
|
import 'widgets/main_layout.dart';
|
|
|
|
import '../features/settings/field_test_report_screen.dart';
|
|
import '../features/settings/field_test_live_log_screen.dart';
|
|
|
|
// ignore: unused_element
|
|
final _rootNavigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
final appRouter = GoRouter(
|
|
initialLocation: '/',
|
|
routes: [
|
|
StatefulShellRoute.indexedStack(
|
|
builder: (context, state, navigationShell) {
|
|
return MainLayout(navigationShell: navigationShell);
|
|
},
|
|
branches: [
|
|
StatefulShellBranch(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/',
|
|
builder: (context, state) => const DashboardScreen(),
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/map',
|
|
builder: (context, state) => const MapScreen(),
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/history',
|
|
builder: (context, state) => const HistoryScreen(),
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/records',
|
|
builder: (context, state) => const RecordsScreen(),
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/garage',
|
|
builder: (context, state) => const GarageScreen(),
|
|
routes: [
|
|
GoRoute(
|
|
path: 'add',
|
|
builder: (context, state) => const AddMotorcycleScreen(),
|
|
),
|
|
GoRoute(
|
|
path: ':id',
|
|
builder: (context, state) {
|
|
final id = int.parse(state.pathParameters['id']!);
|
|
return MotorcycleDetailScreen(motorcycleId: id);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
routes: [
|
|
GoRoute(
|
|
path: '/settings',
|
|
builder: (context, state) => const SettingsScreen(),
|
|
routes: [
|
|
GoRoute(
|
|
path: 'diagnostics',
|
|
builder: (context, state) => const DiagnosticsScreen(),
|
|
),
|
|
GoRoute(
|
|
path: 'field-test-report',
|
|
builder: (context, state) {
|
|
final sessionId = state.uri.queryParameters['sessionId'] != null
|
|
? int.tryParse(state.uri.queryParameters['sessionId']!)
|
|
: null;
|
|
return FieldTestReportScreen(sessionId: sessionId);
|
|
},
|
|
),
|
|
GoRoute(
|
|
path: 'field-test-live-log',
|
|
builder: (context, state) => const FieldTestLiveLogScreen(),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|