todo-app/lib/main.dart
Krzysztof kuhy Rudnicki 5ea7ba7b73 Text-free list, editor, sync and image cues
Glyph + spoken label replaces every app-written string the guard
found: empty states, tile meta, sheet dates/fields, date presets,
template/section headings, status footer, snackbars, GitHub and
cloud-image results, upload/download badges, Material tooltips.
Guard tests (text_free_*_test) walk the painted tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 01:17:03 +01:00

85 lines
2.9 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/attachments/image_store.dart';
import 'package:todo/attachments/image_store_scope.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';
import 'package:todo/ui/text_free_localizations.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);
// App storage + direct dufs on Android; the wrapper's /images on desktop.
final imageStore = await openImageStore();
runApp(
TodoApp(
repository: repository,
appSettings: appSettings,
analytics: analytics,
imageStore: imageStore,
),
);
}
/// 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,
required this.imageStore,
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;
/// The single, app-wide store for attached images.
final ImageStore imageStore;
@override
Widget build(BuildContext context) {
// Above MaterialApp so pushed routes (note detail) see it too.
return ImageStoreScope(
store: imageStore,
child: MaterialApp(
title: 'todo',
localizationsDelegates: kTextFreeLocalizations,
theme: buildLightTheme(),
darkTheme: buildDarkTheme(),
home: CaptureScreen(
repository: repository,
appSettings: appSettings,
analytics: analytics,
),
),
);
}
}