import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:url_launcher/url_launcher.dart'; import '../config/AppSnackbar.dart'; import '../utils/colors.dart'; import 'custom_text.dart'; void showContactOptions(BuildContext context, String number) { final isDarkMode = Theme.of(context).brightness == Brightness.dark; showModalBottomSheet( context: context, backgroundColor: Colors.transparent, builder: (ctx) { return Container( decoration: BoxDecoration( color: isDarkMode ? AppColors.blackBackgroundColor : Colors.white, borderRadius: const BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30), ), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 16), child: Column( mainAxisSize: MainAxisSize.min, children: [ // Drag handle Container( width: 40, height: 4, decoration: BoxDecoration( color: Colors.grey.shade300, borderRadius: BorderRadius.circular(2), ), ), const SizedBox(height: 20), // Title Txt( text: "Contact Options", style: TextStyle( fontSize: 20, fontWeight: FontWeight.w700, fontFamily: 'Poppins', color: isDarkMode ? AppColors.white : AppColors.black, ), ), const SizedBox(height: 20), // Call Option InkWell( onTap: () async { Navigator.pop(ctx); final Uri phoneUri = Uri.parse("tel:$number"); if (await canLaunchUrl(phoneUri)) { await launchUrl(phoneUri); } else { AppSnackbar.showError("Error", "Cannot make a call"); } }, borderRadius: BorderRadius.circular(15), child: Container( padding: const EdgeInsets.symmetric( vertical: 16, horizontal: 20), decoration: BoxDecoration( color: isDarkMode ? Colors.grey.shade800 : Colors.grey.shade50, borderRadius: BorderRadius.circular(15), border: Border.all( color: isDarkMode ? Colors.grey.shade700 : Colors.grey.shade200, width: 1, ), ), child: Row( children: [ Container( width: 45, height: 45, decoration: BoxDecoration( color: Colors.green.withOpacity(0.1), borderRadius: BorderRadius.circular(12), ), child: const Icon( Icons.phone, color: Colors.green, size: 24, ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Txt( text: "Call", style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, fontFamily: 'Poppins', color: isDarkMode ? AppColors.white : AppColors.black, ), ), const SizedBox(height: 2), Txt( text: number, style: TextStyle( fontSize: 13, fontFamily: 'Poppins', color: isDarkMode ? AppColors.darkSecondaryText : Colors.grey.shade600, ), ), ], ), ), Icon( Icons.arrow_forward_ios, size: 16, color: isDarkMode ? AppColors.darkSecondaryText : Colors.grey.shade400, ), ], ), ), ), const SizedBox(height: 12), // WhatsApp Option InkWell( onTap: () async { Navigator.pop(ctx); String formattedNumber = number.replaceAll(RegExp(r'\D'), ''); if (!formattedNumber.startsWith('+')) { formattedNumber = '+$formattedNumber'; } if (formattedNumber.isEmpty || formattedNumber.length < 8) { AppSnackbar.showError( "Invalid number", "Phone number is too short"); return; } final Uri whatsappUri = Uri.parse("https://wa.me/$formattedNumber"); if (await canLaunchUrl(whatsappUri)) { await launchUrl(whatsappUri, mode: LaunchMode.externalApplication); } else { AppSnackbar.showError("Error", "Cannot open WhatsApp"); } }, borderRadius: BorderRadius.circular(15), child: Container( padding: const EdgeInsets.symmetric( vertical: 16, horizontal: 20), decoration: BoxDecoration( color: isDarkMode ? Colors.grey.shade800 : Colors.grey.shade50, borderRadius: BorderRadius.circular(15), border: Border.all( color: isDarkMode ? Colors.grey.shade700 : Colors.grey.shade200, width: 1, ), ), child: Row( children: [ Container( width: 45, height: 45, decoration: BoxDecoration( color: Colors.green.withOpacity(0.1), borderRadius: BorderRadius.circular(12), ), child: Center( child: SvgPicture.asset( 'assets/images/icons8-whatsapp.svg', width: 26, color: Colors.green, ), ), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Txt( text: "Open in WhatsApp", style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, fontFamily: 'Poppins', color: isDarkMode ? AppColors.white : AppColors.black, ), ), const SizedBox(height: 2), Txt( text: "Chat with us on WhatsApp", style: TextStyle( fontSize: 13, fontFamily: 'Poppins', color: isDarkMode ? AppColors.darkSecondaryText : Colors.grey.shade600, ), ), ], ), ), Icon( Icons.arrow_forward_ios, size: 16, color: isDarkMode ? AppColors.darkSecondaryText : Colors.grey.shade400, ), ], ), ), ), const SizedBox(height: 20), ], ), ), ); }, ); }