From e53da52087fc80b6523505d2e2a86c2aa0e7c470 Mon Sep 17 00:00:00 2001 From: KenZR Date: Fri, 1 Mar 2019 16:25:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BA=95=E9=83=A8=E5=AF=BC?= =?UTF-8?q?=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/page/home.dart | 51 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/page/home.dart b/lib/page/home.dart index 301e083..7f545a9 100644 --- a/lib/page/home.dart +++ b/lib/page/home.dart @@ -16,11 +16,22 @@ class Index extends StatefulWidget { } class _IndexState extends State with SingleTickerProviderStateMixin { + int _currentIndex = 0; + PageController _pageController; + @override void initState() { super.initState(); + _pageController = PageController(); + } + + @override + void dispose() { + _pageController.dispose(); + super.dispose(); } + //::TODO 保留到下个版本 考虑去掉 Widget menu(MainStateModel model) { return Container( decoration: BoxDecoration( @@ -69,6 +80,24 @@ class _IndexState extends State with SingleTickerProviderStateMixin { ); } + Widget _bottomNavigationBar(model) { + AppTranslations lang = AppTranslations.of(context); + return BottomNavigationBar( + items: [ + BottomNavigationBarItem( + title: Text(lang.t('title_component')), + icon: Icon(Icons.dashboard)), + BottomNavigationBarItem( + title: Text(lang.t('title_my')), icon: Icon(Icons.person_outline)), + ], + type: BottomNavigationBarType.fixed, + currentIndex: _currentIndex, + onTap: (int index) { + _pageController.jumpToPage(index); + }, + ); + } + List appBarActions(model) { return [ PopupMenuButton( @@ -109,7 +138,7 @@ class _IndexState extends State with SingleTickerProviderStateMixin { AppTranslations lang = AppTranslations.of(context); return Store.connect( builder: (context, child, model) { - return DefaultTabController( + /* return DefaultTabController( initialIndex: 0, length: 2, child: Scaffold( @@ -125,6 +154,26 @@ class _IndexState extends State with SingleTickerProviderStateMixin { ], ), ), + ); */ + return Scaffold( + appBar: AppBar( + title: Header.Index(lang.t('title')), + actions: appBarActions(model), + ), + bottomNavigationBar: _bottomNavigationBar(model), + body: PageView( + controller: _pageController, + physics: NeverScrollableScrollPhysics(), + onPageChanged: (int index) { + setState(() { + _currentIndex = index; + }); + }, + children: [ + TabIndex.Index(model: model), + MyIndex.Index(model: model), + ], + ), ); }, );