12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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<BarItem> 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),
- );
- })
- ],
- ),
- ),
- );
- }
- }
|