import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'pages/order_taking_page.dart'; import 'pages/order_management_page.dart'; import 'pages/send_express_page.dart'; import 'pages/my_page.dart'; class HomePage extends StatefulWidget { final Widget child; HomePage({ Key key, this.child }): super(key: key); _HomePageState createState() => _HomePageState(); } class _HomePageState extends State < HomePage > with SingleTickerProviderStateMixin{ TabController _controller; int _currentIndex = 0; List pageList =[ OrderTakingPage(), OrderManagementPage(), SendExpressPage(), MyPage() ]; @override void initState() { super.initState(); _controller = TabController(length: pageList.length, vsync: this); } @override Widget build(BuildContext context) { return Scaffold( body: TabBarView( physics: NeverScrollableScrollPhysics(), //禁止滚动 controller: _controller, children: [ OrderTakingPage(), OrderManagementPage(), SendExpressPage(), MyPage() ]), bottomNavigationBar: BottomNavigationBar( currentIndex: _currentIndex, type: BottomNavigationBarType.fixed, items:[ BottomNavigationBarItem( icon: Image.asset('lib/images/icon_jiedan.png',scale: 1.6,), title: Text('接单',style: TextStyle(color:_currentIndex==0?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),), activeIcon: Image.asset('lib/images/icon_jiedan01.png',scale: 1.6) ), BottomNavigationBarItem( icon: Image.asset('lib/images/icon_dingdan.png',scale: 1.6), title: Text('订单管理',style: TextStyle(color:_currentIndex==1?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),), activeIcon: Image.asset('lib/images/icon_dingdan01.png',scale: 1.6) ), BottomNavigationBarItem( icon: Image.asset('lib/images/icon_fajian.png',scale: 1.6), title: Text('发件',style: TextStyle(color:_currentIndex==2?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),), activeIcon: Image.asset('lib/images/icon_fajian01.png',scale: 1.6) ), BottomNavigationBarItem( icon: Image.asset('lib/images/icon_wode.png',scale: 1.6), title: Text('我的',style: TextStyle(color:_currentIndex==3?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),), activeIcon: Image.asset('lib/images/icon_wode01.png',scale: 1.6) ), ], onTap: (index){ setState(() { _currentIndex = index; }); // if(_currentIndex==2){ // Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){ // return SendExpressPage(); // })); // }else{ _controller.animateTo(_currentIndex); //} }, ), ); } }