import 'package:wanisclient/config/custom_text.dart'; import 'package:wanisclient/utils/colors.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/language_provider.dart'; import '../widgets/custom_button.dart'; import 'constants/arabe.dart' as Language; class CustomPopup extends StatelessWidget { final String imagePath; final bool twoButton; final String message; final String? description; final VoidCallback onOk; final bool loader; const CustomPopup({ super.key, required this.imagePath, required this.loader, required this.message, this.twoButton = false, this.description, required this.onOk, }); @override Widget build(BuildContext context) { final langCode = context.watch().currentLangCode; // Cache screen dimensions final mq = MediaQuery.of(context); final btnWidth = mq.size.width; final btnHeight = mq.size.height * 0.05; const yesLabel = 'Continue'; const noLabel = 'Dismiss'; Widget buildButton({ required String title, required Color bg, required Color border, required VoidCallback onTap, }) { return SizedBox( width: btnWidth, height: btnHeight, child: CustomButton( onClick: onTap, width: btnWidth, height: btnHeight, fontSize: 18, borderRadius: 10, title: title, backgroundColor: bg, borderColor: border, txtColor: AppColors.white, isloading: loader, loadercolor: AppColors.white, ), ); } return Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), backgroundColor: Colors.white, child: Padding( padding: const EdgeInsets.all(20), child: Column( mainAxisSize: MainAxisSize.min, children: [ if (twoButton) const Icon(Icons.delete_forever_outlined, size: 70, color: Colors.red) else Image.asset(imagePath, height: 78), const SizedBox(height: 20), Txt( text: message, textAlign: TextAlign.center, style: const TextStyle( fontSize: 18, color: Colors.black, fontWeight: FontWeight.bold), ), if(description!=null) const SizedBox(height: 15), if(description!=null) Txt( text: description??"", textAlign: TextAlign.center, style: const TextStyle( fontSize: 15, color: Colors.black, fontWeight: FontWeight.normal), ), const SizedBox(height: 30), if (twoButton) Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: buildButton( title: yesLabel, bg: AppNewColors.primaryBtnColor, border: AppNewColors.primaryBtnColor, onTap: () { Navigator.of(context).pop(); onOk(); }, ), ), const SizedBox(width: 5), Expanded( child: buildButton( title: noLabel, bg: AppColors.secondaryColor, border: AppColors.secondaryColor, onTap: () => Navigator.of(context).pop(), ), ), ], ) else buildButton( title: yesLabel, bg: AppNewColors.primaryBtnColor, border: AppNewColors.primaryBtnColor, onTap: () { Navigator.of(context).pop(); onOk(); }, ), ], ), ), ); } }