import 'package:flutter/material.dart'; import 'package:flutter_lucide/flutter_lucide.dart'; import 'package:marco/helpers/widgets/my_text.dart'; import 'package:marco/helpers/widgets/my_spacing.dart'; import 'package:marco/helpers/utils/mixins/ui_mixin.dart'; import 'package:url_launcher/url_launcher.dart'; class SupportScreen extends StatefulWidget { const SupportScreen({super.key}); @override State createState() => _SupportScreenState(); } class _SupportScreenState extends State with UIMixin { final List> contacts = [ { "type": "email", "label": "info@marcoaiot.com", "subLabel": "Email us your queries", "icon": LucideIcons.mail, "action": "mailto:info@marcoaiot.com?subject=Support Request" }, { "type": "phone", "label": "+91-8055099750", "subLabel": "Call our support team", "icon": LucideIcons.phone, "action": "tel:+91-8055099750" }, ]; void _launchAction(String action) async { final Uri uri = Uri.parse(action); if (await canLaunchUrl(uri)) { // Use LaunchMode.externalApplication for mailto/tel await launchUrl( uri, mode: LaunchMode.externalApplication, ); } else { // Fallback if no app found ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('No app found to open this link.')), ); } } Widget _buildAppBar() { return AppBar( backgroundColor: const Color(0xFFF5F5F5), elevation: 0.5, automaticallyImplyLeading: false, titleSpacing: 0, title: Padding( padding: MySpacing.xy(16, 0), child: Row( children: [ IconButton( icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black, size: 20), onPressed: () => Navigator.pop(context), ), MySpacing.width(8), Expanded( child: MyText.titleLarge('Support', fontWeight: 700, color: Colors.black), ), ], ), ), ); } Widget _buildContactCard(Map contact) { return GestureDetector( onTap: () => _launchAction(contact["action"]), child: Container( padding: const EdgeInsets.all(20), margin: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5), boxShadow: const [ BoxShadow( color: Colors.black12, blurRadius: 12, offset: Offset(0, 6), ), ], ), child: Row( children: [ Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.red.withOpacity(0.1), shape: BoxShape.circle, ), child: Icon(contact["icon"], color: Colors.red, size: 24), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ MyText.bodyMedium( contact["label"], fontWeight: 700, color: Colors.black87, fontSize: 16, ), const SizedBox(height: 4), MyText.bodySmall( contact["subLabel"], color: Colors.black54, ), ], ), ), ], ), ), ); } Widget _buildInfoCard(String title, String subtitle, IconData icon) { return Container( padding: const EdgeInsets.all(20), margin: const EdgeInsets.symmetric(horizontal: 24, vertical: 8), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5), boxShadow: const [ BoxShadow( color: Colors.black12, blurRadius: 12, offset: Offset(0, 6), ), ], ), child: Row( children: [ Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.red.withOpacity(0.1), shape: BoxShape.circle, ), child: Icon(icon, color: Colors.red, size: 28), ), const SizedBox(width: 16), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ MyText.bodyMedium(title, fontWeight: 700, color: Colors.black87, fontSize: 16), const SizedBox(height: 4), MyText.bodySmall(subtitle, color: Colors.black54), ], ), ), ], ), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(72), child: _buildAppBar(), ), body: SafeArea( child: RefreshIndicator( onRefresh: () async { // Optional: Implement refresh logic }, child: SingleChildScrollView( physics: const AlwaysScrollableScrollPhysics(), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ MySpacing.height(24), Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: MyText.titleLarge( "Need Help?", fontWeight: 700, color: Colors.red, ), ), const SizedBox(height: 8), Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: MyText.bodySmall( "Our support team is ready to assist you. Reach out via email or phone.", color: Colors.grey[800], ), ), const SizedBox(height: 24), // Contact cards ...contacts.map((contact) => _buildContactCard(contact)), const SizedBox(height: 16), // Info card _buildInfoCard( "Working Hours", "Monday - Friday: 9 AM - 6 PM\nSaturday: 10 AM - 2 PM", LucideIcons.clock, ), const SizedBox(height: 24), ], ), ), ), ), ); } }