import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:school_asignment_app/common/store/user_store.dart'; import 'package:school_asignment_app/routes/app_pages.dart'; const _items = [ { 'id': 1, 'title': '作业', 'img': 'assets/images/ic_work_normal.png', 'activeImg': 'assets/images/ic_work_press.png', 'route': Routes.home, }, { 'id': 2, 'title': '考试', 'img': 'assets/images/ic_work_normal.png', 'activeImg': 'assets/images/ic_work_press.png', 'route': Routes.home, }, { 'id': 3, 'title': '我的', 'img': 'assets/images/ic_work_normal.png', 'activeImg': 'assets/images/ic_work_press.png', 'route': Routes.myInfo, }, ]; /// 底部导航栏 class MyBottomNavigationBar extends StatelessWidget { final UserStore userStore = UserStore.to; final int active; MyBottomNavigationBar({Key? key, this.active = 1}) : super(key: key); @override Widget build(BuildContext context) { return Container( height: 50.r, margin: EdgeInsets.only(bottom: Get.mediaQuery.padding.bottom), decoration: const BoxDecoration( color:Colors.white, ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: _items .map((e) => InkWell( onTap: () async { if (active == e['id']) { return; } Get.offAllNamed(e['route'] as String,arguments: e['id']); }, child: Container( width: 60.r, color: Colors.transparent, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ e['img'] == null ? SizedBox( width: 22.r, height: 21.r, ) : Image.asset( active == (e['id'] as int) ? e['activeImg'] as String : e['img'] as String, width: 22.r, height: 22.r, fit: BoxFit.fill, ), Text( e['title'] as String, style: TextStyle( color: active == (e['id'] as int) ? const Color(0xFF6888FD) : const Color(0xFF767676), fontSize: 11.sp,), strutStyle: StrutStyle(fontSize: 16.sp), ) ], ), ), )) .toList(), ), ); } }