feat(ui): add some useful text customization in TextWrapper (closes #149)
continuous-integration/drone/push Build is passing

This commit was merged in pull request #150.
This commit is contained in:
2023-02-21 18:05:56 +01:00
parent 6037e13f50
commit a68da15cdc
17 changed files with 148 additions and 34 deletions
@@ -21,16 +21,87 @@ import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
/// a [Text] or a [RichText].
class TextWrapper {
const TextWrapper(
this.text, {
this.data, {
this.style,
this.gradientColors,
this.textAlign,
this.textDirection,
this.softWrap,
this.overflow,
this.maxLines,
this.selectionColor,
});
const TextWrapper.text(this.text)
const TextWrapper.text(this.data)
: style = null,
gradientColors = null;
gradientColors = null,
textAlign = null,
textDirection = null,
softWrap = null,
overflow = null,
maxLines = null,
selectionColor = null;
final String text;
/// Text to be displayed
final String data;
/// Style of the text
final TextStyle? style;
/// Colors of the gradient, if any
final MultiColor? gradientColors;
/// 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.
///
/// This is also used to disambiguate how to render bidirectional text. For
/// example, if the [data] is an English phrase followed by a Hebrew phrase,
/// in a [TextDirection.ltr] context the English phrase will be on the left
/// and the Hebrew phrase to its right, while in a [TextDirection.rtl]
/// context, the English phrase will be on the right and the Hebrew phrase on
/// its left.
///
/// Defaults to the ambient [Directionality], if any.
final TextDirection? textDirection;
/// 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;
/// 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;
/// 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;
}