import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:zy_wms_pda/pages/toolbar/device/device_page.dart'; import 'package:zy_wms_pda/pages/toolbar/home/home_page.dart'; import 'package:zy_wms_pda/pages/toolbar/menu/menu_page.dart'; import 'package:zy_wms_pda/pages/toolbar/quick/quick_page.dart'; import '../../common/user_icon_button.dart'; import 'line_chart.dart'; class Toolbar extends StatefulWidget { const Toolbar({super.key}); @override State createState() => _ToolbarState(); } class _ToolbarState extends State { int cuttentIndex = 0; PageController _pageController = PageController(); final List _titles = [ '首页', '菜单', '设备管理', '快捷中心', ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(_titles[cuttentIndex]), leading:Builder( builder: (BuildContext context) { return UserIconButton(); }, ), ), drawer: Drawer( elevation: 20, width: 1100.w, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(0.0), ), child: ListView( padding: EdgeInsets.zero, children: [ DrawerHeader( decoration: BoxDecoration(color: Color.fromRGBO(95, 185, 97, 1)), child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20) ), padding: EdgeInsets.all(5), margin: EdgeInsets.only(bottom: 10), child: Text('data'), ), ), ListTile( leading: Icon(Icons.home), title: Text('首页'), onTap: () { // 处理点击事件 Navigator.pop(context); // 关闭侧边栏 }, ), ListTile( leading: Icon(Icons.settings), title: Text('设置'), onTap: () { // 处理点击事件 Navigator.pop(context); // 关闭侧边栏 }, ), ListTile( leading: Icon(Icons.info), title: Text('关于'), onTap: () { // 处理点击事件 Navigator.pop(context); // 关闭侧边栏 Get.offAllNamed("/"); }, ), ], ), ), body: PageView( controller: _pageController, physics: NeverScrollableScrollPhysics(), children: [ HomePage(), MenuPage(), DevicePage(), QuickPage(), // LineChartSample2() ], ), bottomNavigationBar: BottomNavigationBar( selectedItemColor: Color.fromRGBO(43, 76, 126, 1), unselectedItemColor: Color.fromRGBO(43, 76, 126, .5), currentIndex: cuttentIndex, type: BottomNavigationBarType.fixed, onTap: (index) { setState(() { _pageController.jumpToPage(index); cuttentIndex = index; }); }, items: [ BottomNavigationBarItem( icon: Icon(Icons.home), label: '首页', ), BottomNavigationBarItem( icon: Icon(Icons.menu_book_rounded), label: '菜单', ), BottomNavigationBarItem( icon: Icon(Icons.memory), label: '设备', ), BottomNavigationBarItem( icon: Icon( Icons.quickreply, ), label: '快捷', ), // BottomNavigationBarItem( // icon: Icon( // Icons.quickreply, // ), // label: '11', // ), ], ), ); } }