import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:creekui/ui/styles/variables.dart';
class PrimaryButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool isLoading;
final String? iconPath;
final Color? backgroundColor;
const PrimaryButton({
super.key,
required this.text,
this.onPressed,
this.isLoading = false,
this.iconPath,
this.backgroundColor,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: isLoading ? null : onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: backgroundColor ?? Variables.textPrimary,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100),
),
elevation: 0,
),
child:
isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(text, style: Variables.buttonTextStyle),
if (iconPath != null) ...[
const SizedBox(width: 12),
SvgPicture.asset(
iconPath!,
width: 18,
height: 18,
colorFilter: const ColorFilter.mode(
Colors.white,
BlendMode.srcIn,
),
),
],
],
),
),
);
}
}