This commit is contained in:
2025-11-25 12:51:29 +05:30
parent 18db360a45
commit 3358ec7669
6 changed files with 292 additions and 105 deletions

View File

@@ -319,11 +319,9 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
builder: (context, state) { builder: (context, state) {
if (state is Authenticated) { if (state is Authenticated) {
if (state.users.isNotEmpty) { if (state.users.isNotEmpty) {
final user = state.users.first;
return AccountStatementScreen( return AccountStatementScreen(
accountNo: user.accountNo ?? '', users: state.users,
balance: user.availableBalance ?? '0.00', selectedIndex: 0,
accountType: user.accountType ?? '',
); );
} else { } else {
return const Center(child: Text("No accounts found.")); return const Center(child: Text("No accounts found."));

View File

@@ -74,9 +74,9 @@ Dio _createDioClient() {
final dio = Dio( final dio = Dio(
BaseOptions( BaseOptions(
baseUrl: baseUrl:
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080', //test // 'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080', //test
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod //'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
//'https://kccbmbnk.net', //prod small 'https://kccbmbnk.net', //prod small
connectTimeout: const Duration(seconds: 60), connectTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 60), receiveTimeout: const Duration(seconds: 60),
headers: { headers: {

View File

@@ -17,99 +17,279 @@ class AccountInfoScreen extends StatefulWidget {
} }
class _AccountInfoScreen extends State<AccountInfoScreen> { class _AccountInfoScreen extends State<AccountInfoScreen> {
late User selectedUser; late User selectedUser;
@override
void initState() {
super.initState();
selectedUser = widget.users[widget.selectedIndex];
}
@override @override
void initState() {
super.initState();
selectedUser = widget.users[widget.selectedIndex];
}
String getFullAccountType(String? accountType) {
if (accountType == null || accountType.isEmpty) return 'N/A';
// Convert to title case
switch (accountType.toLowerCase()) {
case 'sa':
return AppLocalizations.of(context).savingsAccount;
case 'sb':
return AppLocalizations.of(context).savingsAccount;
case 'ln':
return AppLocalizations.of(context).loanAccount;
case 'td':
return AppLocalizations.of(context).termDeposit;
case 'rd':
return AppLocalizations.of(context).recurringDeposit;
case 'ca':
return "Current Account";
default:
return AppLocalizations.of(context).unknownAccount;
}
}
@override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final users = widget.users; final users = widget.users;
int selectedIndex = widget.selectedIndex; int selectedIndex = widget.selectedIndex;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context) title: Text(AppLocalizations.of(context)
.accountInfo .accountInfo
.replaceFirst(RegExp('\n'), '')), .replaceFirst(RegExp('\n'), '')),
), ),
body: Stack( body: Stack(
children: [ children: [
ListView(
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Card(
elevation: 4,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
AppLocalizations.of(context).accountNumber, AppLocalizations.of(context).accountNumber,
style:
const TextStyle(fontWeight: FontWeight.w500, fontSize: 14), style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
), ),
DropdownButton<User>( DropdownButton<User>(
value: selectedUser, value: selectedUser,
onChanged: (User? newUser) { onChanged: (User? newUser) {
if (newUser != null) { if (newUser != null) {
setState(() { setState(() {
selectedUser = newUser; selectedUser = newUser;
}); });
} }
}, },
items: widget.users.map((user) { items: widget.users.map((user) {
return DropdownMenuItem<User>( return DropdownMenuItem<User>(
value: user, value: user,
child: Text(user.accountNo.toString()),
child: Text(
user.accountNo.toString(),
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
); );
}).toList(), }).toList(),
isExpanded: true,
), ),
],
),
),
),
Expanded(
child: Card(
elevation: 4,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ListView(
children: [
InfoRow( InfoRow(
title: AppLocalizations.of(context).customerNumber, title: AppLocalizations.of(context).customerNumber,
value: selectedUser.cifNumber ?? 'N/A', value: selectedUser.cifNumber ?? 'N/A',
),
InfoRow(
title: AppLocalizations.of(context).productName,
value: selectedUser.productType ?? 'N/A',
),
// InfoRow(title: 'Account Opening Date', value: users[selectedIndex].accountOpeningDate ?? 'N/A'),
InfoRow(
title: AppLocalizations.of(context).accountStatus,
value: 'OPEN',
),
InfoRow(
title: AppLocalizations.of(context).availableBalance,
value: selectedUser.availableBalance ?? 'N/A',
),
InfoRow(
title: AppLocalizations.of(context).currentBalance,
value: selectedUser.currentBalance ?? 'N/A',
), ),
users[selectedIndex].approvedAmount != null InfoRow(
? InfoRow(
title: AppLocalizations.of(context).approvedAmount, title: AppLocalizations.of(context).accountType,
value: getFullAccountType(selectedUser.accountType),
),
InfoRow(
title: AppLocalizations.of(context).productName,
value: selectedUser.productType ?? 'N/A',
),
InfoRow(
title: AppLocalizations.of(context).accountStatus,
value: 'OPEN',
),
InfoRow(
title:
AppLocalizations.of(context).availableBalance,
value: selectedUser.availableBalance ?? 'N/A',
),
InfoRow(
title: AppLocalizations.of(context).currentBalance,
value: selectedUser.currentBalance ?? 'N/A',
),
if (users[selectedIndex].approvedAmount != null)
InfoRow(
title:
AppLocalizations.of(context).approvedAmount,
value: selectedUser.approvedAmount ?? 'N/A', value: selectedUser.approvedAmount ?? 'N/A',
)
: const SizedBox.shrink(),
],
), ),
],
),
),
),
),
],
),
),
IgnorePointer( IgnorePointer(
child: Center( child: Center(
child: Opacity( child: Opacity(
opacity: 0.07, // Reduced opacity opacity: 0.07, // Reduced opacity
child: ClipOval( child: ClipOval(
child: Image.asset( child: Image.asset(
'assets/images/logo.png', 'assets/images/logo.png',
width: 200, // Adjust size as needed width: 200, // Adjust size as needed
height: 200, // Adjust size as needed height: 200, // Adjust size as needed
), ),
), ),
), ),
), ),
), ),
], ],
), ),
); );
} }
} }
class InfoRow extends StatelessWidget { class InfoRow extends StatelessWidget {
@@ -130,15 +310,18 @@ class InfoRow extends StatelessWidget {
Text( Text(
title, title,
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 18,
fontWeight: FontWeight.w500, fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurfaceVariant, color: theme.colorScheme.onSurfaceVariant,
), ),
), ),
const SizedBox(height: 3), const SizedBox(height: 3),
Text( Text(
value, value,
style: TextStyle(fontSize: 16, color: theme.colorScheme.onSurface), style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurface),
), ),
], ],
), ),

