import 'package:flutter/material.dart';

/// Function buttons (HOME, F1-F7) for wall presets
class FunctionButtonsWidget extends StatelessWidget {
  final Function(String buttonId)? onButtonPressed;

  const FunctionButtonsWidget({
    super.key,
    this.onButtonPressed,
  });

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        _FunctionButton(
          label: 'HOME',
          buttonId: 'HOME',
          onPressed: onButtonPressed,
          isHome: true,
        ),
        const SizedBox(width: 4),
        ...List.generate(7, (index) {
          return Padding(
            padding: const EdgeInsets.only(left: 4),
            child: _FunctionButton(
              label: 'F${index + 1}',
              buttonId: 'F${index + 1}',
              onPressed: onButtonPressed,
            ),
          );
        }),
      ],
    );
  }
}

class _FunctionButton extends StatelessWidget {
  final String label;
  final String buttonId;
  final Function(String)? onPressed;
  final bool isHome;

  const _FunctionButton({
    required this.label,
    required this.buttonId,
    this.onPressed,
    this.isHome = false,
  });

  @override
  Widget build(BuildContext context) {
    return Material(
      color: isHome ? const Color(0xFF2B6CB0) : const Color(0xFF4A5568),
      borderRadius: BorderRadius.circular(4),
      child: InkWell(
        onTap: onPressed != null ? () => onPressed!(buttonId) : null,
        borderRadius: BorderRadius.circular(4),
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
          child: Text(
            label,
            style: const TextStyle(
              color: Colors.white,
              fontSize: 12,
              fontWeight: FontWeight.bold,
            ),
          ),
        ),
      ),
    );
  }
}
