@@ -16,11 +16,22 @@ class Index extends StatefulWidget {
1616}
1717
1818class _IndexState extends State <Index > with SingleTickerProviderStateMixin {
19+ int _currentIndex = 0 ;
20+ PageController _pageController;
21+
1922 @override
2023 void initState () {
2124 super .initState ();
25+ _pageController = PageController ();
26+ }
27+
28+ @override
29+ void dispose () {
30+ _pageController.dispose ();
31+ super .dispose ();
2232 }
2333
34+ //::TODO 保留到下个版本 考虑去掉
2435 Widget menu (MainStateModel model) {
2536 return Container (
2637 decoration: BoxDecoration (
@@ -69,6 +80,24 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
6980 );
7081 }
7182
83+ Widget _bottomNavigationBar (model) {
84+ AppTranslations lang = AppTranslations .of (context);
85+ return BottomNavigationBar (
86+ items: < BottomNavigationBarItem > [
87+ BottomNavigationBarItem (
88+ title: Text (lang.t ('title_component' )),
89+ icon: Icon (Icons .dashboard)),
90+ BottomNavigationBarItem (
91+ title: Text (lang.t ('title_my' )), icon: Icon (Icons .person_outline)),
92+ ],
93+ type: BottomNavigationBarType .fixed,
94+ currentIndex: _currentIndex,
95+ onTap: (int index) {
96+ _pageController.jumpToPage (index);
97+ },
98+ );
99+ }
100+
72101 List <Widget > appBarActions (model) {
73102 return [
74103 PopupMenuButton (
@@ -109,7 +138,7 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
109138 AppTranslations lang = AppTranslations .of (context);
110139 return Store .connect (
111140 builder: (context, child, model) {
112- return DefaultTabController (
141+ /* return DefaultTabController(
113142 initialIndex: 0,
114143 length: 2,
115144 child: Scaffold(
@@ -125,6 +154,26 @@ class _IndexState extends State<Index> with SingleTickerProviderStateMixin {
125154 ],
126155 ),
127156 ),
157+ ); */
158+ return Scaffold (
159+ appBar: AppBar (
160+ title: Header .Index (lang.t ('title' )),
161+ actions: appBarActions (model),
162+ ),
163+ bottomNavigationBar: _bottomNavigationBar (model),
164+ body: PageView (
165+ controller: _pageController,
166+ physics: NeverScrollableScrollPhysics (),
167+ onPageChanged: (int index) {
168+ setState (() {
169+ _currentIndex = index;
170+ });
171+ },
172+ children: < Widget > [
173+ TabIndex .Index (model: model),
174+ MyIndex .Index (model: model),
175+ ],
176+ ),
128177 );
129178 },
130179 );
0 commit comments