home_page.dart 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'pages/order_taking_page.dart';
  4. import 'pages/order_management_page.dart';
  5. import 'pages/send_express_page.dart';
  6. import 'pages/my_page.dart';
  7. class HomePage extends StatefulWidget {
  8. final Widget child;
  9. HomePage({
  10. Key key,
  11. this.child
  12. }): super(key: key);
  13. _HomePageState createState() => _HomePageState();
  14. }
  15. class _HomePageState extends State < HomePage > with SingleTickerProviderStateMixin{
  16. TabController _controller;
  17. int _currentIndex = 0;
  18. List<Widget> pageList =[
  19. OrderTakingPage(),
  20. OrderManagementPage(),
  21. SendExpressPage(),
  22. MyPage()
  23. ];
  24. @override
  25. void initState() {
  26. super.initState();
  27. _controller = TabController(length: pageList.length, vsync: this);
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return
  32. Scaffold(
  33. body: TabBarView(
  34. physics: NeverScrollableScrollPhysics(), //禁止滚动
  35. controller: _controller,
  36. children: [
  37. OrderTakingPage(),
  38. OrderManagementPage(),
  39. SendExpressPage(),
  40. MyPage()
  41. ]),
  42. bottomNavigationBar: BottomNavigationBar(
  43. currentIndex: _currentIndex,
  44. type: BottomNavigationBarType.fixed,
  45. items:[
  46. BottomNavigationBarItem(
  47. icon: Image.asset('lib/images/icon_jiedan.png',scale: 1.6,),
  48. title: Text('接单',style: TextStyle(color:_currentIndex==0?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),),
  49. activeIcon: Image.asset('lib/images/icon_jiedan01.png',scale: 1.6)
  50. ),
  51. BottomNavigationBarItem(
  52. icon: Image.asset('lib/images/icon_dingdan.png',scale: 1.6),
  53. title: Text('订单管理',style: TextStyle(color:_currentIndex==1?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),),
  54. activeIcon: Image.asset('lib/images/icon_dingdan01.png',scale: 1.6)
  55. ),
  56. BottomNavigationBarItem(
  57. icon: Image.asset('lib/images/icon_fajian.png',scale: 1.6),
  58. title: Text('发件',style: TextStyle(color:_currentIndex==2?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),),
  59. activeIcon: Image.asset('lib/images/icon_fajian01.png',scale: 1.6)
  60. ),
  61. BottomNavigationBarItem(
  62. icon: Image.asset('lib/images/icon_wode.png',scale: 1.6),
  63. title: Text('我的',style: TextStyle(color:_currentIndex==3?Color.fromRGBO(64, 98, 254, 1):Colors.grey,fontSize: ScreenUtil.getInstance().setSp(20)),),
  64. activeIcon: Image.asset('lib/images/icon_wode01.png',scale: 1.6)
  65. ),
  66. ],
  67. onTap: (index){
  68. setState(() {
  69. _currentIndex = index;
  70. });
  71. // if(_currentIndex==2){
  72. // Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
  73. // return SendExpressPage();
  74. // }));
  75. // }else{
  76. _controller.animateTo(_currentIndex);
  77. //}
  78. },
  79. ),
  80. );
  81. }
  82. }