2a29701f
liangchengyou
feat:提交代码
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
];
final _tabIcons = const <Icon>[
Icon(Icons.ac_unit),
Icon(Icons.ac_unit_outlined)
];
final _tabTexts = const <String>[
'页面1',
'页面2'
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _buildIndexedStack(),
bottomNavigationBar: _buildBottomNavBars(),
);
}
Widget _buildIndexedStack() => BlocBuilder<TabBloc,TabState>(
builder: (context, state) => IndexedStack(
index: state.index,
children: _pages,
)
);
Widget _buildBottomNavBars() => BlocBuilder<TabBloc,TabState>(
builder: (context, state) => Container(
decoration: BoxDecoration(
boxShadow: <BoxShadow>[
BoxShadow(
color: Theme.of(context).dividerColor,
blurRadius: .1
)
]
),
child: BottomNavigationBar(
currentIndex: state.index,
items: _buildBottomNavBarItems(context),
onTap: (value) => context.read<TabBloc>().add(UpdateTabIndexEvent(value)),
),
)
);
List<BottomNavigationBarItem> _buildBottomNavBarItems(BuildContext context) => _tabIcons.map((e) {
final index = _tabIcons.indexOf(e);
return BottomNavigationBarItem(
label: _tabTexts[index],
activeIcon: _tabIcons[index],
icon: _tabIcons[index]
);}).toList();
}
|