View All Created
This commit is contained in:
141
lib/features/accounts/screens/all_accounts_screen.dart
Normal file
141
lib/features/accounts/screens/all_accounts_screen.dart
Normal file
@@ -0,0 +1,141 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/models/user.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
class AllAccountsScreen extends StatefulWidget {
|
||||
final List<User> users;
|
||||
const AllAccountsScreen({super.key, required this.users});
|
||||
|
||||
@override
|
||||
State<AllAccountsScreen> createState() => _AllAccountsScreenState();
|
||||
}
|
||||
|
||||
class _AllAccountsScreenState extends State<AllAccountsScreen> {
|
||||
final Map<String, bool> _visibilityMap = {};
|
||||
|
||||
String getFullAccountType(BuildContext context, String? accountType) {
|
||||
// This is duplicated from dashboard_screen.dart.
|
||||
// In a real app, this should be moved to a utility/helper class.
|
||||
if (accountType == null || accountType.isEmpty) return 'N/A';
|
||||
switch (accountType.toLowerCase()) {
|
||||
case 'sa':
|
||||
return "Savings Account"; // Using hardcoded strings for simplicity
|
||||
case 'sb':
|
||||
return "Savings Account";
|
||||
case 'ln':
|
||||
return "Loan Account";
|
||||
case 'td':
|
||||
return "Term Deposit";
|
||||
case 'rd':
|
||||
return "Recurring Deposit";
|
||||
case 'ca':
|
||||
return "Current Account";
|
||||
default:
|
||||
return "Unknown Account";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('All Accounts'),
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: widget.users.length,
|
||||
itemBuilder: (context, index) {
|
||||
final user = widget.users[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: _buildAccountCard(user),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAccountCard(User user) {
|
||||
final theme = Theme.of(context);
|
||||
final accountNo = user.accountNo ?? '';
|
||||
final isVisible = _visibilityMap[accountNo] ?? false;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF01A04C),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Top section: Account Type and Number
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
getFullAccountType(context, user.accountType),
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
user.accountNo ?? 'N/A',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Bottom section: Balance and Toggle
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"₹ ",
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
isVisible ? user.currentBalance ?? '0.00' : '*****',
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_visibilityMap[accountNo] = !isVisible;
|
||||
});
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Icon(
|
||||
isVisible ? Symbols.visibility_lock : Symbols.visibility,
|
||||
color: theme.scaffoldBackgroundColor,
|
||||
weight: 800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user