import 'package:wanisclient/utils/colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_lucide/flutter_lucide.dart'; import '../../../widgets/custom_button.dart'; class PhoneNumberErrorDialog extends StatelessWidget { final String title; final String btTitle; final String message; final IconData icon; final VoidCallback? onBackToLogin; const PhoneNumberErrorDialog({ Key? key, required this.title, required this.icon, required this.message, required this.btTitle, this.onBackToLogin, }) : super(key: key); @override Widget build(BuildContext context) { return Dialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), ), backgroundColor: Colors.white, child: Container( padding: const EdgeInsets.all(24), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), ), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Error Icon Icon( icon, color: Colors.red, size: 100, ), const SizedBox(height: 20), // Title Text( title, style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black, ), textAlign: TextAlign.center, ), const SizedBox(height: 12), // Message Text( message, style: TextStyle( fontSize: 14, color: Colors.grey.shade600, height: 1.4, ), textAlign: TextAlign.center, ), const SizedBox(height: 24), CustomButton( onClick: () { Navigator.of(context).pop(); onBackToLogin?.call(); }, width: double.infinity, height: 50, fontSize: 16, borderRadius: 10, title: btTitle, backgroundColor: AppNewColors.primaryColor, borderColor: AppNewColors.primaryColor, txtColor: AppNewColors.white, ), ], ), ), ); } } // Helper method to show the dialog class AppDialog { static Future showPhoneNumberError( BuildContext context, { required String title, required String message, required IconData icon, required String btTitle, VoidCallback? onBackToLogin, }) async { return showDialog( context: context, barrierDismissible: false, // Prevents closing by tapping outside builder: (BuildContext context) { return PhoneNumberErrorDialog( title: title, message: message, icon: icon, btTitle: btTitle, onBackToLogin: onBackToLogin, ); }, ); } } // Usage examples: // For phone number already exists error: /* AppDialog.showPhoneNumberError( context, title: "Number used before", message: "Please enter a new mobile number with the country code.", icon: Icons.close, // or LucideIcons.x btTitle: "Back to login", onBackToLogin: () { // Navigate back to login Navigator.pushReplacementNamed(context, '/login'); }, ); */ // For success message: /* AppDialog.showPhoneNumberError( context, title: "Success!", message: "Your account has been created successfully.", icon: Icons.check_circle, // or LucideIcons.check_circle btTitle: "Continue", onBackToLogin: () { // Navigate to next screen Navigator.pushReplacementNamed(context, '/dashboard'); }, ); */ // For warning message: /* AppDialog.showPhoneNumberError( context, title: "Warning", message: "Please check your internet connection and try again.", icon: Icons.warning, // or LucideIcons.alert_triangle btTitle: "Retry", onBackToLogin: () { // Retry action _retryFunction(); }, ); */