todo-app/lib/main.dart
Krzysztof kuhy Rudnicki e6e1052c59
Some checks are pending
file-length / file length <= 250 lines (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
Adopt the shared design_system package, dropping theme.dart and confirm.dart
Both files were donors for the new package rather than casualties of it:
theme.dart was byte-identical to untools' copy (md5 6cf8e82d), and
confirm.dart's confirmDestructive() was the ready-made pattern for the
~35 AlertDialogs inlined across the fleet. Keeping local copies after
promoting them upstream is exactly how the two would drift apart again,
so they are deleted and imported from design_system-v0.1.0 instead.

test/confirm_test.dart moves upstream with its subject -- the package
covers that behaviour (Escape and the barrier both refuse, Cancel is
autofocused so a reflexive Return cannot delete) as part of its own
100% gate. test/theme_test.dart stays as a consumer-side smoke check
that the dependency actually resolves to the frozen palette.

Verified: flutter analyze clean (bar one pre-existing bin/ style info),
308 tests pass at 100% coverage (1962/1962 -- the drop from 2005 is
exactly the promoted lines), and the release APK is installed and
running on the Pixel 6a with all 108 notes intact, the gold #B8862E
focus ring rendering from the package's inputDecorationTheme, and no
crashes in logcat.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XS1m7b1piBtAL22USLW6jL
2026-08-14 22:59:59 +02:00

70 lines
2.2 KiB
Dart

// coverage:ignore-file
// App bootstrap: opens the platform's note store and calls runApp. Exercised
// end-to-end by running the app, not unit tests.
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:todo/analytics/analytics_service.dart';
import 'package:todo/data/app_settings.dart';
import 'package:todo/data/note_repository.dart';
import 'package:todo/data/repository_factory.dart';
import 'package:todo/frame_stats.dart';
import 'package:todo/ui/capture_screen.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
installFrameStats();
// Where the log lives, and whether a legacy sqlite DB needs importing, is
// platform-specific and resolved by a conditional import: `dart:io` cannot be
// imported at all in a web compile, and the desktop app is now a web build.
final repository = await openRepository();
final appSettings = ValueNotifier(await AppSettings.load());
final analytics = AnalyticsService(nodeId: repository.nodeId);
runApp(
TodoApp(
repository: repository,
appSettings: appSettings,
analytics: analytics,
),
);
}
/// Root widget. Holds the single [NoteRepository] instance and hands it
/// to the screens that need it.
class TodoApp extends StatelessWidget {
/// Creates a [TodoApp] wrapping the given [repository], [appSettings] and
/// [analytics].
const TodoApp({
required this.repository,
required this.appSettings,
required this.analytics,
super.key,
});
/// The single, app-wide note store, injected into every screen.
final NoteRepository repository;
/// The single, app-wide preferences notifier (currently just
/// `advancedMode`), injected into every screen that reads or changes it.
final ValueNotifier<AppSettings> appSettings;
/// The single, app-wide analytics logger, injected into every screen that
/// reports interaction events.
final AnalyticsService analytics;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'todo',
theme: buildLightTheme(),
darkTheme: buildDarkTheme(),
home: CaptureScreen(
repository: repository,
appSettings: appSettings,
analytics: analytics,
),
);
}
}