Skip to content

Commit c4a9e65

Browse files
authored
Merge pull request alibaba#222 from DeckeDeng/develop
add home scaffold
2 parents cf21ad1 + 8b5c6be commit c4a9e65

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/views/home.dart

+11-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import 'package:flutter_go/resources/widget_name_to_icon.dart';
2424
const int ThemeColor = 0xFFC91B3A;
2525

2626
class AppPage extends StatefulWidget {
27-
2827
@override
2928
State<StatefulWidget> createState() {
3029
return _MyHomePageState();
@@ -33,13 +32,12 @@ class AppPage extends StatefulWidget {
3332

3433
class _MyHomePageState extends State<AppPage>
3534
with SingleTickerProviderStateMixin {
36-
3735
SpUtil sp;
3836
WidgetControlModel widgetControl = new WidgetControlModel();
3937
SearchHistoryList searchHistoryList;
4038
bool isSearch = false;
4139
String appBarTitle = tabData[0]['text'];
42-
List<Widget> list = List();
40+
List<Widget> _list = List();
4341
int _currentIndex = 0;
4442
static List tabData = [
4543
// {'text': '业界动态', 'icon': Icon(Icons.language)},
@@ -48,21 +46,21 @@ class _MyHomePageState extends State<AppPage>
4846
{'text': '关于手册', 'icon': Icon(Icons.import_contacts)},
4947
];
5048

51-
List<BottomNavigationBarItem> myTabs = [];
49+
List<BottomNavigationBarItem> _myTabs = [];
5250

5351
@override
5452
void initState() {
5553
super.initState();
5654
initSearchHistory();
5755
for (int i = 0; i < tabData.length; i++) {
58-
myTabs.add(BottomNavigationBarItem(
56+
_myTabs.add(BottomNavigationBarItem(
5957
icon: tabData[i]['icon'],
6058
title: Text(
6159
tabData[i]['text'],
6260
),
6361
));
6462
}
65-
list
63+
_list
6664
// ..add(FirstPage())
6765
// ..add(MainPage())
6866
..add(WidgetPage(Provider.db))
@@ -131,13 +129,16 @@ class _MyHomePageState extends State<AppPage>
131129
Widget build(BuildContext context) {
132130
return new Scaffold(
133131
appBar: renderAppBar(context, widget, _currentIndex),
134-
body: list[_currentIndex],
132+
body: IndexedStack(
133+
index: _currentIndex,
134+
children: _list,
135+
),
135136
bottomNavigationBar: BottomNavigationBar(
136-
items: myTabs,
137+
items: _myTabs,
137138
//高亮 被点击高亮
138139
currentIndex: _currentIndex,
139140
//修改 页面
140-
onTap: _ItemTapped,
141+
onTap: _itemTapped,
141142
//shifting :按钮点击移动效果
142143
//fixed:固定
143144
type: BottomNavigationBarType.fixed,
@@ -147,7 +148,7 @@ class _MyHomePageState extends State<AppPage>
147148
);
148149
}
149150

150-
void _ItemTapped(int index) {
151+
void _itemTapped(int index) {
151152
setState(() {
152153
_currentIndex = index;
153154
appBarTitle = tabData[index]['text'];

0 commit comments

Comments
 (0)