import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/views/home/abnormal_list/cubit/abnormal_list_state.dart';

class FilterTabBlock extends StatelessWidget {
  final AlarmStatus currentFilter;
  final Function(AlarmStatus) onFilterChanged;

  const FilterTabBlock({
    super.key,
    required this.currentFilter,
    required this.onFilterChanged,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      margin: EdgeInsets.only(top: 10.h),
      child: Row(
        children: [
          _buildTab('全部', AlarmStatus.all),
          SizedBox(width: 20.w),
          _buildTab('待处理', AlarmStatus.pending),
          SizedBox(width: 20.w),
          _buildTab('已处理', AlarmStatus.processed),
          SizedBox(width: 20.w),
          _buildTab('误报', AlarmStatus.falseAlarm),
        ],
      ),
    );
  }

  Widget _buildTab(String label, AlarmStatus status) {
    final isSelected = currentFilter == status;
    return Expanded(
      child: GestureDetector(
        onTap: () => onFilterChanged(status),
        child: Container(
          height: 72.h,
          decoration: BoxDecoration(
            color: isSelected ? const Color.fromRGBO(73, 149, 234, 1) : const Color.fromRGBO(100, 116, 139, 0.1),
            borderRadius: BorderRadius.circular(16.r),
          ),
          alignment: Alignment.center,
          child: Text(
            label,
            style: TextStyle(
              fontSize: 26.sp,
              color: isSelected ? Colors.white : const Color.fromRGBO(100, 116, 139, 1),
            ),
          ),
        ),
      ),
    );
  }
}
