import '../../../../food_delivery_client.dart';

class AppButton extends StatelessWidget {
  const AppButton({
    super.key,
    required this.name,
    this.onPressed,
    this.margin,
    this.backgroundColor,
    this.borderRadius,
    this.height,
    this.textColor,
    this.width,
    this.leading,
    this.trailing,
    this.mainAxisAlignment,
    this.isLoading = false,
  });

  final String name;
  final VoidCallback? onPressed;
  final EdgeInsets? margin;
  final Color? backgroundColor;
  final Color? textColor;
  final double? borderRadius;
  final double? width;
  final double? height;
  final Widget? leading;
  final Widget? trailing;
  final bool isLoading;
  final MainAxisAlignment? mainAxisAlignment;

  @override
  Widget build(BuildContext context) {
    return Bounceable(
      onTap: onPressed,
      duration: TimeDelayConst.durationMill150,
      child: Container(
        width: width ?? double.infinity,
        height: height ?? 55,
        margin: margin,
        alignment: Alignment.center,
        padding: const EdgeInsets.symmetric(horizontal: 16),
        decoration: BoxDecoration(
          color: backgroundColor ?? AppColors.c000000,
          borderRadius: BorderRadius.circular(borderRadius ?? 0),
        ),
        child: isLoading
            ? Center(
                child: CircularProgressIndicator.adaptive(
                  padding: EdgeInsets.all(2),
                  valueColor: AlwaysStoppedAnimation(AppColors.cFFFFFF),
                  backgroundColor: AppColors.cFFFFFF,
                ),
              )
            : Row(
                mainAxisAlignment:
                    mainAxisAlignment ?? MainAxisAlignment.center,
                children: [
                   leading?? AppUtils.kSizedBox,
                  Text(
                    name,
                    style: AppTextStyles.size16Bold.copyWith(
                      color: AppColors.cFFFFFF,
                    ),
                  ),
                  trailing ?? AppUtils.kSizedBox,
                ],
              ),
      ),
    );
  }
}
