kmobile/lib/features/dashboard/screens/dashboard_screen.dart

173 lines
7.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:kmobile/features/accounts/screens/account_info_screen.dart';
import 'package:kmobile/features/accounts/screens/account_statement_screen.dart';
import 'package:kmobile/features/customer_info/screens/customer_info_screen.dart';
import 'package:kmobile/features/beneficiaries/screens/manage_beneficiaries_screen.dart';
import 'package:material_symbols_icons/material_symbols_icons.dart';
class DashboardScreen extends StatefulWidget {
const DashboardScreen({super.key});
@override
State<DashboardScreen> createState() => _DashboardScreenState();
}
class _DashboardScreenState extends State<DashboardScreen> {
// Mock data for transactions
final List<Map<String, String>> transactions = [
{'name': 'Raj Kumar', 'amount': '₹1,000', 'date': '09 March, 2025 16:04', 'type': 'in'},
{'name': 'Sunita Joshi', 'amount': '₹1,45,000', 'date': '07 March, 2025 16:04', 'type': 'out'},
{'name': 'Manoj Singh', 'amount': '₹2,400', 'date': '07 March, 2025 16:04', 'type': 'in'},
{'name': 'Raj Kumar', 'amount': '₹11,500', 'date': '09 March, 2025 16:04', 'type': 'in'},
{'name': 'Manoj Singh', 'amount': '₹1,000', 'date': '', 'type': 'in'},
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text('kMobile', style: TextStyle(color: Colors.blueAccent,
fontWeight: FontWeight.w500),),
actions: [
// IconButton(
// icon: const Icon(Icons.notifications_outlined),
// onPressed: () {
// // Navigate to notifications
// },
// ),
Padding(
padding: const EdgeInsets.only(right: 10.0),
child: InkWell(
borderRadius: BorderRadius.circular(20),
onTap: (){
// Navigator.push(context, MaterialPageRoute(
// builder: (context) => const CustomerInfoScreen()));
},
child: const CircleAvatar(
backgroundImage: AssetImage('assets/images/avatar.jpg'), // Replace with your image
radius: 20,
),
),
),
],
),
body: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 16),
// Account Info Card
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.blue[700],
borderRadius: BorderRadius.circular(16),
),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text("Account Number: ", style:
TextStyle(color: Colors.white, fontSize: 12)),
Text("03000156789462302", style:
TextStyle(color: Colors.white, fontSize: 14)),
Padding(
padding: EdgeInsets.only(left: 5.0),
child: Icon(Symbols.keyboard_arrow_down, color: Colors.white),
),
],
),
SizedBox(height: 15),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("₹ *****", style: TextStyle(color: Colors.white,
fontSize: 24, fontWeight: FontWeight.w700)),
Icon(Symbols.visibility_lock, color: Colors.white),
],
),
SizedBox(height: 20),
],
),
),
const SizedBox(height: 18),
const Text('Quick Links', style: TextStyle(fontSize: 15),),
const SizedBox(height: 16),
// Quick Links
GridView.count(
crossAxisCount: 4,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
children: [
_buildQuickLink(Symbols.id_card, "Customer \n Info", () {
Navigator.push(context, MaterialPageRoute(
builder: (context) => const CustomerInfoScreen()));;
}),
_buildQuickLink(Symbols.currency_rupee, "Quick \n Pay",
() => print("")),
_buildQuickLink(Symbols.send_money, "Fund \n Transfer",
() => print("")),
_buildQuickLink(Symbols.server_person, "Account \n Info",
(){
Navigator.push(context, MaterialPageRoute(
builder: (context) => const AccountInfoScreen()));
}),
_buildQuickLink(Symbols.receipt_long, "Account \n History",
() {
Navigator.push(context, MaterialPageRoute(
builder: (context) => const AccountStatementScreen()));
}),
_buildQuickLink(Symbols.checkbook, "Handle \n Cheque",
() => print("")),
_buildQuickLink(Icons.group, "Manage \n Beneficiary",
() {
Navigator.push(context, MaterialPageRoute(
builder: (context) => const ManageBeneficiariesScreen()));
}),
_buildQuickLink(Symbols.support_agent, "Contact \n Us",
() => print("")),
],
),
const SizedBox(height: 10),
// Recent Transactions
const Align(
alignment: Alignment.centerLeft,
child: Text("Recent Transactions", style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
),
...transactions.map((tx) => ListTile(
leading: Icon(tx['type'] == 'in' ? Symbols.call_received : Symbols.call_made, color: tx['type'] == 'in' ? Colors.green : Colors.red),
title: Text(tx['name']!),
subtitle: Text(tx['date']!),
trailing: Text(tx['amount']!),
)),
],
),
),
),
);
}
Widget _buildQuickLink(IconData icon, String label, VoidCallback onTap) {
return InkWell(
onTap: onTap,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 30, color: Colors.blue[700]),
const SizedBox(height: 4),
Text(label, textAlign: TextAlign.center, style: const TextStyle(fontSize: 12)),
],
),
);
}
}