import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_switch/flutter_switch.dart';
import 'package:smart_hotel_app/views/report/rule/cubit/rule_management_state.dart';

class RuleCard extends StatelessWidget {
  final RuleInfo rule;
  final Function(String) onToggle;

  const RuleCard({
    super.key,
    required this.rule,
    required this.onToggle,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 24.h, horizontal: 28.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(24.r),
      ),
      child: Row(
        children: [
          Container(
            width: 64.w,
            height: 53.h,
            decoration: BoxDecoration(
              color: const Color.fromRGBO(219, 234, 254, 1),
              borderRadius: BorderRadius.circular(8.r),
            ),
            child: Icon(
              rule.icon,
              size: 36.sp,
              color: const Color.fromRGBO(59, 130, 246, 1),
            ),
          ),
          SizedBox(width: 20.w),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  rule.name,
                  style: TextStyle(
                    fontSize: 28.sp,
                    fontWeight: FontWeight.bold,
                    color: const Color.fromRGBO(0, 0, 0, 1),
                  ),
                ),
                SizedBox(height: 8.h),
                Text(
                  rule.description,
                  style: TextStyle(
                    fontSize: 26.sp,
                    color: const Color.fromRGBO(156, 163, 175, 1),
                  ),
                ),
              ],
            ),
          ),
          FlutterSwitch(
            // width: 64.w,
            // height: 29.h,
            width: 80.w,
            height: 35.h,
            valueFontSize: 20.sp,
            toggleSize: 25.h,
            borderRadius: 20.r,
            padding: 4.w,
            value: rule.enabled,
            activeColor: const Color.fromRGBO(80, 162, 255, 1),
            inactiveColor: const Color.fromRGBO(210, 213, 218, 1),
            onToggle: (_) => onToggle(rule.id),
          ),
        ],
      ),
    );
  }
}
