import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:test_sa/views/app_style/sizing.dart';

class AIconButton extends StatelessWidget {
  final IconData iconData;
  final Color? color; // Nullable
  final Color? backgroundColor; // Nullable
  final VoidCallback? onPressed; // Nullable
  final double? iconSize; // Nullable
  final double buttonSize;

  const AIconButton({
    Key? key,
    required this.iconData,
    this.onPressed,
    this.color,
    this.iconSize,
    this.buttonSize = 54,
    this.backgroundColor,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: buttonSize * AppStyle.getScaleFactor(context),
      width: buttonSize * AppStyle.getScaleFactor(context),
      child: ElevatedButton(
        style: ElevatedButton.styleFrom(
          padding: EdgeInsets.zero,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular((AppStyle.borderRadius - 4) * AppStyle.getScaleFactor(context)),
          ),
          backgroundColor: backgroundColor,
        ),
        onPressed: onPressed,
        child: FaIcon(
          iconData,
          color: color,
          size: iconSize ?? 32,
        ),
      ),
    );
  }
}