View File

@@ -14,15 +14,16 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
import 'package:kmobile/data/models/user.dart';
class AccountStatementScreen extends StatefulWidget { class AccountStatementScreen extends StatefulWidget {
final String accountNo; final List<User> users;
final String balance; final int selectedIndex;
final String accountType;
const AccountStatementScreen({ const AccountStatementScreen({
super.key, super.key,
required this.accountNo, required this.users,
required this.balance, required this.selectedIndex,
required this.accountType,
}); });
@override @override
@@ -30,6 +31,7 @@ class AccountStatementScreen extends StatefulWidget {
} }
class _AccountStatementScreen extends State<AccountStatementScreen> { class _AccountStatementScreen extends State<AccountStatementScreen> {
late User selectedUser;
DateTime? fromDate; DateTime? fromDate;
DateTime? toDate; DateTime? toDate;
bool _txLoading = true; bool _txLoading = true;
@@ -41,6 +43,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
selectedUser = widget.users[widget.selectedIndex];
_loadTransactions(); _loadTransactions();
} }
@@ -52,7 +55,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
try { try {
final repo = getIt<TransactionRepository>(); final repo = getIt<TransactionRepository>();
final txs = await repo.fetchTransactions( final txs = await repo.fetchTransactions(
widget.accountNo, selectedUser.accountNo?? '',
fromDate: fromDate, fromDate: fromDate,
toDate: toDate, toDate: toDate,
); );
@@ -142,19 +145,28 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [ children: [
Text( Text(
"${AppLocalizations.of(context).accountNumber}: ", AppLocalizations.of(context).accountNumber,
style: const TextStyle( style: const TextStyle(
fontSize: 17, fontWeight: FontWeight.w500, fontSize: 14),
fontWeight: FontWeight.bold,
), ),
), DropdownButton<User>(
Text(widget.accountNo, value: selectedUser,
style: const TextStyle(fontSize: 17)), onChanged: (User? newUser) {
], if (newUser != null) {
setState(() {
selectedUser = newUser;
});
_loadTransactions();
}
},
items: widget.users.map((user) {
return DropdownMenuItem<User>(
value: user,
child: Text(user.accountNo.toString()),
);
}).toList(),
), ),
const SizedBox(height: 15), const SizedBox(height: 15),
Row( Row(
@@ -165,7 +177,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
fontSize: 17, fontSize: 17,
), ),
), ),
Text('${widget.balance}', Text('${selectedUser.availableBalance}',
style: const TextStyle(fontSize: 17)), style: const TextStyle(fontSize: 17)),
], ],
), ),
@@ -298,9 +310,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
? Symbols.call_received ? Symbols.call_received
: Symbols.call_made, : Symbols.call_made,
color: tx.type == 'CR' color: tx.type == 'CR'
? Theme.of(context) ? const Color(0xFF10BB10)
.colorScheme
.secondary
: Theme.of(context).colorScheme.error, : Theme.of(context).colorScheme.error,
), ),
title: Text( title: Text(
@@ -413,10 +423,10 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
pw.Row( pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween, mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
children: [ children: [
pw.Text('Account Number: ${widget.accountNo}', pw.Text('Account Number: ${selectedUser.accountNo}',
style: style:
pw.TextStyle(font: pw.Font.ttf(rubik), fontSize: 15)), pw.TextStyle(font: pw.Font.ttf(rubik), fontSize: 15)),
pw.Text('Account Type: ${widget.accountType}', pw.Text('Account Type: ${selectedUser.productType}',
style: pw.TextStyle( style: pw.TextStyle(
fontSize: 15, fontSize: 15,
font: pw.Font.ttf(rubik), font: pw.Font.ttf(rubik),

View File

@@ -43,7 +43,7 @@ class TransactionDetailsScreen extends StatelessWidget {
? Symbols.call_received ? Symbols.call_received
: Symbols.call_made, : Symbols.call_made,
color: isCredit color: isCredit
? Theme.of(context).colorScheme.secondary ? const Color(0xFF10BB10)
: Theme.of(context).colorScheme.error, : Theme.of(context).colorScheme.error,
size: 28, size: 28,
), ),

View File

@@ -675,13 +675,8 @@ class _DashboardScreenState extends State<DashboardScreen>
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) =>
AccountStatementScreen( AccountStatementScreen(
accountNo: users[selectedAccountIndex] users: users,
.accountNo!, selectedIndex: selectedAccountIndex,
balance: users[selectedAccountIndex]
.availableBalance!,
accountType:
users[selectedAccountIndex]
.accountType!,
))); )));
}), }),
_buildQuickLink(Icons.location_pin, "Branch Locator", _buildQuickLink(Icons.location_pin, "Branch Locator",
@@ -722,6 +717,7 @@ class _DashboardScreenState extends State<DashboardScreen>
), ),
); );
}, },
disable: true,
), ),
], ],
), ),