import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class RoomBottomButtons extends StatelessWidget {
  final VoidCallback? onPowerOn;
  final VoidCallback? onPowerOff;
  final bool isPoweringOn;
  final bool isPoweringOff;

  const RoomBottomButtons({
    super.key,
    this.onPowerOn,
    this.onPowerOff,
    this.isPoweringOn = false,
    this.isPoweringOff = false,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      spacing: 12.w,
      children: [
        Expanded(
          child: GestureDetector(
            onTap: (onPowerOn != null && !isPoweringOn) ? onPowerOn : null,
            child: Container(
              height: 70.h,
              decoration: BoxDecoration(
                color: (onPowerOn != null && !isPoweringOn)
                    ? const Color.fromRGBO(73, 149, 234, 1)
                    : const Color.fromRGBO(204, 204, 204, 1),
                borderRadius: BorderRadius.circular(16.r),
              ),
              child: Center(
                child: isPoweringOn
                    ? SizedBox(
                        width: 32.w,
                        height: 32.w,
                        child: CircularProgressIndicator(
                          strokeWidth: 3.w,
                          color: const Color.fromRGBO(66, 165, 245, 1.0),
                        ),
                      )
                    : Text(
                        '送电',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 28.sp,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
              ),
            ),
          ),
        ),
        Expanded(
          child: GestureDetector(
            onTap: (onPowerOff != null && !isPoweringOff) ? onPowerOff : null,
            child: Container(
              height: 70.h,
              decoration: BoxDecoration(
                color: (onPowerOff != null && !isPoweringOff)
                    ? const Color.fromRGBO(229, 241, 255, 1)
                    : const Color.fromRGBO(204, 204, 204, 1),
                borderRadius: BorderRadius.circular(16.r),
              ),
              child: Center(
                child: isPoweringOff
                    ? SizedBox(
                        width: 32.w,
                        height: 32.w,
                        child: CircularProgressIndicator(
                          strokeWidth: 3.w,
                          color: const Color.fromRGBO(229, 241, 255, 1),
                        ),
                      )
                    : Text(
                        '断电',
                        style: TextStyle(
                          color: const Color.fromRGBO(100, 116, 139, 1),
                          fontSize: 28.sp,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}