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

class BottomOperationBlock extends StatefulWidget {
  const BottomOperationBlock({super.key});

  @override
  State<BottomOperationBlock> createState() => _BottomOperationBlockState();
}

class _BottomOperationBlockState extends State<BottomOperationBlock> {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
          child: _buildOperationButton(
            '送电',
            Color.fromRGBO(73, 149, 234, 1),
            Colors.white,
            null,
          ),
        ),
        SizedBox(width: 16.w),
        Expanded(
          child: _buildOperationButton(
            '断电',
            Color.fromRGBO(229, 241, 255, 1),
            Color.fromRGBO(73, 149, 234, 1),
            BorderSide(
              color: Color.fromRGBO(73, 149, 234, 1),
              width: 1.w,
            ),
          ),
        ),
        SizedBox(width: 16.w),
        Expanded(
          child: _buildOperationButton(
            '设备控制',
            Color.fromRGBO(100, 116, 139, 0.2),
            Color.fromRGBO(100, 116, 139, 1),
            null,
          ),
        ),
      ],
    );
  }

  Widget _buildOperationButton(
    String text,
    Color backgroundColor,
    Color textColor,
    BorderSide? borderSide,
  ) {
    return ElevatedButton(
      style: ElevatedButton.styleFrom(
        backgroundColor: backgroundColor,
        minimumSize: Size(double.infinity, 88.h),
        padding: EdgeInsets.zero,
        shape: borderSide != null
            ? RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.r),
                side: borderSide,
              )
            : RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.r),
              ),
        elevation: 0,
      ),
      onPressed: () {},
      child: Text(
        text,
        style: TextStyle(
          fontSize: 28.sp,
          color: textColor,
          fontWeight: FontWeight.w500,
        ),
      ),
    );
  }
}
