import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/views/report/room/cubit/room_report_cubit.dart';

class FloorSelector extends StatelessWidget {
  final List<String> floorNames;
  final int selectedIndex;

  const FloorSelector({
    super.key,
    required this.floorNames,
    required this.selectedIndex,
  });

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 20.h),
      child: Row(
        spacing: 30.w,
        children: floorNames.asMap().entries.map((entry) {
          final index = entry.key;
          final name = entry.value;
          final isSelected = index == selectedIndex;
          return GestureDetector(
            behavior: HitTestBehavior.opaque,
            onTap: () {
              context.read<RoomReportCubit>().selectFloor(index);
            },
            child: Column(
              spacing: 10.h,
              children: [
                Text(
                  name,
                  style: TextStyle(
                    fontSize: 28.sp,
                    color: isSelected
                        ? const Color.fromRGBO(80, 162, 255, 1)
                        : const Color.fromRGBO(10, 13, 20, 1),
                    fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
                  ),
                ),
                Container(
                  width: 60.w,
                  height: 3.h,
                  decoration: BoxDecoration(
                    color: isSelected
                        ? const Color.fromRGBO(80, 162, 255, 1)
                        : Colors.transparent,
                    borderRadius: BorderRadius.circular(2.r),
                  ),
                ),
              ],
            ),
          );
        }).toList(),
      ),
    );
  }

}
