import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../../l10n/app_localizations.dart'; class EnquiryScreen extends StatefulWidget { const EnquiryScreen({super.key}); @override State createState() => _EnquiryScreen(); } class _EnquiryScreen extends State { // Updated to launch externally and pre-fill the subject Future _launchEmailAddress(String email) async { final Uri emailUri = Uri( scheme: 'mailto', path: email, query: 'subject=Enquiry', // Pre-fills the subject line ); if (await canLaunchUrl(emailUri)) { // Use external application mode await launchUrl(emailUri, mode: LaunchMode.externalApplication); } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Could not open email app for $email')), ); } } // Updated with better error handling Future _launchPhoneNumber(String phone) async { final Uri phoneUri = Uri(scheme: 'tel', path: phone); if (await canLaunchUrl(phoneUri)) { await launchUrl(phoneUri); } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Could not open dialer for $phone')), ); } } // Updated to launch externally Future _launchUrl(String url) async { final Uri uri = Uri.parse(url); if (await canLaunchUrl(uri)) { // Use external application mode await launchUrl(uri, mode: LaunchMode.externalApplication); } else { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Could not launch $url')), ); } } Widget _buildContactItem(String role, String email, String phone) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(role, style: TextStyle(color: Theme.of(context).colorScheme.onSurface)), const SizedBox(height: 4), GestureDetector( onTap: () => _launchEmailAddress(email), child: Text(email, style: TextStyle(color: Theme.of(context).colorScheme.primary)), ), const SizedBox(height: 4), GestureDetector( onTap: () => _launchPhoneNumber(phone), child: Text(phone, style: TextStyle( color: Theme.of(context) .colorScheme .primary)), // Changed color for visibility ), ], ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(AppLocalizations.of(context).enquiry), centerTitle: false, ), body: Stack( children: [ Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 20), GestureDetector( onTap: () => _launchUrl("https://kccbhp.bank.in/complaint-form/"), child: Row(mainAxisSize: MainAxisSize.min, children: [ Text( "Complaint Form", style: TextStyle( fontSize: 17, color: Theme.of(context).colorScheme.primary, decoration: TextDecoration .underline, // Added underline for link clarity decorationColor: Theme.of(context).colorScheme.primary, ), ), const SizedBox(width: 4), Icon( Icons.open_in_new, color: Theme.of(context).colorScheme.primary, size: 16.0, ), ])), const SizedBox(height: 40), Text( AppLocalizations.of(context).keyContacts, style: TextStyle( fontSize: 17, color: Theme.of(context).colorScheme.primary, ), // horizontal line ), Divider(color: Theme.of(context).colorScheme.outline), const SizedBox(height: 16), _buildContactItem( AppLocalizations.of(context).chairman, "chairman@kccb.in", "01892-222677", ), const SizedBox(height: 16), _buildContactItem( AppLocalizations.of(context).managingDirector, "md@kccb.in", "01892-224969", ), const SizedBox(height: 16), _buildContactItem( AppLocalizations.of(context).gmWest, "gmw@kccb.in", "01892-223280", ), const SizedBox(height: 16), _buildContactItem( AppLocalizations.of(context).gmNorth, "gmn@kccb.in", "01892-224607", ), ], ), ), IgnorePointer( child: Center( child: Opacity( opacity: 0.07, // Reduced opacity child: ClipOval( child: Image.asset( 'assets/images/logo.png', width: 200, // Adjust size as needed height: 200, // Adjust size as needed ), ), ), ), ), ], ), ); } }