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
@@ -182,8 +182,14 @@ class FileSelectionButtonScreen
/// More infos in `ThemeResolver` class
if (title != null) ...[
Text(
title!.text,
title!.data,
style: title!.style ?? style.title,
textAlign: title!.textAlign,
textDirection: title!.textDirection,
softWrap: title!.softWrap,
overflow: title!.overflow,
maxLines: title!.maxLines,
selectionColor: title!.selectionColor,
).toGradient(
gradientColors: style.foregroundColors,
),
@@ -203,8 +209,14 @@ class FileSelectionButtonScreen
if (subTitle != null) ...[
const Gap(5),
Text(
subTitle!.text,
subTitle!.data,
style: subTitle!.style ?? style.subTitle,
textAlign: title!.textAlign,
textDirection: title!.textDirection,
softWrap: title!.softWrap,
overflow: title!.overflow,
maxLines: title!.maxLines,
selectionColor: title!.selectionColor,
).toGradient(
gradientColors: style.foregroundColors,
),
@@ -180,8 +180,14 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
/// More infos in ThemeResolver class
if (label != null) ...[
Text(
label!.text,
label!.data,
style: label!.style ?? style.label,
textAlign: label!.textAlign,
textDirection: label!.textDirection,
softWrap: label!.softWrap,
overflow: label!.overflow,
maxLines: label!.maxLines,
selectionColor: label!.selectionColor,
).toGradient(
gradientColors: style.foregroundColors,
)
@@ -193,8 +193,14 @@ class SymbolButtonScreen
if (label != null) ...[
Gap(style.padding?.horizontal ?? 10),
Text(
label!.text,
label!.data,
style: label!.style ?? style.label,
textAlign: label!.textAlign,
textDirection: label!.textDirection,
softWrap: label!.softWrap,
overflow: label!.overflow,
maxLines: label!.maxLines,
selectionColor: label!.selectionColor,
).toGradient(
gradientColors: style.foregroundColors,
),
@@ -77,7 +77,7 @@ class InformationCard extends InformationCardComponent
if (body != null) ...[
const Gap(_bodyTopSpacing),
CardText(
body!.text,
body!,
textType: TextType.body,
style: body!.style,
gradientColors: body!.gradientColors,
@@ -41,7 +41,7 @@ class InformationCardTitles extends StatelessWidget {
children: [
if (title != null) ...[
CardText(
title!.text,
title!,
textType: TextType.title,
style: title!.style,
gradientColors: title!.gradientColors,
@@ -50,7 +50,7 @@ class InformationCardTitles extends StatelessWidget {
if (subtitle != null) ...[
const Gap(_titlesLineSpacing),
CardText(
subtitle!.text,
subtitle!,
textType: TextType.subtitle,
style: subtitle!.style,
gradientColors: subtitle!.gradientColors,
@@ -70,7 +70,7 @@ class PortfolioCard extends PortfolioCardComponent with $PortfolioCardCWMixin {
const Gap(20),
],
CardText(
description!.text,
description!,
textType: TextType.body,
style: description!.style,
gradientColors: description!.gradientColors,
@@ -105,7 +105,7 @@ class PortfolioCard extends PortfolioCardComponent with $PortfolioCardCWMixin {
const Gap(20),
],
CardText(
description!.text,
description!,
textType: TextType.body,
style: description!.style,
gradientColors: description!.gradientColors,
@@ -64,7 +64,7 @@ class PortfolioCardHeader extends StatelessWidget {
children: [
if (keyword != null)
...keyword!.map(
(e) => Container(
(word) => Container(
margin: const EdgeInsets.all(3),
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
@@ -75,8 +75,14 @@ class PortfolioCardHeader extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
),
child: Text(
e.text,
style: e.style ?? context.textTheme.bodySmall,
word.data,
style: word.style ?? context.textTheme.bodySmall,
textAlign: word.textAlign,
textDirection: word.textDirection,
softWrap: word.softWrap,
overflow: word.overflow,
maxLines: word.maxLines,
selectionColor: word.selectionColor,
),
),
),
@@ -71,7 +71,7 @@ class QuoteCard extends QuoteCardComponent with $QuoteCardCWMixin {
),
if (quote != null) ...[
CardText(
quote!.text,
quote!,
textType: TextType.body,
style: quote!.style,
gradientColors: quote!.gradientColors,
@@ -102,7 +102,7 @@ class QuoteCard extends QuoteCardComponent with $QuoteCardCWMixin {
children: [
if (name != null) ...[
CardText(
name!.text,
name!,
textType: TextType.body,
style: name!.style,
gradientColors: name!.gradientColors,
@@ -110,7 +110,7 @@ class QuoteCard extends QuoteCardComponent with $QuoteCardCWMixin {
],
if (subtitle != null) ...[
CardText(
subtitle!.text,
subtitle!,
textType: TextType.subtitle,
style: subtitle!.style,
gradientColors: subtitle!.gradientColors,
@@ -67,7 +67,7 @@ class SkillCard extends SkillCardComponent with $SkillCardCWMixin {
const Gap(25),
if (description != null) ...[
CardText(
description!.text,
description!,
textType: TextType.body,
style: description!.style,
gradientColors: description!.gradientColors,
@@ -64,7 +64,7 @@ class SkillCardHeader extends StatelessWidget {
children: [
if (title != null) ...[
CardText(
title!.text,
title!,
textType: TextType.title,
style: title!.style,
gradientColors: title!.gradientColors,
@@ -37,7 +37,7 @@ class SkillCardSkills extends StatelessWidget {
Widget build(BuildContext context) => Column(
children: skills!
.map(
(e) => Row(
(skill) => Row(
children: [
Icon(
leadingIcon ?? Icons.check,
@@ -47,10 +47,10 @@ class SkillCardSkills extends StatelessWidget {
const Gap(10),
Expanded(
child: CardText(
e.text,
skill,
textType: TextType.body,
style: e.style,
gradientColors: e.gradientColors,
style: skill.style,
gradientColors: skill.gradientColors,
),
),
],
@@ -26,16 +26,17 @@ enum TextType {
class CardText extends StatelessWidget {
const CardText(
this.data, {
this.text, {
required this.textType,
this.style,
this.gradientColors,
super.key,
});
final TextWrapper text;
final TextType textType;
final TextStyle? style;
final MultiColor? gradientColors;
final String data;
TextStyle? _getStyle(BuildContext context) {
if (style != null) {
@@ -56,7 +57,13 @@ class CardText extends StatelessWidget {
@override
Widget build(BuildContext context) => Text(
data,
text.data,
style: _getStyle(context),
textAlign: text.textAlign,
textDirection: text.textDirection,
softWrap: text.softWrap,
overflow: text.overflow,
maxLines: text.maxLines,
selectionColor: text.selectionColor,
).toGradient(gradientColors: gradientColors);
}
@@ -315,14 +315,14 @@ class TextInputScreen extends CubitScreen<TextInputCubit, TextInputState> {
labelStyle: style.labelStyle,
)
: null,
hintText: hint?.text,
hintText: hint?.data,
hintStyle: hint?.style,
prefixIcon: prefixIcon,
prefixText: prefixText?.text,
prefixText: prefixText?.data,
prefixStyle: prefixText?.style,
prefixIconColor: style.prefixIconColor,
suffixIcon: suffixIcon,
suffixText: suffixText?.text,
suffixText: suffixText?.data,
suffixStyle: suffixText?.style,
suffixIconColor: style.suffixIconColor,
enabled: state.controlState != ControlState.disabled,
@@ -31,7 +31,13 @@ class LabelWidget extends StatelessWidget {
@override
Widget build(BuildContext context) => Text(
label?.text ?? '',
label?.data ?? '',
style: labelStyle,
textAlign: label!.textAlign,
textDirection: label!.textDirection,
softWrap: label!.softWrap,
overflow: label!.overflow,
maxLines: label!.maxLines,
selectionColor: label!.selectionColor,
);
}