home_page.dart 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. 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: IndexedStack(
  33. index: _currentIndex,
  34. children: pageList
  35. ),
  36. bottomNavigationBar: BottomNavigationBar(
  37. currentIndex: _currentIndex,
  38. type: BottomNavigationBarType.fixed,
  39. items: [
  40. BottomNavigationBarItem(
  41. icon: Image.asset('lib/images/icon_jiedan.png', scale: 1.6, ),
  42. title: Text('接单', style: TextStyle(color: _currentIndex == 0 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  43. activeIcon: Image.asset('lib/images/icon_jiedan01.png', scale: 1.6)
  44. ),
  45. BottomNavigationBarItem(
  46. icon: Image.asset('lib/images/icon_dingdan.png', scale: 1.6),
  47. title: Text('订单管理', style: TextStyle(color: _currentIndex == 1 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  48. activeIcon: Image.asset('lib/images/icon_dingdan01.png', scale: 1.6)
  49. ),
  50. BottomNavigationBarItem(
  51. icon: Image.asset('lib/images/icon_fajian.png', scale: 1.6),
  52. title: Text('发件', style: TextStyle(color: _currentIndex == 2 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  53. activeIcon: Image.asset('lib/images/icon_fajian01.png', scale: 1.6)
  54. ),
  55. BottomNavigationBarItem(
  56. icon: Image.asset('lib/images/icon_wode.png', scale: 1.6),
  57. title: Text('我的', style: TextStyle(color: _currentIndex == 3 ? Color.fromRGBO(64, 98, 254, 1) : Colors.grey, fontSize: ScreenUtil.getInstance().setSp(20)), ),
  58. activeIcon: Image.asset('lib/images/icon_wode01.png', scale: 1.6)
  59. ),
  60. ],
  61. onTap: (index) {
  62. setState(() {
  63. _currentIndex = index;
  64. });
  65. // if(_currentIndex==2){
  66. // Navigator.pushReplacement(context, MaterialPageRoute(builder: (context){
  67. // return SendExpressPage();
  68. // }));
  69. // }else{
  70. //}
  71. },
  72. ),
  73. );
  74. }
  75. }