text_style.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'package:flowy_infra/size.dart';
  2. import 'package:flutter/material.dart';
  3. class TextStyles {
  4. final String font;
  5. final Color color;
  6. TextStyles({
  7. required this.font,
  8. required this.color,
  9. });
  10. TextStyle getFontStyle({
  11. String? fontFamily,
  12. double? fontSize,
  13. FontWeight? fontWeight,
  14. Color? fontColor,
  15. double? letterSpacing,
  16. double? lineHeight,
  17. }) =>
  18. TextStyle(
  19. fontFamily: fontFamily ?? font,
  20. fontSize: fontSize ?? FontSizes.s12,
  21. color: fontColor ?? color,
  22. fontWeight: fontWeight ?? FontWeight.w500,
  23. fontFamilyFallback: const ["Noto Color Emoji"],
  24. letterSpacing: (fontSize ?? FontSizes.s12) * (letterSpacing ?? 0.005),
  25. height: lineHeight,
  26. );
  27. TextTheme generateTextTheme() {
  28. return TextTheme(
  29. displayLarge: getFontStyle(
  30. fontSize: FontSizes.s32,
  31. fontWeight: FontWeight.w600,
  32. lineHeight: 42.0,
  33. ), // h2
  34. displayMedium: getFontStyle(
  35. fontSize: FontSizes.s24,
  36. fontWeight: FontWeight.w600,
  37. lineHeight: 34.0,
  38. ), // h3
  39. displaySmall: getFontStyle(
  40. fontSize: FontSizes.s20,
  41. fontWeight: FontWeight.w600,
  42. lineHeight: 28.0,
  43. ), // h4
  44. titleLarge: getFontStyle(
  45. fontSize: FontSizes.s18,
  46. fontWeight: FontWeight.w600,
  47. ), // title
  48. titleMedium: getFontStyle(
  49. fontSize: FontSizes.s16,
  50. fontWeight: FontWeight.w600,
  51. ), // heading
  52. titleSmall: getFontStyle(
  53. fontSize: FontSizes.s14,
  54. fontWeight: FontWeight.w600,
  55. ), // subheading
  56. bodyMedium: getFontStyle(), // body-regular
  57. bodySmall: getFontStyle(fontWeight: FontWeight.w400), // body-thin
  58. );
  59. }
  60. }