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

const kPanelBg = Color(0xE8181818);
const kPanelDivider = Color(0x33FFFFFF);

Widget panelDivider() => const FDivider(
  style: .delta(color: kPanelDivider, padding: .value(EdgeInsets.zero)),
);

class PlayerPanelShell extends StatelessWidget {
  final IconData icon;
  final String title;
  final double width;
  final VoidCallback onClose;
  final Widget child;

  const PlayerPanelShell({
    super.key,
    required this.icon,
    required this.title,
    required this.width,
    required this.onClose,
    required this.child,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Container(
        width: width,
        decoration: BoxDecoration(
          color: kPanelBg,
          borderRadius: BorderRadius.circular(12),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            _header(),
            panelDivider(),
            Flexible(child: child),
          ],
        ),
      ),
    );
  }

  Widget _header() {
    return Padding(
      padding: const EdgeInsets.fromLTRB(16, 12, 8, 10),
      child: Row(
        children: [
          Icon(icon, color: Colors.white70, size: 18),
          const SizedBox(width: 8),
          Text(
            title,
            style: const TextStyle(
              color: Colors.white,
              fontSize: 15,
              fontWeight: FontWeight.w600,
            ),
          ),
          const Spacer(),
          IconButton(
            icon: const Icon(Icons.close, color: Colors.white54, size: 18),
            onPressed: onClose,
            padding: EdgeInsets.zero,
            constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
          ),
        ],
      ),
    );
  }
}
