From 738f25ffa1c6561017e3f59ada5da64352ad20fd Mon Sep 17 00:00:00 2001 From: Bruno D'Luka Date: Sun, 31 Dec 2023 12:24:49 -0300 Subject: [PATCH 1/3] fix: Unify bottom alignment --- lib/src/rounded_background_text.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/rounded_background_text.dart b/lib/src/rounded_background_text.dart index 198004c..dc1b8b5 100644 --- a/lib/src/rounded_background_text.dart +++ b/lib/src/rounded_background_text.dart @@ -656,19 +656,19 @@ class LineMetricsHelper { left: height * _horizontalPaddingFactor, right: height * _horizontalPaddingFactor, top: height * 0.3, - bottom: 0, + bottom: height * 0.175 / 2, ); late final EdgeInsets _innerLinePadding = EdgeInsets.only( left: height * _horizontalPaddingFactor, right: height * _horizontalPaddingFactor, top: 0.0, - bottom: height * 0.175, + bottom: height * 0.175 / 2, ); late final EdgeInsets _lastLinePadding = EdgeInsets.only( left: height * _horizontalPaddingFactor, right: height * _horizontalPaddingFactor, top: 0.0, - bottom: height * 0.175, + bottom: height * 0.175 / 2, ); /// Dynamically calculate the outer factor based on the provided [outerRadius] From 7ea55c760688f82917876b26c18792680c27f4c2 Mon Sep 17 00:00:00 2001 From: Bruno D'Luka Date: Sun, 31 Dec 2023 12:25:30 -0300 Subject: [PATCH 2/3] chore: Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fbcfd9..666524d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [next] + +* fix: Update vertical alignment ([#19](https://github.com/bdlukaa/rounded_background_text/issues/19)) + ## 0.4.3 * fix: `RoundedBackgroundTextField.textAlign` is respected ([#17](https://github.com/bdlukaa/rounded_background_text/issues/17)) From 064ae1a35ed7a140852f858136dea78003c87505 Mon Sep 17 00:00:00 2001 From: Bruno D'Luka Date: Tue, 2 Jan 2024 10:36:26 -0300 Subject: [PATCH 3/3] fix: apply textWidthBasis on SelectableText --- lib/src/rounded_background_text.dart | 2 ++ lib/src/rounded_background_text_field.dart | 22 +++++++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/src/rounded_background_text.dart b/lib/src/rounded_background_text.dart index a21781d..553ac3e 100644 --- a/lib/src/rounded_background_text.dart +++ b/lib/src/rounded_background_text.dart @@ -154,6 +154,7 @@ class RoundedBackgroundText extends StatelessWidget { innerRadius: innerRadius, outerRadius: outerRadius, backgroundColor: backgroundColor, + textWidthBasis: textWidthBasis, ), SelectableText.rich( textSpan, @@ -171,6 +172,7 @@ class RoundedBackgroundText extends StatelessWidget { autofocus: autofocus, semanticsLabel: semanticsLabel, magnifierConfiguration: magnifierConfiguration, + textWidthBasis: textWidthBasis, ), ]); } diff --git a/lib/src/rounded_background_text_field.dart b/lib/src/rounded_background_text_field.dart index 3f5fe38..41adca8 100644 --- a/lib/src/rounded_background_text_field.dart +++ b/lib/src/rounded_background_text_field.dart @@ -511,21 +511,13 @@ class _RoundedBackgroundTextFieldState ); return Stack( - alignment: () { - switch (widget.textAlign) { - case TextAlign.end: - return AlignmentDirectional.topEnd; - case TextAlign.start: - return AlignmentDirectional.topStart; - case TextAlign.left: - return Alignment.topLeft; - case TextAlign.right: - return Alignment.topRight; - case TextAlign.center: - default: - return Alignment.topCenter; - } - }(), + alignment: switch (widget.textAlign) { + TextAlign.end => AlignmentDirectional.topEnd, + TextAlign.start => AlignmentDirectional.topStart, + TextAlign.left => Alignment.topLeft, + TextAlign.right => Alignment.topRight, + TextAlign.center || _ => Alignment.topCenter, + }, children: [ if (textController.text.isNotEmpty) Positioned(