feat(ui): proxy some rich text parameters

This commit is contained in:
2023-05-12 14:39:51 +02:00
parent 5de3dbd5b3
commit 952d3f8539
5 changed files with 281 additions and 19 deletions
@@ -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<String, TextStyle>? 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;
}
@@ -11,12 +11,34 @@ abstract class $RichTextBuilderComponentCWProxy {
RichTextBuilderComponent parser(RichTextParser? parser);
RichTextBuilderComponent defaultStyle(TextStyle? defaultStyle);
RichTextBuilderComponent styles(Map<String, TextStyle>? 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<String, TextStyle>? 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,
});
}