Skip to content

Commit 82d1cb8

Browse files
committed
处理ios的底部safeArea
1 parent a8ec0ee commit 82d1cb8

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

lib/widget/gsy_tabbar_widget.dart

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class GSYTabBarWidget extends StatefulWidget {
5656
);
5757
}
5858

59-
class _GSYTabBarState extends State<GSYTabBarWidget> with SingleTickerProviderStateMixin {
59+
class _GSYTabBarState extends State<GSYTabBarWidget>
60+
with SingleTickerProviderStateMixin {
6061
final int _type;
6162

6263
final List<Widget> _tabViews;
@@ -91,7 +92,8 @@ class _GSYTabBarState extends State<GSYTabBarWidget> with SingleTickerProviderSt
9192
@override
9293
void initState() {
9394
super.initState();
94-
_tabController = new TabController(vsync: this, length: widget.tabItems.length);
95+
_tabController =
96+
new TabController(vsync: this, length: widget.tabItems.length);
9597
}
9698

9799
///整个页面dispose时,记得把控制器也dispose掉,释放内存
@@ -107,7 +109,8 @@ class _GSYTabBarState extends State<GSYTabBarWidget> with SingleTickerProviderSt
107109
///顶部tab bar
108110
return new Scaffold(
109111
floatingActionButton: _floatingActionButton,
110-
persistentFooterButtons: _tarWidgetControl == null ? [] : _tarWidgetControl.footerButton,
112+
persistentFooterButtons:
113+
_tarWidgetControl == null ? [] : _tarWidgetControl.footerButton,
111114
appBar: new AppBar(
112115
backgroundColor: Theme.of(context).primaryColor,
113116
title: _title,
@@ -117,7 +120,8 @@ class _GSYTabBarState extends State<GSYTabBarWidget> with SingleTickerProviderSt
117120
indicatorColor: _indicatorColor,
118121
onTap: (index) {
119122
_onPageChanged?.call(index);
120-
_pageController.jumpTo(MediaQuery.of(context).size.width * index);
123+
_pageController
124+
.jumpTo(MediaQuery.of(context).size.width * index);
121125
}),
122126
),
123127
body: new PageView(
@@ -149,15 +153,18 @@ class _GSYTabBarState extends State<GSYTabBarWidget> with SingleTickerProviderSt
149153
bottomNavigationBar: new Material(
150154
//为了适配主题风格,包一层Material实现风格套用
151155
color: Theme.of(context).primaryColor, //底部导航栏主题颜色
152-
child: new TabBar(
153-
//TabBar导航标签,底部导航放到Scaffold的bottomNavigationBar中
154-
controller: _tabController, //配置控制器
155-
tabs: widget.tabItems,
156-
indicatorColor: _indicatorColor,
157-
onTap: (index) {
158-
_onPageChanged?.call(index);
159-
_pageController.jumpTo(MediaQuery.of(context).size.width * index);
160-
}, //tab标签的下划线颜色
156+
child: new SafeArea(
157+
child: new TabBar(
158+
//TabBar导航标签,底部导航放到Scaffold的bottomNavigationBar中
159+
controller: _tabController, //配置控制器
160+
tabs: widget.tabItems,
161+
indicatorColor: _indicatorColor,
162+
onTap: (index) {
163+
_onPageChanged?.call(index);
164+
_pageController
165+
.jumpTo(MediaQuery.of(context).size.width * index);
166+
}, //tab标签的下划线颜色
167+
),
161168
),
162169
));
163170
}

0 commit comments

Comments
 (0)