Files
English/kouyu_english/lib/main.dart
T
shenleiandClaude Opus 4.8 febfd30f49 feat: A1 短材料复现本单元理解词,并加入黑夜模式
课程内容
- 重写全部 21 个 A1 单元的听读材料,把本单元理解词织进听/读文本,
  单元内理解词复现率从约 20% 提升到约 77%(各单元 56–96%)。
- 修正 U01 房间号与机场大巴同为 thirty 的撞车(改为 17/30/40)。
- 校验器容差按级别读取(A1 为 8%),materials 覆盖率、字数、
  选项子串等校验全部通过;course_content_test 通过。

黑夜模式
- app_theme 拆分明/暗两套调色板,AppColors 随亮度切换;
  main 用 theme/darkTheme/themeMode + builder 镜像已解析亮度;
  主题偏好持久化到快照;进度页新增“外观主题”切换。

文档
- COURSE-PACK-JSON.md 更新 A1 词池覆盖(840/933)与材料复现约定。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-18 11:16:09 +09:00

108 lines
3.3 KiB
Dart

import 'package:flutter/material.dart';
import 'core/app_state.dart';
import 'core/app_theme.dart';
import 'core/sync/sync_coordinator.dart';
import 'core/sherpa_stt_service.dart';
import 'features/onboarding/onboarding_pages.dart';
import 'features/shell/learning_shell.dart';
void main() {
runApp(const KouyuEnglishApp());
}
class KouyuEnglishApp extends StatefulWidget {
const KouyuEnglishApp({super.key});
@override
State<KouyuEnglishApp> createState() => _KouyuEnglishAppState();
}
class _KouyuEnglishAppState extends State<KouyuEnglishApp> {
final appState = AppState();
var onboardingStep = 0;
@override
void initState() {
super.initState();
// 异步静默预热打包在本地的 SenseVoice 离线语音模型,加速首次语音交互
SherpaSttService.instance.initialize().then((ok) {
debugPrint('[Main] 离线 SenseVoice 语音引擎预热状态: $ok');
});
SyncCoordinator.instance.init().then((_) {
if (mounted && appState.isLoaded) {
SyncCoordinator.instance.triggerBackgroundSync(appState);
}
});
appState.load().then((_) {
if (mounted && SyncCoordinator.instance.isInitialized) {
SyncCoordinator.instance.triggerBackgroundSync(appState);
}
});
}
@override
void dispose() {
appState.dispose();
super.dispose();
}
static ThemeMode _themeMode(AppThemeMode mode) => switch (mode) {
AppThemeMode.system => ThemeMode.system,
AppThemeMode.light => ThemeMode.light,
AppThemeMode.dark => ThemeMode.dark,
};
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: appState,
builder: (context, _) => MaterialApp(
title: '芽说英语 · SpeakSprout',
debugShowCheckedModeBanner: false,
theme: buildAppTheme(Brightness.light),
darkTheme: buildAppTheme(Brightness.dark),
themeMode: _themeMode(appState.themeMode),
// Mirror the resolved brightness into the global palette that many
// widgets read directly, so it tracks both the user's choice and any
// system dark-mode change.
builder: (context, child) {
AppColors.applyBrightness(Theme.of(context).brightness);
return child ?? const SizedBox.shrink();
},
home: Builder(
builder: (context) {
if (!appState.isLoaded) {
return const Scaffold(
body: Center(child: CircularProgressIndicator()),
);
}
if (appState.onboardingComplete) {
return LearningShell(state: appState);
}
if (onboardingStep == 0) {
return WelcomePage(
state: appState,
onContinue: () => setState(() => onboardingStep = 1),
);
}
return PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, _) {
if (!didPop) {
setState(() => onboardingStep = 0);
}
},
child: PlacementPage(
state: appState,
onBack: () => setState(() => onboardingStep = 0),
onStart: () => appState.finishOnboarding(),
),
);
},
),
),
);
}
}