- 创建 AppThemeColors ThemeExtension 类,统一管理主题感知颜色(涨跌色、卡片背景、渐变等) - 从 AppColorScheme 移除主题感知辅助函数,仅保留静态颜色常量 - 在 AppTheme 中注册 ThemeExtension,支持深色/浅色主题工厂 - 重构所有 UI 组件使用 context.appColors 访问主题颜色,替代硬编码的 AppColorScheme 方法调用 - 移除组件中重复的 isDark 判断逻辑,简化颜色获取方式 - 保持向后兼容性,所有现有功能不变
64 lines
1.8 KiB
Dart
64 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
|
import '../../../../core/theme/app_spacing.dart';
|
|
import '../../../../core/theme/app_theme.dart';
|
|
import '../../../../core/theme/app_theme_extension.dart';
|
|
import 'avatar_circle.dart';
|
|
|
|
/// 用户资料卡片 - 头像 + 用户名 + 徽章 + chevron
|
|
class ProfileCard extends StatelessWidget {
|
|
final dynamic user;
|
|
const ProfileCard({super.key, required this.user});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: context.appColors.surfaceCard,
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
border: Border.all(
|
|
color: context.appColors.ghostBorder,
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// Avatar
|
|
AvatarCircle(
|
|
radius: 24,
|
|
fontSize: 18,
|
|
text: user?.avatarText,
|
|
),
|
|
const SizedBox(width: 12),
|
|
// Name + badge column
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
user?.username ?? '未登录',
|
|
style: AppTextStyles.headlineLarge(context),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
'普通用户',
|
|
style: AppTextStyles.bodyMedium(context).copyWith(
|
|
fontWeight: FontWeight.normal,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Chevron
|
|
Icon(
|
|
LucideIcons.chevronRight,
|
|
size: 16,
|
|
color: context.colors.onSurfaceVariant,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|