import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import '../../themes/app_dimension.dart'; import '../../themes/app_colors.dart'; import '../../themes/styles_text.dart'; class DialogWidget extends StatelessWidget { final String icon; final Color? iconColor; final String title; final String message; final String confirmTitle; final String? cancelTitle; final String? otherTitle; final Widget? customWidget; final Function onPressedConfirm; final Function? onPressedCancel; final Function? onPressedOther; final Color? colorConfirmButton; const DialogWidget({ Key? key, required this.icon, required this.title, required this.message, required this.confirmTitle, required this.onPressedConfirm, this.iconColor, this.customWidget, this.onPressedCancel, this.cancelTitle, this.onPressedOther, this.otherTitle, this.colorConfirmButton, }) : super(key: key); @override Widget build(BuildContext context) { return SingleChildScrollView( child: Column( mainAxisSize: MainAxisSize.min, children: [ SizedBox( height: 35.h, ), SvgPicture.asset(icon, color: iconColor), SizedBox( height: 13.h, ), Padding( padding: EdgeInsets.only(left: 30.0.w, right: 30.0.w), child: Text( title, style: StylesText.header1, textAlign: TextAlign.center, ), ), const SizedBox( height: 10, ), Padding( padding: EdgeInsets.only(left: 30.0.w, right: 30.0.w), child: Text( message, style: StylesText.body3, textAlign: TextAlign.center, ), ), Container( padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 16.h), child: customWidget ?? const SizedBox.shrink(), ), Padding( padding: EdgeInsets.only(left: 30.0.w, right: 30.w, top: customWidget != null ? 0 : 40.h, bottom: 10.h), child: SizedBox( height: 48.h, width: double.infinity.w, child: ElevatedButton( onPressed: () { onPressedConfirm(); }, style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (states) { return colorConfirmButton ?? AppColors.primary1; }, ), shadowColor: MaterialStateProperty.resolveWith( (states) { return Colors.transparent; }, ), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(0.0), ), ), ), child: Text( confirmTitle.toUpperCase(), style: StylesText.body5.copyWith( color: AppColors.white, ), ), ), ), ), cancelTitle != null ? Padding( padding: EdgeInsets.only(left: 30.0.w, right: 30.w, top: 0.h, bottom: 10.h), child: SizedBox( height: 48.h, width: double.infinity.w, child: ElevatedButton( onPressed: () { onPressedCancel!(); }, style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (states) { return AppColors.white; }, ), shadowColor: MaterialStateProperty.resolveWith( (states) { return Colors.transparent; }, ), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(0.0), side: BorderSide( color: AppColors.primary1, ), ), ), ), child: Text( cancelTitle!.toUpperCase(), style: StylesText.body5.copyWith( color: AppColors.neutral1, ), ), ), ), ) : const SizedBox.shrink(), otherTitle != null ? Padding( padding: EdgeInsets.only(left: 30.0.w, right: 30.w, top: 0.h, bottom: 10.h), child: SizedBox( height: 48.h, width: double.infinity.w, child: ElevatedButton( onPressed: () { onPressedOther!(); }, style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith( (states) { return AppColors.white; }, ), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(0.0), side: BorderSide( color: AppColors.primary1, ), ), ), ), child: Text( otherTitle!.toUpperCase(), style: StylesText.body5.copyWith( color: AppColors.neutral1, ), ), ), ), ) : const SizedBox.shrink(), SizedBox( height: 40.h, ) ], ), ); } }