home_page.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 > {
  16. int _currentIndex = 0;
  17. List < Widget > pageList = [
  18. OrderTakingPage(),
  19. OrderManagementPage(),
  20. SendExpressPage(),
  21. MyPage()
  22. ];
  23. @override
  24. void initState() {
  25. super.initState();
  26. }
  27. @override
  28. Widget build(BuildContext context) {
  29. ScreenUtil.instance = ScreenUtil(width: 750, height: 1334,allowFontScaling:false)..init(context);
  30. return
  31. Scaffold(
  32. body:pageList[_currentIndex],
  33. // IndexedStack(
  34. // index: _currentIndex,
  35. // children: pageList
  36. // ),
  37. bottomNavigationBar: BottomNavigationBar(
  38. currentIndex: _currentIndex,
  39. type: BottomNavigationBarType.fixed,
  40. items: [
  41. BottomNavigationBarItem(
  42. icon: Image.asset('lib/images/icon_jiedan.png', scale: 1.6, ),
  43. title: Text('接单', style: TextStyle(color: _currentIndex == 0 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  44. activeIcon: Image.asset('lib/images/icon_jiedan01.png', scale: 1.6)
  45. ),
  46. BottomNavigationBarItem(
  47. icon: Image.asset('lib/images/icon_dingdan.png', scale: 1.6),
  48. title: Text('订单管理', style: TextStyle(color: _currentIndex == 1 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  49. activeIcon: Image.asset('lib/images/icon_dingdan01.png', scale: 1.6)
  50. ),
  51. BottomNavigationBarItem(
  52. icon: Image.asset('lib/images/icon_fajian.png', scale: 1.6),
  53. title: Text('发件', style: TextStyle(color: _currentIndex == 2 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  54. activeIcon: Image.asset('lib/images/icon_fajian01.png', scale: 1.6)
  55. ),
  56. BottomNavigationBarItem(
  57. icon: Image.asset('lib/images/icon_wode.png', scale: 1.6),
  58. title: Text('我的', style: TextStyle(color: _currentIndex == 3 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  59. activeIcon: Image.asset('lib/images/icon_wode01.png', scale: 1.6)
  60. ),
  61. ],
  62. onTap: (index) {
  63. setState(() {
  64. _currentIndex = index;
  65. });
  66. // if(_currentIndex==2){
  67. // Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
  68. // return SendExpressPage();
  69. // }));
  70. // }else{
  71. //}
  72. },
  73. ),
  74. );
  75. }
  76. }