import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:smart_hotel_app/routes/app_router.dart';
import 'package:smart_hotel_app/routes/app_router.gr.dart';

class QuickActionsBlock extends StatelessWidget {
  final Map<String, dynamic> quickActions;

  const QuickActionsBlock({super.key, required this.quickActions});

  @override
  Widget build(BuildContext context) {
    final actions = quickActions['actions'] as List<Map<String, dynamic>>;

    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(28.w),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(24.r),
        color: Colors.white,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            quickActions['title'] as String,
            style: TextStyle(
              fontSize: 28.sp,
              fontWeight: FontWeight.normal,
              color: const Color.fromRGBO(107, 114, 128, 1),
            ),
          ),
          SizedBox(height: 28.h),
          Row(
            children: actions.map((action) {
              final name = action['name'] as String;
              return Padding(
                padding: EdgeInsets.only(right: 60.w),
                child: GestureDetector(
                  onTap: () {
                    if (name == '联动规则') {
                      context.pushRoute(const ReportRuleManagementRoute());
                    } else if (name == '告警记录') {
                      context.pushRoute(const AbnormalListRoute());
                    }
                  },
                  child: Column(
                    children: [
                      Container(
                        width: 80.w,
                        height: 80.h,
                        decoration: BoxDecoration(
                          color: const Color.fromRGBO(239, 246, 255, 1),
                          borderRadius: BorderRadius.circular(16.r),
                        ),
                        child: Icon(
                          action['icon'] as IconData,
                          color: const Color.fromRGBO(59, 130, 246, 1),
                          size: 36.sp,
                        ),
                      ),
                      SizedBox(height: 8.h),
                      Text(
                        name,
                        style: TextStyle(
                          fontSize: 22.sp,
                          color: const Color.fromRGBO(107, 114, 128, 1),
                        ),
                      ),
                    ],
                  ),
                ),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }
}