This commit is contained in:
Phuoc Nguyen
2025-10-10 16:38:07 +07:00
parent e5b247d622
commit b94c158004
177 changed files with 25080 additions and 152 deletions

View File

@@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import '../constants/ui_constants.dart';
/// Custom button widget
class CustomButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool isLoading;
final bool isOutlined;
final IconData? icon;
final Color? backgroundColor;
const CustomButton({
super.key,
required this.text,
this.onPressed,
this.isLoading = false,
this.isOutlined = false,
this.icon,
this.backgroundColor,
});
@override
Widget build(BuildContext context) {
if (isOutlined) {
return OutlinedButton.icon(
onPressed: isLoading ? null : onPressed,
icon: isLoading
? const SizedBox(
width: UIConstants.iconSizeS,
height: UIConstants.iconSizeS,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Icon(icon ?? Icons.check),
label: Text(text),
style: OutlinedButton.styleFrom(
minimumSize: const Size(double.infinity, UIConstants.buttonHeightM),
),
);
}
if (icon != null) {
return ElevatedButton.icon(
onPressed: isLoading ? null : onPressed,
icon: isLoading
? const SizedBox(
width: UIConstants.iconSizeS,
height: UIConstants.iconSizeS,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Icon(icon),
label: Text(text),
style: ElevatedButton.styleFrom(
minimumSize: const Size(double.infinity, UIConstants.buttonHeightM),
backgroundColor: backgroundColor,
),
);
}
return ElevatedButton(
onPressed: isLoading ? null : onPressed,
style: ElevatedButton.styleFrom(
minimumSize: const Size(double.infinity, UIConstants.buttonHeightM),
backgroundColor: backgroundColor,
),
child: isLoading
? const SizedBox(
width: UIConstants.iconSizeM,
height: UIConstants.iconSizeM,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text(text),
);
}
}