From 69eabe19de2fb445bd04b479266ef8caa1a137aa Mon Sep 17 00:00:00 2001 From: Andrzej Chmielewski Date: Fri, 6 May 2022 14:18:44 +0200 Subject: [PATCH] fix: text overflow in CosmosTextButton --- .../lib/components/cosmos_text_button.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/cosmos_ui_components/lib/components/cosmos_text_button.dart b/packages/cosmos_ui_components/lib/components/cosmos_text_button.dart index 384f4f0b..9d2fb3ea 100644 --- a/packages/cosmos_ui_components/lib/components/cosmos_text_button.dart +++ b/packages/cosmos_ui_components/lib/components/cosmos_text_button.dart @@ -14,6 +14,8 @@ class CosmosTextButton extends StatelessWidget { this.textStyle, this.iconTopSpacing, this.color, + this.maxLines = 1, + this.overflow = TextOverflow.ellipsis, }) : super(key: key); static const defaultHeight = 50.0; @@ -26,6 +28,8 @@ class CosmosTextButton extends StatelessWidget { final TextStyle? textStyle; final Color? color; final double? iconTopSpacing; + final int maxLines; + final TextOverflow overflow; @override Widget build(BuildContext context) { @@ -48,10 +52,9 @@ class CosmosTextButton extends StatelessWidget { ], Text( text, - style: textStyle ?? - CosmosTextTheme.elevatedButton.copyWith( - color: color, - ), + maxLines: maxLines, + overflow: overflow, + style: textStyle ?? CosmosTextTheme.elevatedButton.copyWith(color: color), ), if (suffixIcon != null) ...[ if (text.isNotEmpty) SizedBox(width: CosmosTheme.of(context).spacingS), @@ -74,6 +77,8 @@ class CosmosTextButton extends StatelessWidget { ..add(ColorProperty('color', color)) ..add(StringProperty('text', text)) ..add(DiagnosticsProperty('textStyle', textStyle)) - ..add(DoubleProperty('height', height)); + ..add(DoubleProperty('height', height)) + ..add(IntProperty('maxLines', maxLines)) + ..add(EnumProperty('overflow', overflow)); } }