import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:muaawana/widgets/primary_button_widget.dart'; import '../config/size.dart'; import '../utils/text_style.dart'; import '../utils/text_widget.dart'; Future Popup(BuildContext context, String confirmText, {String? title, String? description, Function? confirmFunction}) { return showDialog( context: context, builder: (BuildContext context) { return StatefulBuilder(builder: (context, stating) { final hm = SizeConfig.heightMultiplier; final wm = SizeConfig.widthMultiplier; final tm = SizeConfig.textMultiplier; return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(wm * 5.0)), //this right here child: SizedBox( height: hm * 35, child: Stack( alignment: Alignment.center, children: [ title != null ? title == "Error" || title.toLowerCase() == "error" ? Positioned( top: hm * 3, child: SizedBox( width: wm * 60, child: Image.asset( "assets/icons/warning.png", width: wm * 60, height: hm * 7, fit: BoxFit.fitHeight, )), ) : Positioned( top: hm * 6, child: Padding( padding: EdgeInsets.fromLTRB( wm * 2.5, hm * 1, wm * 2.5, hm * 3), child: Container( width: wm * 60, height: hm * 10, color: Colors.white, child: Txt( text: title, maxLines: 2, textAlign: TextAlign.center, style: tS('NunitoBold', tm * 2.5, FontWeight.normal, Colors.black), ), ), ), ) : Positioned( top: hm * 4, child: SizedBox( width: wm * 60, child: Image.asset( "assets/icons/warning.png", width: wm * 60, height: hm * 7, fit: BoxFit.fitHeight, )), ), if (description != null) Positioned( child: Container( margin: EdgeInsetsDirectional.only( top: hm * 2, start: wm * 2.5, end: wm * 2.5), width: wm * 60, height: hm * 10, color: Colors.white, child: Txt( text: description, maxLines: 2, textAlign: TextAlign.center, style: tS('NunitoMedium', tm * 2.2, FontWeight.normal, Colors.black), ), ), ), Positioned( top: hm * 1, right: wm * 2, child: TextButton( onPressed: () { Navigator.pop(context); }, style: ButtonStyle( overlayColor: MaterialStateProperty.resolveWith( (states) => Colors.transparent)), child: SvgPicture.asset( 'assets/icons/close.svg', height: hm * 3.5, ), ), ), Positioned( bottom: hm * 4, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ //if(isConfirm) primaryButton( height: hm * 5.0, width: wm * 30, borderRadius: BorderRadius.circular(wm * 4), widget: FittedBox( child: Padding( padding: EdgeInsets.symmetric(horizontal: wm * 2), child: Txt( text: confirmText, style: tS('NunitoBold', tm * 2, FontWeight.normal, Colors.white), ), ), ), function: () { if (confirmFunction != null) { confirmFunction(); } else { Navigator.pop(context); } }), ], ), ), ], ), ), ); }); }); }