testsAndMisc-archive/horatio/horatio_app/lib/router.dart
Krzysztof kuhy Rudnicki 68d47d8574 feat(horatio): add Horatio actor script memorization app
Two-package monorepo:
- horatio_core: pure Dart package (parser, SRS, planner)
- horatio_app: Flutter UI (Bloc/Cubit, GoRouter, TTS)

Features:
- Script import (txt, docx, pdf) with drag-and-drop
- Four script format parsers (colon, bracketed, parenthetical, screenplay)
- SM-2 spaced repetition for line memorization
- Rehearsal mode with TTS and line comparison
- 5 bundled public domain scripts

Quality:
- 83 core tests + 160 app tests, both 100% branch coverage
- Strict analysis (130+ lint rules, fatal-infos)
- Dead code detection script (dead_code.sh)
- run.sh pipeline: analyze, test, dead-code, run, web
- Pre-commit hook for horatio test coverage
2026-03-29 14:44:57 +02:00

101 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:horatio_app/screens/home_screen.dart';
import 'package:horatio_app/screens/import_screen.dart';
import 'package:horatio_app/screens/rehearsal_screen.dart';
import 'package:horatio_app/screens/role_selection_screen.dart';
import 'package:horatio_app/screens/schedule_screen.dart';
import 'package:horatio_app/screens/srs_review_screen.dart';
import 'package:horatio_core/horatio_core.dart';
/// Route paths.
abstract final class RoutePaths {
/// Home / script library.
static const String home = '/';
/// Import a new script.
static const String import_ = '/import';
/// Select a role after importing a script.
static const String roleSelection = '/role-selection';
/// View memorization schedule.
static const String schedule = '/schedule';
/// Interactive rehearsal mode.
static const String rehearsal = '/rehearsal';
/// SRS flashcard review.
static const String srsReview = '/srs-review';
}
/// Application router configuration.
final GoRouter appRouter = GoRouter(
routes: [
GoRoute(
path: RoutePaths.home,
builder: (context, state) => const HomeScreen(),
),
GoRoute(
path: RoutePaths.import_,
builder: (context, state) => const ImportScreen(),
),
GoRoute(
path: RoutePaths.roleSelection,
redirect: (context, state) =>
state.extra == null ? RoutePaths.home : null,
builder: (context, state) {
if (state.extra case final Script script) {
return RoleSelectionScreen(script: script);
}
return const SizedBox.shrink();
},
),
GoRoute(
path: RoutePaths.schedule,
redirect: (context, state) =>
state.extra == null ? RoutePaths.home : null,
builder: (context, state) {
if (state.extra case final Map<String, Object> extra) {
return ScheduleScreen(
script: extra['script']! as Script,
selectedRole: extra['role']! as Role,
);
}
return const SizedBox.shrink();
},
),
GoRoute(
path: RoutePaths.rehearsal,
redirect: (context, state) =>
state.extra == null ? RoutePaths.home : null,
builder: (context, state) {
if (state.extra case final Map<String, Object> extra) {
return RehearsalScreen(
script: extra['script']! as Script,
selectedRole: extra['role']! as Role,
);
}
return const SizedBox.shrink();
},
),
GoRoute(
path: RoutePaths.srsReview,
redirect: (context, state) =>
state.extra == null ? RoutePaths.home : null,
builder: (context, state) {
if (state.extra case final List<SrsCard> cards) {
return SrsReviewScreen(cards: cards);
}
return const SizedBox.shrink();
},
),
],
errorBuilder: (context, state) => Scaffold(
appBar: AppBar(title: const Text('Not Found')),
body: Center(
child: Text('Page not found: ${state.uri}'),
),
),
);