import 'package:flutter/material.dart';
import 'package:kasy_kit/core/haptics/kasy_haptics.dart';
import 'package:kasy_kit/core/theme/theme.dart';

typedef SocialSigninCallback = void Function();

class SocialSigninButton extends StatelessWidget {
  final Image iconImage;
  final SocialSigninCallback? onPressed;

  const SocialSigninButton({
    super.key,
    required this.iconImage,
    required this.onPressed,
  });

  factory SocialSigninButton.google(SocialSigninCallback onPressed) {
    return SocialSigninButton(
      iconImage: Image.asset("assets/icons/google.png", width: 24),
      onPressed: onPressed,
    );
  }

  factory SocialSigninButton.googlePlayGames(SocialSigninCallback onPressed) {
    return SocialSigninButton(
      iconImage: Image.asset("assets/icons/google_play_games.png", width: 24),
      onPressed: onPressed,
    );
  }

  factory SocialSigninButton.facebook(SocialSigninCallback onPressed) {
    return SocialSigninButton(
      iconImage: Image.asset("assets/icons/facebook.png", width: 24),
      onPressed: onPressed,
    );
  }

  factory SocialSigninButton.apple(SocialSigninCallback onPressed) {
    return SocialSigninButton(
      iconImage: Image.asset("assets/icons/apple.png", width: 24),
      onPressed: onPressed,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 56,
      decoration: BoxDecoration(
        border: Border.all(color: context.colors.outline),
        shape: BoxShape.circle,
      ),
      child: RawMaterialButton(
        elevation: 0,
        focusElevation: 0,
        hoverElevation: 0,
        highlightElevation: 0,
        splashColor: Colors.transparent,
        highlightColor: Colors.transparent,
        hoverColor: Colors.transparent,
        focusColor: Colors.transparent,
        onPressed: () {
          KasyHaptics.medium(context);
          onPressed?.call();
        },
        shape: const CircleBorder(),
        fillColor: Colors.transparent,
        padding: const EdgeInsets.all(KasySpacing.md),
        child: iconImage,
      ),
    );
  }
}
