captioned_text_widget.dart 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // leading icon can be passed without specifing size, this component set size to 20x20
  2. import 'package:flutter/material.dart';
  3. import 'package:photos/ente_theme_data.dart';
  4. class CaptionedTextWidget extends StatelessWidget {
  5. final String text;
  6. final String? subText;
  7. final TextStyle? textStyle;
  8. final bool makeTextBold;
  9. final Color? textColor;
  10. const CaptionedTextWidget({
  11. required this.text,
  12. this.subText,
  13. this.textStyle,
  14. this.makeTextBold = false,
  15. this.textColor,
  16. Key? key,
  17. }) : super(key: key);
  18. @override
  19. Widget build(BuildContext context) {
  20. final enteTheme = Theme.of(context).colorScheme.enteTheme;
  21. return Flexible(
  22. child: Padding(
  23. padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 2),
  24. child: Row(
  25. children: [
  26. Flexible(
  27. child: RichText(
  28. text: TextSpan(
  29. style: textStyle ??
  30. (makeTextBold
  31. ? enteTheme.textTheme.bodyBold
  32. .copyWith(color: textColor)
  33. : enteTheme.textTheme.body
  34. .copyWith(color: textColor)),
  35. children: [
  36. TextSpan(
  37. text: text,
  38. ),
  39. subText != null
  40. ? TextSpan(
  41. text: ' \u2022 ',
  42. style: enteTheme.textTheme.small.copyWith(
  43. color: enteTheme.colorScheme.textMuted,
  44. ),
  45. )
  46. : const TextSpan(text: ''),
  47. subText != null
  48. ? TextSpan(
  49. text: subText,
  50. style: enteTheme.textTheme.small.copyWith(
  51. color: enteTheme.colorScheme.textMuted,
  52. ),
  53. )
  54. : const TextSpan(text: ''),
  55. ],
  56. ),
  57. ),
  58. )
  59. ],
  60. ),
  61. ),
  62. );
  63. }
  64. }