登录流程已全部重构

This commit is contained in:
zhutao
2025-09-23 11:47:29 +08:00
parent a4992a063b
commit 8988b3feea
71 changed files with 2036 additions and 901 deletions

View File

@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
abstract class AppColorsBase {
/// 品牌主色
Color get primary;
Color get secondary;
// 灰度
Color get textPrimary;
Color get textSecondary;
// 扩展颜色
Color get success;
Color get warning;
Color get info;
Color get danger;
// 容器色
Color get surfaceContainerLowest;
Color get surfaceContainerLow;
Color get surfaceContainer;
Color get surfaceContainerHigh; //白色卡片 / item
}

View File

@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'app_colors_base.dart'; // 假设你之前定义了 AppColorsBase
TextTheme buildTextTheme(AppColorsBase colors) {
return TextTheme(
// 标题层级
titleLarge: TextStyle(
fontSize: 22, // 比正文大6
fontWeight: FontWeight.w700,
color: colors.textPrimary,
),
titleMedium: TextStyle(
fontSize: 20, // 比正文大4
fontWeight: FontWeight.w700,
color: colors.textPrimary,
),
titleSmall: TextStyle(
fontSize: 18, // 比正文大2
fontWeight: FontWeight.w600,
color: colors.textPrimary,
),
// 正文字体
bodyLarge: TextStyle(
fontSize: 18, // 稍大正文
color: colors.textPrimary,
),
bodyMedium: TextStyle(
fontSize: 16, // 正文标准
color: colors.textPrimary,
),
bodySmall: TextStyle(
fontSize: 14, // 辅助正文
color: colors.textSecondary,
),
// 标签/提示文字
labelLarge: TextStyle(
fontSize: 14, // 比正文小一点
fontWeight: FontWeight.w500,
color: colors.textSecondary,
),
labelMedium: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: colors.textSecondary,
),
labelSmall: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w400,
color: colors.textSecondary,
),
);
}

View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'app_colors_base.dart';
@immutable
class AppThemeExtension extends ThemeExtension<AppThemeExtension> {
final Color success;
final Color warning;
final Color danger;
final Color textSecondary;
const AppThemeExtension({
required this.success,
required this.warning,
required this.danger,
required this.textSecondary,
});
// 工厂方法,根据 AppColorsBase 创建
factory AppThemeExtension.fromColors(AppColorsBase colors) {
return AppThemeExtension(
success: colors.success,
warning: colors.warning,
danger: colors.danger,
textSecondary: colors.textSecondary,
);
}
@override
ThemeExtension<AppThemeExtension> copyWith({
Color? success,
Color? warning,
Color? danger,
Color? textSecondary,
}) {
return AppThemeExtension(
success: success ?? this.success,
warning: warning ?? this.warning,
danger: danger ?? this.danger,
textSecondary: textSecondary ?? this.textSecondary,
);
}
@override
AppThemeExtension lerp(AppThemeExtension? other, double t) {
if (other == null) return this;
return AppThemeExtension(
success: Color.lerp(success, other.success, t)!,
warning: Color.lerp(warning, other.warning, t)!,
danger: Color.lerp(danger, other.danger, t)!,
textSecondary: Color.lerp(textSecondary, other.textSecondary, t)!,
);
}
}
extension AppThemeExt on BuildContext {
AppThemeExtension get themeEx => Theme.of(this).extension<AppThemeExtension>()!;
Color get success => themeEx.success;
Color get warning => themeEx.warning;
Color get danger => themeEx.danger;
Color get textSecondary => themeEx.textSecondary;
}