feat(navigate): 更新底部导航栏的样式
This commit is contained in:
@@ -64,18 +64,17 @@ class BistroFrame extends StatefulWidget {
|
|||||||
|
|
||||||
class _BistroFrameState extends State<BistroFrame> {
|
class _BistroFrameState extends State<BistroFrame> {
|
||||||
late Widget _body;
|
late Widget _body;
|
||||||
int _index = 3;
|
int _index = 0;
|
||||||
|
|
||||||
static const List<Map<String, dynamic>> _iconList = [
|
static const List<Map<String, dynamic>> _iconList = [
|
||||||
{
|
{
|
||||||
"title": "应用",
|
"title": "应用",
|
||||||
"default": Icons.storefront_outlined,
|
"icon": Icons.storefront_outlined,
|
||||||
"active": Icons.storefront_rounded,
|
|
||||||
"display": true,
|
"display": true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "道听",
|
"title": "道听",
|
||||||
"default": Icons.forum_outlined,
|
"icon": Icons.forum_outlined,
|
||||||
"active": Icons.forum_rounded,
|
|
||||||
"display": true,
|
"display": true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -83,14 +82,12 @@ class _BistroFrameState extends State<BistroFrame> {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "途说",
|
"title": "途说",
|
||||||
"default": Icons.supervisor_account_outlined,
|
"icon": Icons.supervisor_account_outlined,
|
||||||
"active": Icons.supervisor_account_sharp,
|
|
||||||
"display": true,
|
"display": true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "我的",
|
"title": "我的",
|
||||||
"default": Icons.perm_identity_outlined,
|
"icon": Icons.person_outline,
|
||||||
"active": Icons.person_sharp,
|
|
||||||
"display": true,
|
"display": true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -116,7 +113,6 @@ class _BistroFrameState extends State<BistroFrame> {
|
|||||||
|
|
||||||
List<Widget> bottomNavigationBarData = [];
|
List<Widget> bottomNavigationBarData = [];
|
||||||
for (var i = 0; i < 5; i++) {
|
for (var i = 0; i < 5; i++) {
|
||||||
|
|
||||||
Widget itemWidget = bottomAppBarItem(index: i);
|
Widget itemWidget = bottomAppBarItem(index: i);
|
||||||
bottomNavigationBarData.add(itemWidget);
|
bottomNavigationBarData.add(itemWidget);
|
||||||
}
|
}
|
||||||
@@ -148,7 +144,7 @@ class _BistroFrameState extends State<BistroFrame> {
|
|||||||
Map<String, dynamic> item = _iconList[index];
|
Map<String, dynamic> item = _iconList[index];
|
||||||
|
|
||||||
//设置默认未选中的状态
|
//设置默认未选中的状态
|
||||||
double size = 11;
|
double size = 14;
|
||||||
Color color = Colors.black87;
|
Color color = Colors.black87;
|
||||||
bool isShow = item["display"];
|
bool isShow = item["display"];
|
||||||
|
|
||||||
@@ -156,29 +152,25 @@ class _BistroFrameState extends State<BistroFrame> {
|
|||||||
fontSize: size,
|
fontSize: size,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
Widget child;
|
Widget child;
|
||||||
if (!isShow) {
|
if (!isShow) {
|
||||||
child = Container();
|
child = Container();
|
||||||
} else {
|
} else {
|
||||||
IconData icon = item["default"];
|
IconData? icon = item["default"];
|
||||||
String title = item["title"];
|
String title = item["title"];
|
||||||
|
|
||||||
if (_index == index) {
|
if (_index == index) {
|
||||||
//选中的话
|
//选中的话
|
||||||
size = 14;
|
|
||||||
color = Theme.of(context).primaryColor;
|
color = Theme.of(context).primaryColor;
|
||||||
style = const TextStyle(
|
style = const TextStyle(
|
||||||
fontSize: 0,
|
fontSize: 0,
|
||||||
);
|
);
|
||||||
icon = item["active"];
|
icon = item["icon"];
|
||||||
}
|
}
|
||||||
|
|
||||||
child = GestureDetector(
|
child = GestureDetector(
|
||||||
child: Column(
|
child: icon != null
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
? SizedBox(
|
||||||
children: <Widget>[
|
|
||||||
SizedBox(
|
|
||||||
width: 25.0,
|
width: 25.0,
|
||||||
height: 23.0,
|
height: 23.0,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -186,12 +178,13 @@ class _BistroFrameState extends State<BistroFrame> {
|
|||||||
color: color,
|
color: color,
|
||||||
size: size * 1.7,
|
size: size * 1.7,
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
Text(
|
: Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Text(
|
||||||
title,
|
title,
|
||||||
style: style,
|
style: style,
|
||||||
)
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_index != index) {
|
if (_index != index) {
|
||||||
|
|||||||
Reference in New Issue
Block a user