Skip to content

Commit

Permalink
fix: Vertical alignment (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Jan 2, 2024
2 parents 8e7ce4a + 064ae1a commit a9796c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [next]

* fix: Update vertical alignment ([#19](https://github.com/bdlukaa/rounded_background_text/issues/19))
* breaking: Remove `textScaleFactor`. Use `textScaler` instead
* feat: Add missing fields to `RoundedBackgroundTextField`
* Added `textHeightBehavior`
Expand Down
8 changes: 5 additions & 3 deletions lib/src/rounded_background_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class RoundedBackgroundText extends StatelessWidget {
innerRadius: innerRadius,
outerRadius: outerRadius,
backgroundColor: backgroundColor,
textWidthBasis: textWidthBasis,
),
SelectableText.rich(
textSpan,
Expand All @@ -171,6 +172,7 @@ class RoundedBackgroundText extends StatelessWidget {
autofocus: autofocus,
semanticsLabel: semanticsLabel,
magnifierConfiguration: magnifierConfiguration,
textWidthBasis: textWidthBasis,
),
]);
}
Expand Down Expand Up @@ -656,19 +658,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]
Expand Down
22 changes: 7 additions & 15 deletions lib/src/rounded_background_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a9796c1

Please sign in to comment.