text.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import 'package:flowy_infra/theme.dart';
  2. import 'package:flutter/widgets.dart';
  3. import 'package:provider/provider.dart';
  4. class FlowyText extends StatelessWidget {
  5. final String title;
  6. final TextOverflow overflow;
  7. final double fontSize;
  8. final FontWeight fontWeight;
  9. final TextAlign? textAlign;
  10. final Color? color;
  11. const FlowyText(
  12. this.title, {
  13. Key? key,
  14. this.overflow = TextOverflow.ellipsis,
  15. this.fontSize = 16,
  16. this.fontWeight = FontWeight.w400,
  17. this.textAlign,
  18. this.color,
  19. }) : super(key: key);
  20. const FlowyText.semibold(this.title,
  21. {Key? key, this.fontSize = 16, TextOverflow? overflow, this.color, this.textAlign})
  22. : fontWeight = FontWeight.w600,
  23. overflow = overflow ?? TextOverflow.ellipsis,
  24. super(key: key);
  25. const FlowyText.medium(this.title, {Key? key, this.fontSize = 16, TextOverflow? overflow, this.color, this.textAlign})
  26. : fontWeight = FontWeight.w500,
  27. overflow = overflow ?? TextOverflow.ellipsis,
  28. super(key: key);
  29. const FlowyText.regular(this.title,
  30. {Key? key, this.fontSize = 16, TextOverflow? overflow, this.color, this.textAlign})
  31. : fontWeight = FontWeight.w400,
  32. overflow = overflow ?? TextOverflow.ellipsis,
  33. super(key: key);
  34. @override
  35. Widget build(BuildContext context) {
  36. final theme = context.watch<AppTheme>();
  37. final textColor = color ?? theme.shader1;
  38. return Text(title,
  39. overflow: overflow,
  40. softWrap: false,
  41. style: TextStyle(
  42. color: textColor,
  43. fontWeight: fontWeight,
  44. fontSize: fontSize + 2,
  45. fontFamily: 'Mulish',
  46. ));
  47. }
  48. }