import 'package:flutter/material.dart';


class ResendLink extends StatelessWidget {
  final String label;
  final VoidCallback onPressed;
  final bool isDisabled;
  final bool isLoading;

  const ResendLink({
    super.key,
    required this.label,
    required this.onPressed,
    this.isDisabled = false,
    this.isLoading = false,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    final color = theme.colorScheme.primary;
    final isButtonDisabled = isDisabled || isLoading;

    return TextButton(
      onPressed: isButtonDisabled ? null : onPressed,
      style: TextButton.styleFrom(
        padding: EdgeInsets.zero,
        minimumSize: const Size(0, 0),
        tapTargetSize: MaterialTapTargetSize.shrinkWrap,
        alignment: Alignment.centerLeft,
        foregroundColor: color,
        textStyle: theme.textTheme.bodyMedium?.copyWith(
          decoration: TextDecoration.underline,
        ),
      ),
      child: isLoading
          ? SizedBox(
              width: 16,
              height: 16,
              child: CircularProgressIndicator(
                strokeWidth: 2,
                color: color,
              ),
            )
          : Text(label),
    );
  }
}
