Skip to content

Commit

Permalink
✨ (feat): 添加 TabBar 的对齐方式属性并更新 TextPainter
Browse files Browse the repository at this point in the history
  • Loading branch information
alan committed Dec 16, 2024
1 parent 53bb300 commit c6eb8f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/src/components/tabbar/normal/brn_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class BrnTabBar extends StatefulWidget {
final double? tagHeight;

BrnTabBarConfig? themeData;
/// 对齐方式
TabAlignment? tabAlignment;

BrnTabBar({
required this.tabs,
Expand Down Expand Up @@ -134,6 +136,7 @@ class BrnTabBar extends StatefulWidget {
this.tagSpacing,
this.preLineTagCount,
this.tagHeight,
this.tabAlignment,
}) : assert(tabs != null) {
this.themeData ??= BrnTabBarConfig();
this.themeData = BrnThemeConfigurator.instance
Expand Down Expand Up @@ -282,6 +285,7 @@ class BrnTabBarState extends State<BrnTabBar> {
_brnTabbarController.entry = null;
}
},
tabAlignment: widget.tabAlignment,
indicator: CustomWidthUnderlineTabIndicator(
insets: widget.indicatorPadding,
borderSide: BorderSide(
Expand Down Expand Up @@ -557,7 +561,7 @@ class BrnTabBarState extends State<BrnTabBar> {
// 获取 badgeTextWidth
TextStyle badgeTextStyle = TextStyle(height: 1, fontSize: 10);
TextPainter _badgeTextPainter =
TextPainter(textScaleFactor: MediaQuery.of(context).textScaleFactor);
TextPainter(textScaler: MediaQuery.of(context).textScaler);
_badgeTextPainter.textDirection = TextDirection.ltr;
_badgeTextPainter.maxLines = 1;
_badgeTextPainter.text = TextSpan(text: _badgeText, style: badgeTextStyle);
Expand Down

0 comments on commit c6eb8f7

Please sign in to comment.