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