Skip to content

Instantly share code, notes, and snippets.

@mortezanazari-hub
Created January 23, 2025 12:46
Show Gist options
  • Select an option

  • Save mortezanazari-hub/fb957c57ecff231dc188f63c1fd06c85 to your computer and use it in GitHub Desktop.

Select an option

Save mortezanazari-hub/fb957c57ecff231dc188f63c1fd06c85 to your computer and use it in GitHub Desktop.
/// {@template app_typography}
/// کلاس تم که پیکربندی [TextStyle] را فراهم می‌کند.
/// Theme class which provides configuration of [TextStyle]
/// {@endtemplate}
interface class AppTypography extends ThemeExtension<AppTypography> {
/// {@macro app_typography}
AppTypography({
required this.buttonLarge,
required this.buttonMedium,
required this.buttonSmall,
});
/// دکمه بزرگ
/// Button Large
final TextStyle buttonLarge;
/// دکمه متوسط
/// Button Medium
final TextStyle buttonMedium;
/// دکمه کوچک
/// Button Small
final TextStyle buttonSmall;
@override
ThemeExtension<AppTypography> copyWith({
TextStyle? buttonLarge,
TextStyle? buttonMedium,
TextStyle? buttonSmall,
}) {
return AppTypography(
buttonLarge: buttonLarge ?? this.buttonLarge,
buttonMedium: buttonMedium ?? this.buttonMedium,
buttonSmall: buttonSmall ?? this.buttonSmall,
);
}
@override
ThemeExtension<AppTypography> lerp(
covariant ThemeExtension<AppTypography>? other,
double t,
) {
if (other is! AppTypography) {
return this;
}
return AppTypography(
buttonLarge: TextStyle.lerp(buttonLarge, other.buttonLarge, t)!,
buttonMedium: TextStyle.lerp(buttonMedium, other.buttonMedium, t)!,
buttonSmall: TextStyle.lerp(buttonSmall, other.buttonSmall, t)!,
);
}
}
/// {@macro app_typography}
class AppRegularTypography extends AppTypography {
/// {@macro app_typography}
AppRegularTypography({
super.buttonLarge = const TextStyle(
fontSize: 16,
height: 24 / 16,
fontWeight: FontWeight.w500,
),
super.buttonMedium = const TextStyle(
fontSize: 14,
height: 20 / 14,
fontWeight: FontWeight.w500,
),
super.buttonSmall = const TextStyle(
fontSize: 14,
height: 20 / 14,
fontWeight: FontWeight.w500,
),
),
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment