import 'package:flutter/material.dart'; class AppButton extends StatelessWidget { final String text; final VoidCallback onPressed; final bool isLoading; final bool enabled; final Color? backgroundColor; final Color? textColor; final double? width; final double? height; const AppButton({ super.key, required this.text, required this.onPressed, this.isLoading = false, this.enabled = true, this.backgroundColor, this.textColor, this.width, this.height = 50, }); @override Widget build(BuildContext context) { return SizedBox( width: width ?? double.infinity, height: height, child: ElevatedButton( onPressed: enabled && !isLoading ? onPressed : null, style: ElevatedButton.styleFrom( backgroundColor: backgroundColor ?? Theme.of(context).primaryColor, foregroundColor: textColor ?? Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), elevation: 0, ), child: isLoading ? SizedBox( width: 24, height: 24, child: CircularProgressIndicator( strokeWidth: 2, color: textColor ?? Colors.white, ), ) : Text( text, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600, ), ), ), ); } }