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.gr.dart';

class VoltageOperateBlock extends StatelessWidget {
  final String voltageAlarmTitle;
  final String voltageAlarmLocation;
  final String voltageValue;
  final String normalVoltage;
  final String voltageWaitTime;
  final String voltageAlarmLevel;

  const VoltageOperateBlock({
    super.key,
    required this.voltageAlarmTitle,
    required this.voltageAlarmLocation,
    required this.voltageValue,
    required this.normalVoltage,
    required this.voltageWaitTime,
    required this.voltageAlarmLevel,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: EdgeInsets.all(20.w),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(20.r),
        color: Colors.white,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            width: double.infinity,
            margin: EdgeInsets.only(bottom: 16.h),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Container(
                  width: 64.w,
                  height: 66.h,
                  decoration: BoxDecoration(
                    color: const Color.fromRGBO(235, 244, 255, 1.0),
                    borderRadius: BorderRadius.circular(12.r),
                    border: Border.all(
                      color: const Color.fromRGBO(66, 165, 245, 1.0),
                      width: 2.w,
                      style: BorderStyle.solid,
                    ),
                  ),
                  child: Icon(
                    Icons.thermostat_outlined,
                    color: const Color.fromRGBO(66, 165, 245, 1.0),
                    size: 32.sp,
                  ),
                ),
                SizedBox(width: 16.w),
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        voltageAlarmTitle,
                        style: TextStyle(
                          fontSize: 28.sp,
                          fontWeight: FontWeight.bold,
                          color: Colors.black,
                        ),
                      ),
                      SizedBox(height: 4.h),
                      Text(
                        voltageAlarmLocation,
                        style: TextStyle(
                          fontSize: 24.sp,
                          color: const Color.fromRGBO(100, 116, 139, 1.0),
                        ),
                      ),
                    ],
                  ),
                ),
                Text(
                  voltageAlarmLevel,
                  style: TextStyle(
                    fontSize: 24.sp,
                    fontWeight: FontWeight.bold,
                    color: const Color.fromRGBO(255, 204, 21, 1.0),
                  ),
                ),
              ],
            ),
          ),
          Container(
            width: double.infinity,
            margin: EdgeInsets.only(left: 80.w, bottom: 20.h),
            child: Text(
              '电压${voltageValue}V (正常≤${normalVoltage}V)·已等待$voltageWaitTime',
              style: TextStyle(
                fontSize: 24.sp,
                color: const Color.fromRGBO(100, 116, 139, 1.0),
              ),
            ),
          ),
          Container(
            width: double.infinity,
            child: Row(
              children: [
                Expanded(
                  child: GestureDetector(
                    onTap: () {},
                    child: Container(
                      height: 88.h,
                      decoration: BoxDecoration(
                        color: const Color.fromRGBO(66, 165, 245, 1.0),
                        borderRadius: BorderRadius.circular(16.r),
                      ),
                      child: Center(
                        child: Text(
                          '确认处理',
                          style: TextStyle(
                            fontSize: 28.sp,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
                SizedBox(width: 20.w),
                Expanded(
                  child: GestureDetector(
                    onTap: () {
                      context.pushRoute(const AbnormalDetailRoute());
                    },
                    child: Container(
                      height: 88.h,
                      decoration: BoxDecoration(
                        color: const Color.fromRGBO(235, 244, 255, 1.0),
                        borderRadius: BorderRadius.circular(16.r),
                      ),
                      child: Center(
                        child: Text(
                          '查看详情',
                          style: TextStyle(
                            fontSize: 28.sp,
                            color: const Color.fromRGBO(100, 116, 139, 1.0),
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}