import 'package:farmer_client/widgets/layout/bottomBar/item.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; class BottomBarItem extends StatelessWidget { final bool selected; final BarItem data; BottomBarItem({Key? key, required this.selected, required this.data}) : super(key: key); @override Widget build(BuildContext context) { final image = selected ? data.selected.image : data.normal.image; final color = selected ? data.selected.color : data.normal.color; final fontSize = selected ? data.selected.fontSize : data.normal.fontSize; final textStyle = TextStyle( color: color, fontSize: fontSize, fontWeight: FontWeight.bold); return GestureDetector( onTap: () { if (!selected) { Get.offNamed(data.page); } }, child: Column( children: [ Expanded( flex: 1, child: Image.asset(image, fit: BoxFit.cover), ), Expanded( flex: 1, child: Center( child: Text(data.label, style: textStyle), ), ), ], ), ); } } class BottomBar extends StatelessWidget { final int current; List list; BottomBar({Key? key, required this.list, required this.current}) : super(key: key); @override Widget build(BuildContext context) { return Container( width: double.infinity, height: 65.w, padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 0), decoration: BoxDecoration( color: const Color(0xFFFFFFFF), boxShadow: [ BoxShadow( color: const Color(0x14000000), offset: Offset(0, -2.w), blurRadius: 3.w, ), ], ), child: Center( child: Row( children: [ ...list.map((item) { int index = list.indexOf(item); return Expanded( flex: 1, child: BottomBarItem(data: item, selected: current == index), ); }) ], ), ), ); } }