captioned_text_widget.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 Color? textColor;
  9. const CaptionedTextWidget({
  10. required this.text,
  11. this.subText,
  12. this.textStyle,
  13. this.textColor,
  14. Key? key,
  15. }) : super(key: key);
  16. @override
  17. Widget build(BuildContext context) {
  18. final enteTheme = Theme.of(context).colorScheme.enteTheme;
  19. return Flexible(
  20. child: Padding(
  21. padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 2),
  22. child: Row(
  23. children: [
  24. Flexible(
  25. child: RichText(
  26. text: TextSpan(
  27. style: textStyle ??
  28. enteTheme.textTheme.bodyBold.copyWith(color: textColor),
  29. children: [
  30. TextSpan(
  31. text: text,
  32. ),
  33. subText != null
  34. ? TextSpan(
  35. text: ' \u2022 ',
  36. style: enteTheme.textTheme.small.copyWith(
  37. color: enteTheme.colorScheme.textMuted,
  38. ),
  39. )
  40. : const TextSpan(text: ''),
  41. subText != null
  42. ? TextSpan(
  43. text: subText,
  44. style: enteTheme.textTheme.small.copyWith(
  45. color: enteTheme.colorScheme.textMuted,
  46. ),
  47. )
  48. : const TextSpan(text: ''),
  49. ],
  50. ),
  51. ),
  52. )
  53. ],
  54. ),
  55. ),
  56. );
  57. }
  58. }