46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'app_colors_base.dart';
|
|
|
|
@immutable
|
|
class AppThemeExtension extends ThemeExtension<AppThemeExtension> {
|
|
final AppColorsBase baseTheme;
|
|
|
|
const AppThemeExtension({required this.baseTheme});
|
|
|
|
@override
|
|
ThemeExtension<AppThemeExtension> copyWith({
|
|
AppColorsBase? baseTheme,
|
|
}) {
|
|
return AppThemeExtension(
|
|
baseTheme: baseTheme ?? this.baseTheme,
|
|
);
|
|
}
|
|
|
|
@override
|
|
AppThemeExtension lerp(AppThemeExtension? other, double t) {
|
|
if (other is! AppThemeExtension) return this;
|
|
return t < 0.5 ? this : other; // 或者 this/base 混合逻辑
|
|
}
|
|
}
|
|
|
|
extension AppThemeExt on BuildContext {
|
|
AppThemeExtension get themeEx => Theme.of(this).extension<AppThemeExtension>()!;
|
|
|
|
///主题
|
|
Color get success => themeEx.baseTheme.success;
|
|
|
|
Color get warning => themeEx.baseTheme.warning;
|
|
|
|
Color get danger => themeEx.baseTheme.danger;
|
|
|
|
Color get info => themeEx.baseTheme.info;
|
|
|
|
//字体灰度
|
|
Color get textSecondary => themeEx.baseTheme.textSecondary;
|
|
|
|
Color get textTertiary => themeEx.baseTheme.textTertiary;
|
|
|
|
double get pagePadding => 12;
|
|
}
|