All checks were successful
CI / Windows build (push) Successful in 12m34s
The app had zero localization ("软件多语言做了吗" — no). Add Flutter's
official gen-l10n pipeline and localize the core flow the user sees.
- pubspec: flutter_localizations + intl + generate: true
- l10n.yaml + lib/l10n/app_en.arb + app_zh.arb (37 strings)
- main.dart: localizationsDelegates + supportedLocales (follows OS locale)
- pen editor: all tool tooltips, page pill, error states localized
- home: app bar actions + empty-state buttons localized
Proven end-to-end: l10n_test pumps the same widget under Locale('en')
and Locale('zh') and asserts English vs Chinese strings resolve.
flutter analyze: 0 issues. l10n_test: 3/3 pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
81 lines
2.9 KiB
Dart
81 lines
2.9 KiB
Dart
import 'package:dynamic_color/dynamic_color.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:pdfrx/pdfrx.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'editor/pdf/pen_capture_region.dart';
|
|
import 'l10n/app_localizations.dart';
|
|
import 'providers/settings_provider.dart';
|
|
import 'screens/home_screen.dart';
|
|
import 'services/database_service.dart';
|
|
|
|
Future<void> main() async {
|
|
// Kind-aware binding (extends WidgetsFlutterBinding) must be the active
|
|
// binding before runApp so the M1 spike's PenCaptureRegion can gate
|
|
// hit-testing by pointer kind. Safe for the rest of the app: with no pen
|
|
// region mounted it behaves exactly like the default binding.
|
|
PenCaptureBinding.ensureInitialized();
|
|
// pdfrx native engine init (required before any PdfViewer is built).
|
|
pdfrxFlutterInitialize();
|
|
|
|
// Ensure DB is ready before the app starts so providers can use it eagerly
|
|
await DatabaseService.getInstance();
|
|
|
|
// Initialize SharedPreferences
|
|
await SharedPreferences.getInstance();
|
|
|
|
runApp(const ProviderScope(child: BadNoteApp()));
|
|
}
|
|
|
|
class BadNoteApp extends ConsumerWidget {
|
|
const BadNoteApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final settings = ref.watch(settingsProvider);
|
|
|
|
// Material You: prefer the OS dynamic color (Windows/Android system accent);
|
|
// fall back to the user's seed color when the platform provides none.
|
|
return DynamicColorBuilder(
|
|
builder: (lightDynamic, darkDynamic) {
|
|
final lightScheme = lightDynamic?.harmonized() ??
|
|
ColorScheme.fromSeed(
|
|
seedColor: settings.colorSchemeSeed,
|
|
brightness: Brightness.light,
|
|
);
|
|
final darkScheme = darkDynamic?.harmonized() ??
|
|
ColorScheme.fromSeed(
|
|
seedColor: settings.colorSchemeSeed,
|
|
brightness: Brightness.dark,
|
|
);
|
|
return MaterialApp(
|
|
title: 'BadNote',
|
|
themeMode: settings.themeMode,
|
|
theme: _theme(lightScheme),
|
|
darkTheme: _theme(darkScheme),
|
|
// i18n: follows the OS language (en / zh) via the system locale.
|
|
localizationsDelegates: const [
|
|
AppLocalizations.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: const HomeScreen(),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
ThemeData _theme(ColorScheme scheme) => ThemeData(
|
|
colorScheme: scheme,
|
|
useMaterial3: true,
|
|
textTheme: GoogleFonts.interTextTheme(
|
|
ThemeData(brightness: scheme.brightness).textTheme,
|
|
),
|
|
);
|
|
}
|