diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.dart index 978162ed..00c57200 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.dart @@ -28,6 +28,17 @@ abstract class RichTextBuilderComponent extends Component this.parser, this.defaultStyle, this.styles, + this.strutStyle, + this.textAlign, + this.textDirection, + this.locale, + this.softWrap, + this.overflow, + this.textScaleFactor, + this.maxLines, + this.semanticsLabel, + this.textWidthBasis, + this.selectionColor, super.key, }); @@ -52,4 +63,83 @@ abstract class RichTextBuilderComponent extends Component /// ``` /// in "This text `is red`." final Map? styles; + + final StrutStyle? strutStyle; + + /// How the text should be aligned horizontally. + final TextAlign? textAlign; + + /// The directionality of the text. + /// + /// This decides how [textAlign] values like [TextAlign.start] and + /// [TextAlign.end] are interpreted. + final TextDirection? textDirection; + + /// Used to select a font when the same Unicode character can + /// be rendered differently, depending on the locale. + final Locale? locale; + + /// Whether the text should break at soft line breaks. + /// + /// If false, the glyphs in the text will be positioned as if there + /// was unlimited horizontal space. + final bool? softWrap; + + /// How visual overflow should be handled. + /// + /// If this is null [TextStyle.overflow] will be used, otherwise the value + /// from the nearest [DefaultTextStyle] ancestor will be used. + final TextOverflow? overflow; + + /// The number of font pixels for each logical pixel. + /// + /// For example, if the text scale factor is 1.5, text will be 50% larger than + /// the specified font size. + /// + /// The value given to the constructor as textScaleFactor. If null, will + /// use the [MediaQueryData.textScaleFactor] obtained from the ambient + /// [MediaQuery], or 1.0 if there is no [MediaQuery] in scope. + final double? textScaleFactor; + + /// An optional maximum number of lines for the text to span, wrapping if + /// necessary. + /// If the text exceeds the given number of lines, it will be truncated + /// according to [overflow]. + /// + /// If this is 1, text will not wrap. Otherwise, text will be wrapped at the + /// edge of the box. + /// + /// If this is null, but there is an ambient [DefaultTextStyle] that specifies + /// an explicit number for its [DefaultTextStyle.maxLines], then the + /// [DefaultTextStyle] value will take precedence. You can use a [RichText] + /// widget directly to entirely override the [DefaultTextStyle]. + final int? maxLines; + + /// {@template flutter.widgets.Text.semanticsLabel} + /// An alternative semantics label for this text. + /// + /// If present, the semantics of this widget will contain this value instead + /// of the actual text. This will overwrite any of the semantics labels + /// applied directly to the [TextSpan]s. + /// + /// This is useful for replacing abbreviations or shorthands with the full + /// text value: + /// + /// ```dart + /// const Text(r'$$', semanticsLabel: 'Double dollars') + /// ``` + /// {@endtemplate} + final String? semanticsLabel; + + final TextWidthBasis? textWidthBasis; + + /// The color to use when painting the selection. + /// + /// This is ignored if [SelectionContainer.maybeOf] returns null + /// in the [BuildContext] of the [Text] widget. + /// + /// If null, the ambient [DefaultSelectionStyle] is used (if any); failing + /// that, the selection color defaults to [DefaultSelectionStyle.defaultColor] + /// (semi-transparent grey). + final Color? selectionColor; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.g.dart index 52532f5c..ad2a85f4 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_component.g.dart @@ -11,12 +11,34 @@ abstract class $RichTextBuilderComponentCWProxy { RichTextBuilderComponent parser(RichTextParser? parser); RichTextBuilderComponent defaultStyle(TextStyle? defaultStyle); RichTextBuilderComponent styles(Map? styles); + RichTextBuilderComponent strutStyle(StrutStyle? strutStyle); + RichTextBuilderComponent textAlign(TextAlign? textAlign); + RichTextBuilderComponent textDirection(TextDirection? textDirection); + RichTextBuilderComponent locale(Locale? locale); + RichTextBuilderComponent softWrap(bool? softWrap); + RichTextBuilderComponent overflow(TextOverflow? overflow); + RichTextBuilderComponent textScaleFactor(double? textScaleFactor); + RichTextBuilderComponent maxLines(int? maxLines); + RichTextBuilderComponent semanticsLabel(String? semanticsLabel); + RichTextBuilderComponent textWidthBasis(TextWidthBasis? textWidthBasis); + RichTextBuilderComponent selectionColor(Color? selectionColor); RichTextBuilderComponent key(Key? key); RichTextBuilderComponent call({ String? text, RichTextParser? parser, TextStyle? defaultStyle, Map? styles, + StrutStyle? strutStyle, + TextAlign? textAlign, + TextDirection? textDirection, + Locale? locale, + bool? softWrap, + TextOverflow? overflow, + double? textScaleFactor, + int? maxLines, + String? semanticsLabel, + TextWidthBasis? textWidthBasis, + Color? selectionColor, Key? key, }); } diff --git a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart index 7ddacada..ab270288 100644 --- a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart +++ b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart @@ -29,6 +29,17 @@ class RichTextBuilder extends RichTextBuilderComponent super.parser, super.defaultStyle, super.styles, + super.strutStyle, + super.textAlign, + super.textDirection, + super.locale, + super.softWrap, + super.overflow, + super.textScaleFactor, + super.maxLines, + super.semanticsLabel, + super.textWidthBasis, + super.selectionColor, super.key, }); @@ -91,6 +102,17 @@ class RichTextBuilder extends RichTextBuilderComponent TextSpan(children: [root.toInlineSpan(customParser)]), textHeightBehavior: const TextHeightBehavior(applyHeightToLastDescent: false), + strutStyle: super.strutStyle, + textAlign: super.textAlign, + textDirection: super.textDirection, + locale: super.locale, + softWrap: super.softWrap, + overflow: super.overflow, + textScaleFactor: super.textScaleFactor, + maxLines: super.maxLines, + semanticsLabel: super.semanticsLabel, + textWidthBasis: super.textWidthBasis, + selectionColor: super.selectionColor, ); } } diff --git a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.g.dart b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.g.dart index 87ca0548..1d13307e 100644 --- a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.g.dart +++ b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.g.dart @@ -20,6 +20,34 @@ class $RichTextBuilderCWProxyImpl implements $RichTextBuilderComponentCWProxy { RichTextBuilder styles(Map? styles) => this(styles: styles); @override + RichTextBuilder strutStyle(StrutStyle? strutStyle) => + this(strutStyle: strutStyle); + @override + RichTextBuilder textAlign(TextAlign? textAlign) => this(textAlign: textAlign); + @override + RichTextBuilder textDirection(TextDirection? textDirection) => + this(textDirection: textDirection); + @override + RichTextBuilder locale(Locale? locale) => this(locale: locale); + @override + RichTextBuilder softWrap(bool? softWrap) => this(softWrap: softWrap); + @override + RichTextBuilder overflow(TextOverflow? overflow) => this(overflow: overflow); + @override + RichTextBuilder textScaleFactor(double? textScaleFactor) => + this(textScaleFactor: textScaleFactor); + @override + RichTextBuilder maxLines(int? maxLines) => this(maxLines: maxLines); + @override + RichTextBuilder semanticsLabel(String? semanticsLabel) => + this(semanticsLabel: semanticsLabel); + @override + RichTextBuilder textWidthBasis(TextWidthBasis? textWidthBasis) => + this(textWidthBasis: textWidthBasis); + @override + RichTextBuilder selectionColor(Color? selectionColor) => + this(selectionColor: selectionColor); + @override RichTextBuilder key(Key? key) => this(key: key); @override RichTextBuilder call({ @@ -27,6 +55,17 @@ class $RichTextBuilderCWProxyImpl implements $RichTextBuilderComponentCWProxy { RichTextParser? parser, TextStyle? defaultStyle, Map? styles, + StrutStyle? strutStyle, + TextAlign? textAlign, + TextDirection? textDirection, + Locale? locale, + bool? softWrap, + TextOverflow? overflow, + double? textScaleFactor, + int? maxLines, + String? semanticsLabel, + TextWidthBasis? textWidthBasis, + Color? selectionColor, Key? key, }) => RichTextBuilder( @@ -34,6 +73,17 @@ class $RichTextBuilderCWProxyImpl implements $RichTextBuilderComponentCWProxy { parser: parser ?? _value.parser, defaultStyle: defaultStyle ?? _value.defaultStyle, styles: styles ?? _value.styles, + strutStyle: strutStyle ?? _value.strutStyle, + textAlign: textAlign ?? _value.textAlign, + textDirection: textDirection ?? _value.textDirection, + locale: locale ?? _value.locale, + softWrap: softWrap ?? _value.softWrap, + overflow: overflow ?? _value.overflow, + textScaleFactor: textScaleFactor ?? _value.textScaleFactor, + maxLines: maxLines ?? _value.maxLines, + semanticsLabel: semanticsLabel ?? _value.semanticsLabel, + textWidthBasis: textWidthBasis ?? _value.textWidthBasis, + selectionColor: selectionColor ?? _value.selectionColor, key: key ?? _value.key, ); } diff --git a/packages/wyatt_ui_kit/lib/src/data/theme_extensions/rich_text_builder_theme_extension_impl.dart b/packages/wyatt_ui_kit/lib/src/data/theme_extensions/rich_text_builder_theme_extension_impl.dart index 53c6712f..1c335797 100644 --- a/packages/wyatt_ui_kit/lib/src/data/theme_extensions/rich_text_builder_theme_extension_impl.dart +++ b/packages/wyatt_ui_kit/lib/src/data/theme_extensions/rich_text_builder_theme_extension_impl.dart @@ -17,6 +17,7 @@ import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/wyatt_ui_components.dart'; import 'package:wyatt_ui_kit/src/components/gradients/gradient_text_style.dart'; +import 'package:wyatt_ui_kit/src/core/design_system/colors.dart'; class RichTextBuilderThemeExtensionImpl extends RichTextBuilderThemeExtension { const RichTextBuilderThemeExtensionImpl({ @@ -52,54 +53,131 @@ class RichTextBuilderThemeExtensionImpl extends RichTextBuilderThemeExtension { fontWeight: FontWeight.w600, height: 1.8, ), - const MultiColor([ - Color(0xFF3C97FB), - Color(0xFF436EF4), - ]), + WyattColors.blueGradient, + ), + 'gradient-dark-blue': GradientTextStyle.from( + theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + height: 1.8, + ), + WyattColors.darkBlueGradient, + ), + 'gradient-gray': GradientTextStyle.from( + theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + height: 1.8, + ), + WyattColors.grayGradient, + ), + 'gradient-light-gray': GradientTextStyle.from( + theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + height: 1.8, + ), + WyattColors.lightGrayGradient, + ), + 'gradient-light': GradientTextStyle.from( + theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + height: 1.8, + ), + WyattColors.lightGradient, + ), + 'gradient-purple': GradientTextStyle.from( + theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + height: 1.8, + ), + WyattColors.purpleGradient, ), 'gradient-red': GradientTextStyle.from( theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w600, height: 1.8, ), - const MultiColor([ - Color(0xFFF44464), - Color(0xFFF44464), - ]), + WyattColors.redGradient, + ), + 'gradient-yellow': GradientTextStyle.from( + theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + height: 1.8, + ), + WyattColors.yellowGradient, ), 'gradient-green': GradientTextStyle.from( theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w600, height: 1.8, ), - const MultiColor([ - Color(0xFF00D16C), - Color(0xFF00D16C), - ]), + WyattColors.greenGradient, ), 'blue': theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w600, - color: const Color(0xFF3C97FB), + color: WyattColors.blue1, height: 1.8, ) ?? const TextStyle( - color: Color(0xFF3C97FB), + color: WyattColors.blue1, ), - 'red': theme.textTheme.bodyMedium?.copyWith( + 'dark-blue': theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w600, - color: const Color(0xFFF44464), + color: WyattColors.darkBlue1, height: 1.8, ) ?? const TextStyle( - color: Color(0xFFF44464), + color: WyattColors.darkBlue1, + ), + 'gray': theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: WyattColors.gray1, + height: 1.8, + ) ?? + const TextStyle( + color: WyattColors.gray1, ), 'green': theme.textTheme.bodyMedium?.copyWith( fontWeight: FontWeight.w600, - color: const Color(0xFF00D16C), + color: WyattColors.green1, height: 1.8, ) ?? const TextStyle( - color: Color(0xFF00D16C), + color: WyattColors.green1, ), + 'light': theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: WyattColors.light, + height: 1.8, + ) ?? + const TextStyle( + color: WyattColors.light, + ), + 'light-gray': theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: WyattColors.lightGray1, + height: 1.8, + ) ?? + const TextStyle( + color: WyattColors.lightGray1, + ), + 'purple': theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: WyattColors.purple1, + height: 1.8, + ) ?? + const TextStyle( + color: WyattColors.purple1, + ), + 'red': theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: WyattColors.red1, + height: 1.8, + ) ?? + const TextStyle(color: WyattColors.red1), + 'yellow': theme.textTheme.bodyMedium?.copyWith( + fontWeight: FontWeight.w600, + color: WyattColors.yellow1, + height: 1.8, + ) ?? + const TextStyle(color: WyattColors.yellow1), }; }