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

import 'device_control_common.dart';

/// 信息展示面板（新风进化/开放供氧 等）
class DeviceControlInfoPanel extends StatelessWidget {
  const DeviceControlInfoPanel({
    super.key,
    required this.title,
    required this.actionText,
    required this.icon,
    required this.body,
    this.warning,
    this.active = false,
    this.onTap,
  });

  final String title;
  final String actionText;
  final IconData icon;
  final String body;
  final String? warning;
  final bool active;
  final VoidCallback? onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: DeviceControlPanelFrame(
        backgroundAsset: assetPanelWide,
        padding: EdgeInsets.fromLTRB(30.w, 22.h, 30.w, 24.h),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Expanded(child: DeviceControlPanelTitle(title)),
                DeviceControlPill(text: actionText, active: active),
              ],
            ),
            const Spacer(),
            Row(
              children: [
                Icon(
                  icon,
                  color: active
                      ? const Color(0xFF45F36F)
                      : const Color(0xFF6AC6F2),
                  size: 54.w,
                ),
                SizedBox(width: 28.w),
                Expanded(
                  child: Text(
                    body,
                    style: TextStyle(
                      color: const Color(0xFFC9F8FF),
                      fontSize: 20.sp,
                      height: 1.35,
                    ),
                  ),
                ),
              ],
            ),
            if (warning != null) ...[
              SizedBox(height: 8.h),
              Text(
                warning!,
                style: TextStyle(
                  color: const Color(0xFFFFC400),
                  fontSize: 16.sp,
                ),
              ),
            ],
          ],
        ),
      ),
    );
  }
}
