Enhanced the code and look of DialogFooter buttons.

This commit is contained in:
Faris Armoush
2025-04-15 13:06:30 +03:00
parent 616adccfdd
commit 7dcaa20da1

View File

@ -8,12 +8,12 @@ class DialogFooter extends StatelessWidget {
final int? dialogWidth;
const DialogFooter({
Key? key,
super.key,
required this.onCancel,
required this.onConfirm,
required this.isConfirmEnabled,
this.dialogWidth,
}) : super(key: key);
});
@override
Widget build(BuildContext context) {
@ -28,21 +28,19 @@ class DialogFooter extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: _buildFooterButton(
context,
'Cancel',
onCancel,
),
_buildFooterButton(
context: context,
text: 'Cancel',
onTap: onCancel,
),
if (isConfirmEnabled) ...[
Container(width: 1, height: 50, color: ColorsManager.greyColor),
Expanded(
child: _buildFooterButton(
context,
'Confirm',
onConfirm,
),
_buildFooterButton(
context: context,
text: 'Confirm',
onTap: onConfirm,
textColor:
isConfirmEnabled ? ColorsManager.primaryColorWithOpacity : Colors.red,
),
],
],
@ -50,24 +48,24 @@ class DialogFooter extends StatelessWidget {
);
}
Widget _buildFooterButton(
BuildContext context,
String text,
VoidCallback? onTap,
) {
return GestureDetector(
onTap: onTap,
child: SizedBox(
height: 50,
child: Center(
child: Text(
text,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
color: text == 'Confirm'
? ColorsManager.primaryColorWithOpacity
: ColorsManager.textGray,
),
),
Widget _buildFooterButton({
required BuildContext context,
required String text,
required VoidCallback? onTap,
Color? textColor,
}) {
return Expanded(
child: TextButton(
style: TextButton.styleFrom(
foregroundColor: ColorsManager.primaryColorWithOpacity,
disabledForegroundColor: ColorsManager.primaryColor,
),
onPressed: onTap,
child: Text(
text,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: textColor ?? ColorsManager.textGray,
),
),
),
);