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,50 +1,144 @@
import 'package:flutter/material.dart';
import 'package:kmobile/l10n/app_localizations.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/l10n/app_localizations.dart';
import 'package:url_launcher/url_launcher.dart';
class QuickLinksScreen extends StatefulWidget {
const QuickLinksScreen({super.key});
// Data model for a single Quick Link item
class QuickLink {
final String title;
final String url;
final IconData icon;
@override
State<QuickLinksScreen> createState() => _QuickLinksScreenState();
}
QuickLink({required this.title, required this.url, required this.icon});
}
class _QuickLinksScreenState extends State<QuickLinksScreen> {
@override
void initState() {
super.initState();
_getQuickLinks();
}
class QuickLinksScreen extends StatefulWidget {
const QuickLinksScreen({super.key});
// A placeholder for your future API call
Future<void> _getQuickLinks() async {
// TODO: Implement API call to fetch quick links data
// For now, simulating a network call with a delay
await Future.delayed(const Duration(seconds: 1));
// In a real implementation, you would process the API response here
}
@override
State<QuickLinksScreen> createState() => _QuickLinksScreenState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).quickLinks),
),
body: Stack(
children: [
IgnorePointer(
child: Center(
child: Opacity(
opacity: 0.1, // Low opacity
child: Image.asset(
'assets/images/logo.png',
width: 200, // Adjust size as needed
height: 200, // Adjust size as needed
),
),
),
),
],
),
);
}
}
class _QuickLinksScreenState extends State<QuickLinksScreen> {
// List of Quick Links
final List<QuickLink> _quickLinks = [
QuickLink(
title: "National Bank of Agriculture & Rural Development",
url: "http://www.nabard.org/",
icon: Icons.account_balance),
QuickLink(
title: "Reserve Bank of India",
url: "http://www.rbi.org.in/home.aspx",
icon: Icons.account_balance_wallet),
QuickLink(
title: "Indian Institute of Banking & Finance",
url: "http://www.iibf.org.in/",
icon: Icons.school),
QuickLink(
title: "Indian Bank Association",
url: "http://www.iba.org.in/",
icon: Icons.group_work),
QuickLink(
title: "Ministry of Finance",
url: "http://www.finmin.nic.in/",
icon: Icons.business),
QuickLink(
title: "Securities Exchange Board of India",
url: "http://www.sebi.gov.in/",
icon: Icons.show_chart),
QuickLink(
title: "Insurance Regulatory & Development Authority",
url: "https://www.irdai.gov.in/",
icon: Icons.shield_outlined),
];
// Function to launch a URL
Future<void> _launchURL(String url, BuildContext context) async {
final Uri uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri, mode: LaunchMode.externalApplication);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Could not launch $url')),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).quickLinks),
),
body: Stack(
children: [
// Background logo
IgnorePointer(
child: Center(
child: Opacity(
opacity: 0.1,
child: Image.asset(
'assets/images/logo.png',
width: 200,
height: 200,
),
),
),
),
// Grid of Quick Links
GridView.builder(
padding: const EdgeInsets.all(12.0),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, // Two columns
crossAxisSpacing: 12.0,
mainAxisSpacing: 12.0,
childAspectRatio: 1.1, // Adjust for better card shape
),
itemCount: _quickLinks.length,
itemBuilder: (context, index) {
final link = _quickLinks[index];
return _buildLinkCard(link, context);
},
),
],
),
);
}
Widget _buildLinkCard(QuickLink link, BuildContext context) {
return Card(
elevation: 3.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
child: InkWell(
onTap: () => _launchURL(link.url, context),
borderRadius: BorderRadius.circular(15.0),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
link.icon,
size: 40.0,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(height: 12.0),
Text(
link.title,
textAlign: TextAlign.center,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 14.0,
),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
],
),
),
),
);
}
}