testsAndMisc-archive/horatio/horatio_app/lib/app.dart
Krzysztof kuhy Rudnicki 85edd6ba02 feat: annotations subsystem — core models, drift DB, cubits, and UI
Add the complete annotations feature for marking and annotating script text:

Core models (horatio_core):
- TextMark, LineNote, AnnotationSnapshot, MarkType, NoteCategory
- Script.id field + UUID generation in text_parser

Database layer (horatio_app):
- Drift tables: text_marks, line_notes, annotation_snapshots
- AppDatabase with AnnotationDao (full CRUD + streams + bulk replace)

State management:
- AnnotationCubit: mark/note CRUD, line selection, editing context
- AnnotationHistoryCubit: snapshot save/restore with stream updates

UI components:
- MarkOverlay: colored span rendering for text marks
- NoteIndicator: per-line note count badge
- MarkTypePicker: 6-type ActionChip selector
- NoteEditorSheet: category dropdown + text field bottom sheet
- AnnotationEditorScreen: full editor with long-press marks + note editing
- AnnotationHistoryScreen: snapshot timeline with restore dialog

Wiring:
- main.dart: async DB init with path_provider
- app.dart: RepositoryProvider<AnnotationDao>
- router.dart: /annotations + /annotation-history routes
- role_selection_screen: Annotate Script option
- run.sh: app_codegen step + coverage filtering for generated code

352 tests (105 core + 247 app), 100% branch coverage, zero dead code.
2026-03-29 17:59:26 +02:00

52 lines
1.8 KiB
Dart

import 'package:device_preview/device_preview.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:horatio_app/bloc/script_import/script_import_cubit.dart';
import 'package:horatio_app/bloc/srs_review/srs_review_cubit.dart';
import 'package:horatio_app/database/app_database.dart';
import 'package:horatio_app/database/daos/annotation_dao.dart';
import 'package:horatio_app/router.dart';
import 'package:horatio_app/services/script_repository.dart';
import 'package:horatio_app/theme/app_theme.dart';
/// Root widget for the Horatio app.
class HoratioApp extends StatelessWidget {
/// Creates the [HoratioApp].
const HoratioApp({required this.database, super.key});
/// The drift database instance.
final AppDatabase database;
@override
Widget build(BuildContext context) => MultiRepositoryProvider(
providers: [
RepositoryProvider<ScriptRepository>(
create: (_) => ScriptRepository(),
),
RepositoryProvider<AnnotationDao>(
create: (_) => database.annotationDao,
),
],
child: MultiBlocProvider(
providers: [
BlocProvider<ScriptImportCubit>(
create: (context) => ScriptImportCubit(
repository: context.read<ScriptRepository>(),
),
),
BlocProvider<SrsReviewCubit>(
create: (_) => SrsReviewCubit(),
),
],
child: MaterialApp.router(
title: 'Horatio',
theme: AppTheme.light,
darkTheme: AppTheme.dark,
locale: DevicePreview.locale(context),
builder: DevicePreview.appBuilder,
routerConfig: appRouter,
),
),
);
}