import 'package:prosapp_web_app/providers/settings_provider.dart'; import 'package:prosapp_web_app/ui/cards/white_card.dart'; import 'package:flutter/material.dart'; import 'package:prosapp_web_app/ui/labels/custom_labels.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; class SupportView extends StatelessWidget { const SupportView({super.key}); Future _launchURL(String url) async { final Uri _url = Uri.parse(url); if (await canLaunchUrl(_url)) { await launchUrl( _url, mode: LaunchMode.externalApplication, webOnlyWindowName: '_blank', // Para abrir en una nueva pestaña en web ); } else { throw 'No se pudo abrir la URL $url'; } } Future _goWhatssApp(String number) async { final url = 'https://api.whatsapp.com/send?phone=$number&text=Hola%21+soy+usuario+de+Prosapp+y+quisiera+conocer+mas+sobre+esta+app+%F0%9F%98%81'; await _launchURL(url); } Future _goEmail(String email) async { final url = 'mailto:$email?subject=${Uri.encodeComponent(email)}'; await _launchURL(url); } Future _goSugerencias() async { const url = 'https://admin.prosapp.co/sugerencias'; await _launchURL(url); } Future _goPoliticas(String urlText) async { final url = urlText; await _launchURL(url); } Future _goTerminos(String urlText) async { final url = urlText; await _launchURL(url); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return Consumer( builder: (context, settingsProvider, child) { if (settingsProvider.isLoading) { return const Center(child: CircularProgressIndicator()); } final settings = settingsProvider.settings!; return ListView( physics: const ClampingScrollPhysics(), children: [ const SizedBox(height: 10), Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 800), child: WhiteCard( child: Column( children: [ Padding( padding: const EdgeInsets.only(top: 10, bottom: 30), child: Center( child: Text( settings.tituloSoporte, style: TextStyle( fontSize: size.width > 500 ? 30 : 20, fontWeight: FontWeight.w600, ), textAlign: TextAlign.center, ), ), ), Padding( padding: EdgeInsets.only( left: size.width > 500 ? 30 : 0, right: size.width > 500 ? 30 : 0, bottom: 30, ), child: Text( settings.parrafoSoporte, style: CustomLabels.h3, textAlign: TextAlign.center, ), ), Center( child: Column( children: [ const Text( 'Horario de atención:', style: TextStyle( fontSize: 28, fontWeight: FontWeight.w400, ), ), const SizedBox(height: 10), Text(settings.diasSoporte, style: CustomLabels.h3), Text(settings.horasSoporte, style: CustomLabels.h3), ], ), ), const SizedBox(height: 30), Padding( padding: EdgeInsets.only( left: size.width > 500 ? 30 : 0, right: size.width > 500 ? 30 : 0, bottom: 30, ), child: Wrap( alignment: WrapAlignment.center, spacing: 15, runSpacing: 15, children: [ _buildGridButton( context, icon: Icons.phone, text: 'WhatsApp', onPressed: () => _goWhatssApp(settings.numeroSoporte), ), _buildGridButton( context, icon: Icons.email, text: 'Email', onPressed: () => _goEmail(settings.emailSoporte), ), _buildGridButton( context, icon: Icons.feedback, text: 'Sugerencias', onPressed: _goSugerencias, ), _buildGridButton( context, icon: Icons.privacy_tip, text: 'Políticas de Privacidad', onPressed: () => _goPoliticas(settings.politicasPrivacidad), ), _buildGridButton( context, icon: Icons.article, text: 'Términos y Condiciones', onPressed: () => _goTerminos(settings.terminosCondiciones), ), ], ), ), ], ), ), ), ), ], ); }, ); } Widget _buildGridButton( BuildContext context, { required IconData icon, required String text, required VoidCallback onPressed, }) { return MouseRegion( cursor: SystemMouseCursors.click, child: GestureDetector( onTap: onPressed, child: Container( height: 110, width: 180, decoration: BoxDecoration( color: Colors.blue[600], borderRadius: BorderRadius.circular(10), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(icon, size: 40, color: Colors.white), const SizedBox(height: 10), Center( child: Text( textAlign: TextAlign.center, text, style: const TextStyle( color: Colors.white, fontSize: 18, ), ), ), ], ), ), ), ); } }