登录流程已全部重构
This commit is contained in:
66
lib/config/theme/base/app_theme_ext.dart
Normal file
66
lib/config/theme/base/app_theme_ext.dart
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user