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 TemperatureBlock extends StatelessWidget {
  final String temperatureAlarmTitle;
  final String temperatureAlarmLocation;
  final String currentTemperature;
  final String currentVoltage;
  final String currentCurrent;
  final String waitTime;
  final String alarmLevel;

  const TemperatureBlock({
    super.key,
    required this.temperatureAlarmTitle,
    required this.temperatureAlarmLocation,
    required this.currentTemperature,
    required this.currentVoltage,
    required this.currentCurrent,
    required this.waitTime,
    required this.alarmLevel,
  });

  @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(
        children: [
          Container(
            width: double.infinity,
            margin: EdgeInsets.only(bottom: 16.h),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Container(
                  width: 66.w,
                  height: 68.h,
                  decoration: BoxDecoration(
                    color: const Color.fromRGBO(235, 244, 255, 1.0),
                    borderRadius: BorderRadius.circular(12.r),
                  ),
                  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(
                        temperatureAlarmTitle,
                        style: TextStyle(
                          fontSize: 28.sp,
                          fontWeight: FontWeight.bold,
                          color: const Color.fromRGBO(0, 0, 0, 1.0),
                        ),
                      ),
                      SizedBox(height: 4.h),
                      Text(
                        temperatureAlarmLocation,
                        style: TextStyle(
                          fontSize: 24.sp,
                          color: const Color.fromRGBO(100, 116, 139, 1.0),
                        ),
                      ),
                    ],
                  ),
                ),
                Text(
                  '置顶',
                  style: TextStyle(
                    fontSize: 24.sp,
                    color: const Color.fromRGBO(255, 100, 101, 1.0),
                  ),
                ),
              ],
            ),
          ),
          Container(
            width: double.infinity,
            padding: EdgeInsets.symmetric(vertical: 20.h),
            decoration: BoxDecoration(
              color: const Color.fromRGBO(235, 244, 255, 1.0),
              borderRadius: BorderRadius.circular(16.r),
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                Expanded(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Text(
                        '$currentTemperature°C',
                        style: TextStyle(
                          fontSize: 40.sp,
                          fontWeight: FontWeight.bold,
                          color: const Color.fromRGBO(255, 77, 79, 1.0),
                        ),
                      ),
                      SizedBox(height: 4.h),
                      Text(
                        '当前温度',
                        style: TextStyle(
                          fontSize: 20.sp,
                          color: const Color.fromRGBO(100, 116, 139, 1.0),
                        ),
                      ),
                    ],
                  ),
                ),
                Expanded(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Text(
                        '${currentVoltage}V',
                        style: TextStyle(
                          fontSize: 40.sp,
                          fontWeight: FontWeight.bold,
                          color: const Color.fromRGBO(66, 165, 245, 1.0),
                        ),
                      ),
                      SizedBox(height: 4.h),
                      Text(
                        '电压',
                        style: TextStyle(
                          fontSize: 20.sp,
                          color: const Color.fromRGBO(100, 116, 139, 1.0),
                        ),
                      ),
                    ],
                  ),
                ),
                Expanded(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Text(
                        '${currentCurrent}A',
                        style: TextStyle(
                          fontSize: 40.sp,
                          fontWeight: FontWeight.bold,
                          color: const Color.fromRGBO(66, 165, 245, 1.0),
                        ),
                      ),
                      SizedBox(height: 4.h),
                      Text(
                        '电流',
                        style: TextStyle(
                          fontSize: 20.sp,
                          color: const Color.fromRGBO(100, 116, 139, 1.0),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          SizedBox(height: 16.h),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Icon(
                    Icons.access_time,
                    color: const Color.fromRGBO(100, 116, 139, 1.0),
                    size: 24.sp,
                  ),
                  SizedBox(width: 8.w),
                  Text(
                    '已等待$waitTime·',
                    style: TextStyle(
                      fontSize: 24.sp,
                      color: const Color.fromRGBO(100, 116, 139, 1.0),
                    ),
                  ),
                  Text(
                    alarmLevel,
                    style: TextStyle(
                      fontSize: 24.sp,
                      fontWeight: FontWeight.bold,
                      color: const Color.fromRGBO(255, 77, 79, 1.0),
                    ),
                  ),
                ],
              ),
              GestureDetector(
                onTap: () {
                  context.pushRoute(const AbnormalDetailRoute());
                },
                child: Container(
                  padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 20.h),
                  decoration: BoxDecoration(
                    color: const Color.fromRGBO(66, 165, 245, 1.0),
                    borderRadius: BorderRadius.circular(16.r),
                  ),
                  child: Text(
                    '立即处理',
                    style: TextStyle(
                      fontSize: 24.sp,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}