Quick Links added

This commit is contained in:
2025-11-14 15:24:02 +05:30
parent 3135116f26
commit 43d92d799b
4 changed files with 257 additions and 88 deletions

View File

@@ -1,5 +1,3 @@
// ignore_for_file: use_build_context_synchronously
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../../l10n/app_localizations.dart';
@@ -12,31 +10,45 @@ class EnquiryScreen extends StatefulWidget {
}
class _EnquiryScreen extends State<EnquiryScreen> {
// Updated to launch externally and pre-fill the subject
Future<void> _launchEmailAddress(String email) async {
final Uri emailUri = Uri(scheme: 'mailto', path: email);
final Uri emailUri = Uri(
scheme: 'mailto',
path: email,
query: 'subject=Enquiry', // Pre-fills the subject line
);
if (await canLaunchUrl(emailUri)) {
await launchUrl(emailUri);
// Use external application mode
await launchUrl(emailUri, mode: LaunchMode.externalApplication);
} else {
debugPrint('${AppLocalizations.of(context).emailLaunchError} $email');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Could not open email app for $email')),
);
}
}
// Updated with better error handling
Future<void> _launchPhoneNumber(String phone) async {
final Uri phoneUri = Uri(scheme: 'tel', path: phone);
if (await canLaunchUrl(phoneUri)) {
await launchUrl(phoneUri);
} else {
debugPrint('${AppLocalizations.of(context).dialerLaunchError} $phone');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Could not open dialer for $phone')),
);
}
}
// Updated to launch externally
Future<void> _launchUrl(String url) async {
final Uri uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri);
// Use external application mode
await launchUrl(uri, mode: LaunchMode.externalApplication);
} else {
// Consider adding a 'urlLaunchError' key to your AppLocalizations
debugPrint('Could not launch $url');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Could not launch $url')),
);
}
}
@@ -57,7 +69,7 @@ class _EnquiryScreen extends State<EnquiryScreen> {
onTap: () => _launchPhoneNumber(phone),
child: Text(phone,
style:
TextStyle(color: Theme.of(context).scaffoldBackgroundColor)),
TextStyle(color: Theme.of(context).colorScheme.primary)), // Changed color for visibility
),
],
);
@@ -79,13 +91,14 @@ class _EnquiryScreen extends State<EnquiryScreen> {
children: [
const SizedBox(height: 20),
GestureDetector(
onTap: () => _launchUrl("https://kccb.in/complaint-form"),
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,
),
@@ -150,4 +163,4 @@ class _EnquiryScreen extends State<EnquiryScreen> {
),
);
}
}
}