- 引入 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
62 lines
2.0 KiB
Dart
62 lines
2.0 KiB
Dart
import 'package:cupertino_ui/cupertino_ui.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:material_ui/material_ui.dart' as material;
|
|
|
|
import '../l10n/app_localizations.dart';
|
|
import '../core/storage/token_storage.dart';
|
|
import 'theme/app_theme.dart';
|
|
import 'theme/dark_mode.dart';
|
|
|
|
/// 应用根组件。
|
|
///
|
|
/// 使用 CupertinoApp.router 接入 GoRouter,并在 [ProviderScope] 内运行。
|
|
class App extends StatelessWidget {
|
|
const App({super.key, required this.router});
|
|
|
|
final GoRouter router;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CupertinoApp.router(
|
|
title: '桐桐家庭关怀',
|
|
theme: AppTheme.cupertinoTheme,
|
|
routerConfig: router,
|
|
localizationsDelegates: const [
|
|
AppLocalizations.delegate,
|
|
...material.GlobalMaterialLocalizations.delegates,
|
|
],
|
|
builder: (context, child) {
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
value: DarkMode.systemBars(context),
|
|
child: material.Theme(
|
|
data: material.ThemeData(
|
|
colorScheme: material.ColorScheme.fromSeed(
|
|
seedColor: AppTheme.primary,
|
|
brightness: CupertinoTheme.brightnessOf(context),
|
|
),
|
|
),
|
|
// easy_image_viewer 仍使用 SDK Material 的主题和本地化。
|
|
// ignore: deprecated_member_use
|
|
child: material.MaterialUiCompatibilityBridge(child: child!),
|
|
),
|
|
);
|
|
},
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 便于在 main 中统一构建 ProviderScope + App。
|
|
Widget buildApp(GoRouter router) {
|
|
return ValueListenableBuilder<int>(
|
|
valueListenable: TokenStorage.sessionChanges,
|
|
builder: (context, version, _) => ProviderScope(
|
|
key: ValueKey(version),
|
|
child: App(router: router),
|
|
),
|
|
);
|
|
}
|