captioned_text_widget.dart 1.7 KB

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