144 lines
4.4 KiB
Dart
144 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:kmobile/l10n/app_localizations.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
// Data model for a single Quick Link item
|
|
class QuickLink {
|
|
final String title;
|
|
final String url;
|
|
final IconData icon;
|
|
|
|
QuickLink({required this.title, required this.url, required this.icon});
|
|
}
|
|
|
|
class QuickLinksScreen extends StatefulWidget {
|
|
const QuickLinksScreen({super.key});
|
|
|
|
@override
|
|
State<QuickLinksScreen> createState() => _QuickLinksScreenState();
|
|
}
|
|
|
|
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,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |