import 'package:wanisclient/utils/colors.dart'; import 'package:wanisclient/widgets/custom_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../config/AppSnackbar.dart'; import '../config/constants/arabe.dart' as Language; import '../config/custom_text.dart'; import '../providers/language_provider.dart'; import 'ContactUsScreen.dart'; class Support extends StatefulWidget { final bool? withBack; const Support({super.key, this.withBack}); @override State createState() => _SupportState(); } class _SupportState extends State { @override Widget build(BuildContext context) { final languageProvider = context.watch(); bool isArabic = languageProvider.currentLangCode == Language.ar; return Scaffold( backgroundColor: Colors.white, body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ widget.withBack !=null && widget.withBack==true ?const SizedBox(height: 20):const SizedBox(height: 150), if(widget.withBack !=null && widget.withBack==true) Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ GestureDetector( onTap: () { Navigator.pop(context); }, child: Container( width: 32, height: 32, margin: const EdgeInsets.symmetric(vertical: 12), decoration: BoxDecoration( color: AppNewColors.lightgray, borderRadius: BorderRadius.circular(16), boxShadow: [ BoxShadow( color: AppNewColors.black.withOpacity(.1), blurRadius: 1, offset: const Offset(2, 1), ), ], ), child: const Icon( Icons.arrow_back, color: AppNewColors.black, size: 16, ), ), ), Expanded( child: Center( child: Txt( text: 'Customer Service', style: TextStyle( color: AppNewColors.titleTextColor, fontSize: 18, fontFamily: isArabic ? "Readex_Pro" : 'Inter', fontWeight: FontWeight.w600, height: 1.23, ), ), ), ), const SizedBox(width: 32), ], ), ), SvgPicture.asset( "assets/icons/wanislogoweb.svg", color: AppNewColors.primaryBtnColor, width: 80, ), const SizedBox(height: 20), const Txt( text: "Welcome to Support!", style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const SizedBox(height: 10), const Txt( text: "How would you like to contact us?", style: TextStyle(fontSize: 16), textAlign: TextAlign.center, ), const SizedBox(height: 30), // ElevatedButton.icon( // onPressed: _openEmailScreen, // icon: const Icon(Icons.email), // label: const Text("Contact via Email"), // style: ElevatedButton.styleFrom( // minimumSize: const Size(double.infinity, 50), // ), // ), CustomButton( onClick: () => _openEmailScreen(context), width: MediaQuery.of(context).size.width * .6, fontSize: 15, height: 40, borderRadius: 25, txtColor: AppColors.secondaryColor, title: isArabic ? 'البريد الإلكتروني' : "Email", backgroundColor: AppColors.white, borderColor: AppColors.secondaryColor, //isloading: isCancelling, loadercolor: AppColors.secondaryColor, ), /* Padding( padding: const EdgeInsets.fromLTRB(24, 5, 24, 5), child: ElevatedButton( onPressed: () => _openEmailScreen(context), style: ElevatedButton.styleFrom(backgroundColor: AppColors.secondaryColor), child: const Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Icon(Icons.email,size: 30, color: Colors.white), Txt( text: "Email", style: TextStyle( color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold), ), ], ), ), ),*/ const SizedBox(height: 16), SizedBox( child: CustomButton( onClick: () => _showContactOptions(context, "+216 20000000"), width: MediaQuery.of(context).size.width * .6, fontSize: 15, height: 40, borderRadius: 25, txtColor: AppColors.greanColor, title: isArabic ? 'الهاتف' : "Phone", backgroundColor: AppColors.white, borderColor: AppColors.greanColor, //isloading: isCancelling, loadercolor: AppColors.greanColor, ), ), /*Padding( padding: const EdgeInsets.fromLTRB(24, 5, 24, 5), child: ElevatedButton( onPressed: () => _showContactOptions(context, "+216 28871944"), style: ElevatedButton.styleFrom(backgroundColor: AppColors.greanColor), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ //Icon(Icons.phone, color: Colors.green), SvgPicture.asset( 'assets/images/icons8-whatsapp.svg', width: 25, color: Colors.white, ), const Txt( text: "Call", style: TextStyle( color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold), ), ], ), ), ),*/ ], ), ), ); } void _openEmailScreen(BuildContext context) { showModalBottomSheet( context: context, isScrollControlled: true, backgroundColor: Colors.transparent, builder: (ctx) { return Container( height: MediaQuery.of(context).size.height * 0.6, decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(24), topRight: Radius.circular(24), ), ), child: const ContactUsScreen(), ); }, ); } void _showContactOptions(BuildContext context, String number) { showModalBottomSheet( context: context, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20)), ), builder: (ctx) { return Container( height: 200, padding: const EdgeInsets.symmetric(vertical: 8), child: Column( children: [ ListTile( leading: const Icon(Icons.phone, color: Colors.green), title: const Txt( text: "Call", style: TextStyle(), ), 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"); } }, ), ListTile( leading: SvgPicture.asset( 'assets/images/icons8-whatsapp.svg', width: 25, color: Colors.green, ), title: const Txt( text: "Open in WhatsApp", style: TextStyle(), ), onTap: () async { Navigator.pop(ctx); String formattedNumber = number.replaceAll(RegExp(r'\D'), ''); if (formattedNumber.isEmpty || formattedNumber.length < 8) { AppSnackbar.showError("Error", "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"); } }, ), ], ), ); }, ); } }