captioned_text_widget.dart 1.6 KB

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