Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NoticeBar] 解决web端文字显示异常问题 #351

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions tdesign-component/lib/src/components/notice_bar/td_notice_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ class _TDNoticeBarState extends State<TDNoticeBar> {
(_size!.width - _style!.getPadding.horizontal);
}

/// 获取文字高度
double _getTextHeight() {
if(identical(0, 0.0)) {
return widget.height;
}
return _getFontSize().height;
}

/// 内容区域
Widget _contextWidget() {
var valid = false;
Expand All @@ -251,11 +259,14 @@ class _TDNoticeBarState extends State<TDNoticeBar> {
height: widget.height,
child: Align(
alignment: Alignment.centerLeft,
child: TDText(
widget.context,
style: _style?.getTextStyle,
maxLines: 1,
forceVerticalCenter: true,
child: SizedBox(
height: _getTextHeight(),
child: TDText(
widget.context,
style: _style?.getTextStyle,
maxLines: 1,
forceVerticalCenter: true,
),
),
),
);
Expand All @@ -266,11 +277,14 @@ class _TDNoticeBarState extends State<TDNoticeBar> {
height: widget.height,
child: Align(
alignment: Alignment.centerLeft,
child: TDText(
widget.context[0],
style: _style?.getTextStyle,
maxLines: 1,
forceVerticalCenter: true,
child: SizedBox(
height: _getTextHeight(),
child: TDText(
widget.context[0],
style: _style?.getTextStyle,
maxLines: 1,
forceVerticalCenter: true,
),
),
),
);
Expand Down