Files
ttstd_family_care/test/app/dark_mode_test.dart
T
tongtong 71dd8eb52c feat(theme): 添加全局深色模式支持与主题适配
- 引入 DarkMode 工具类,提供系统栏、颜色、色调的暗色适配能力
- AppColors 调色板改为 CupertinoDynamicColor.withBrightness 自适应
- app.dart 增加 AnnotatedRegion 与 Material Theme 包裹以联动暗色系统栏
- 移除 system_ui_util 中硬编码的浅色图标配置,改由主题驱动
- CardBox、AppDivider、SectionTitle 等公共组件适配深色卡片与分割线
- settings_ui、change_mobile、change_password、login_devices、wechat_binding 等页面全面接入 DarkMode 颜色
- dio_client 新增 allowStale 响应缓存机制,网络异常时回退本地缓存
- token_storage 增加 currentAccountId(JWT 解析)及按用户隔离的设备偏好存取
- ApiException 改为通过私有构造持有真实 AppError 实例,appError getter 返回结构化错误
- 闹钟模块迁移至 FutureProvider.autoDispose.family,消除手动 loading 状态管理
- 闹钟编辑页 CupertinoTimerPicker 替换为 CupertinoDatePicker(24h 格式),标签输入改为 TextEditingController
2026-11-07 02:35:30 +08:00

49 lines
1.6 KiB
Dart

import 'package:cupertino_ui/cupertino_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'package:ttstd_family_care/app/app.dart';
import 'package:ttstd_family_care/core/widgets/app_page_scaffold.dart';
import 'package:ttstd_family_care/core/widgets/feature_ui.dart';
void main() {
testWidgets('page and card follow system appearance changes', (tester) async {
final dispatcher = tester.platformDispatcher;
addTearDown(dispatcher.clearPlatformBrightnessTestValue);
dispatcher.platformBrightnessTestValue = Brightness.light;
final router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (_, _) => const AppPageScaffold(
backgroundColor: AppColors.surface,
child: CardBox(child: Text('Theme')),
),
),
],
);
addTearDown(router.dispose);
await tester.pumpWidget(App(router: router));
await tester.pumpAndSettle();
Color? pageColor() => tester
.widget<CupertinoPageScaffold>(find.byType(CupertinoPageScaffold))
.backgroundColor;
Color? cardColor() {
final card = find.descendant(
of: find.byType(CardBox),
matching: find.byType(Container),
);
return (tester.widget<Container>(card).decoration as BoxDecoration).color;
}
expect(pageColor(), const Color(0xFFF5F7FA));
expect(cardColor(), CupertinoColors.white);
dispatcher.platformBrightnessTestValue = Brightness.dark;
await tester.pumpAndSettle();
expect(pageColor(), const Color(0xFF13171E));
expect(cardColor(), const Color(0xFF202630));
});
}