import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';

class RBottomNavigation extends StatefulWidget {
  RBottomNavigation({super.key, required this.items,this.mainAxisAlignment});

  final List<RBottomNavigationItem> items;
  MainAxisAlignment? mainAxisAlignment;

  @override
  State<RBottomNavigation> createState() => _RBottomNavigationState();
}

class _RBottomNavigationState extends State<RBottomNavigation> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100.h,
      padding: EdgeInsets.symmetric(horizontal: 11.w, vertical: 18.h),
      decoration: BoxDecoration(
        color: AppColor.blueNormal,
        borderRadius: const BorderRadius.only(
          topLeft: Radius.circular(32),
          topRight: Radius.circular(32),
        ),
      ),
      child: Row(
        mainAxisAlignment: widget.mainAxisAlignment??MainAxisAlignment.spaceBetween,
        children: widget.items,
      ),
    );
  }
}

class RBottomNavigationItem extends StatelessWidget {
  final String icon;
  final String label;
  final bool isSelected;
  final Function() onTap;

  const RBottomNavigationItem({
    super.key,
    required this.icon,
    required this.label,
    required this.isSelected,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      constraints: BoxConstraints(
        minWidth: 70.h,
        minHeight: 70.h,
        maxHeight: 70.h
      ),
      padding: const EdgeInsets.symmetric(horizontal: 10),
      decoration: BoxDecoration(
        color: isSelected ? Colors.white.withAlpha(208) : Colors.transparent,
        borderRadius: BorderRadius.circular(10),
      ),
      child: InkWell(
        onTap: onTap,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SvgGenImage.vec(icon).svg(
              width: 40.w,
              height: 40.h,
              colorFilter: ColorFilter.mode(
                isSelected ? AppColor.blueNormal : Colors.white,
                BlendMode.srcIn,
              ),
            ),
            SizedBox(height: 5.h),
            Text(
              label,
              style: AppFonts.yekan10.copyWith(
                color: isSelected ? AppColor.blueNormal : Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
