Skip to content

Instantly share code, notes, and snippets.

@mortezanazari-hub
Created January 23, 2025 12:42
/// {@template app_button_theme}
/// کلاس تم که پیکربندی دکمه‌ها را فراهم می‌کند.
/// Theme class which provides configuration of buttons
/// {@endtemplate}
class AppButtonTheme extends ThemeExtension<AppButtonTheme> {
/// {@macro app_button_theme}
const AppButtonTheme({
required this.primaryText,
required this.primaryDefault,
required this.primaryHover,
required this.primaryFocused,
});
/// {@macro app_button_theme}
factory AppButtonTheme.light() {
return AppButtonTheme(
primaryText: AppColors.white,
primaryDefault: AppColors.brand.shade500,
primaryHover: AppColors.brand.shade600,
primaryFocused: AppColors.brand.shade700,
);
}
/// رنگ متن اصلی.
/// The color of the primary text.
final Color primaryText;
/// رنگ پیش‌فرض دکمه‌ی اصلی.
/// The color of the primary button default.
final Color primaryDefault;
/// رنگ هنگام قرار گرفتن ماوس روی دکمه‌ی اصلی (Hover).
/// The color of the primary button hover.
final Color primaryHover;
/// رنگ دکمه‌ی اصلی در حالت فوکوس.
/// The color of the primary button focused.
final Color primaryFocused;
@override
ThemeExtension<AppButtonTheme> copyWith({
Color? primaryText,
Color? primaryDefault,
Color? primaryHover,
Color? primaryFocused,
}) {
return AppButtonTheme(
primaryText: primaryText ?? this.primaryText,
primaryDefault: primaryDefault ?? this.primaryDefault,
primaryHover: primaryHover ?? this.primaryHover,
primaryFocused: primaryFocused ?? this.primaryFocused,
);
}
@override
ThemeExtension<AppButtonTheme> lerp(
covariant ThemeExtension<AppButtonTheme>? other,
double t,
) {
if (other is! AppButtonTheme) {
return this;
}
return AppButtonTheme(
primaryText: Color.lerp(primaryText, other.primaryText, t)!,
primaryDefault: Color.lerp(primaryDefault, other.primaryDefault, t)!,
primaryHover: Color.lerp(primaryHover, other.primaryHover, t)!,
primaryFocused: Color.lerp(primaryFocused, other.primaryFocused, t)!,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment