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

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

  final List<RBottomNavigationItem> items;
  final MainAxisAlignment? mainAxisAlignment;

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

class _RBottomNavigationState extends State<RBottomNavigation> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 80.h,

      padding: EdgeInsets.fromLTRB(11.w, 4.h, 11.w, 6.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: (isSelected ? 40 : 36).w,
              height: (isSelected ? 40 : 36).h,
              colorFilter: ColorFilter.mode(
                isSelected ? AppColor.blueNormal : Colors.white,
                BlendMode.srcIn,
              ),
            ),
            SizedBox(height: 5.h),
            Text(
              label,
              style: isSelected
                  ? AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal)
                  : AppFonts.yekan10.copyWith(color: Colors.white),
            ),
          ],
        ),
      ),
    );
  }
}
