Skip to content

Commit

Permalink
TDBottomTabBar 添加安全区域
Browse files Browse the repository at this point in the history
  • Loading branch information
Luozf12345 committed Dec 8, 2023
1 parent 2124a11 commit de7b67d
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class TDBottomTabBar extends StatefulWidget {
this.dividerColor,
this.showTopBorder = true,
this.topBorder,
this.useSafeArea = true,
}) : assert(() {
if (navigationTabs.isEmpty) {
throw FlutterError(
Expand Down Expand Up @@ -248,6 +249,9 @@ class TDBottomTabBar extends StatefulWidget {
/// 上边线样式
final BorderSide? topBorder;

/// 使用安全区域
final bool useSafeArea;

@override
State<TDBottomTabBar> createState() => _TDBottomTabBarState();
}
Expand All @@ -270,7 +274,9 @@ class _TDBottomTabBarState extends State<TDBottomTabBar> {
maxWidth -= 32;
}
var itemWidth = maxWidth / widget.navigationTabs.length;
return Container(

Widget result = Container(
height: widget.barHeight ?? _kDefaultTabBarHeight,
alignment: Alignment.center,
margin: isCapsuleOutlineType
? const EdgeInsets.symmetric(horizontal: 16)
Expand Down Expand Up @@ -298,6 +304,10 @@ class _TDBottomTabBarState extends State<TDBottomTabBar> {
})),
_verticalDivider(),
]));
if(widget.useSafeArea){
result = SafeArea(child: result);
}
return result;
},
);
}
Expand Down

0 comments on commit de7b67d

Please sign in to comment.