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) {
if (state is Authenticated) {
if (state.users.isNotEmpty) {
final user = state.users.first;
return AccountStatementScreen(
accountNo: user.accountNo ?? '',
balance: user.availableBalance ?? '0.00',
accountType: user.accountType ?? '',
users: state.users,
selectedIndex: 0,
);
} else {
return const Center(child: Text("No accounts found."));

View File

@@ -74,9 +74,9 @@ Dio _createDioClient() {
final dio = Dio(
BaseOptions(
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
//'https://kccbmbnk.net', //prod small
'https://kccbmbnk.net', //prod small
connectTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 60),
headers: {

View File

@@ -17,99 +17,279 @@ class AccountInfoScreen extends StatefulWidget {
}
class _AccountInfoScreen extends State<AccountInfoScreen> {
late User selectedUser;
@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) {
final users = widget.users;
int selectedIndex = widget.selectedIndex;
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)
.accountInfo
.replaceFirst(RegExp('\n'), '')),
),
body: Stack(
children: [
ListView(
padding: const EdgeInsets.all(16.0),
children: [
Text(
AppLocalizations.of(context).accountNumber,
style:
const TextStyle(fontWeight: FontWeight.w500, fontSize: 14),
),
DropdownButton<User>(
value: selectedUser,
onChanged: (User? newUser) {
if (newUser != null) {
setState(() {
selectedUser = newUser;
});
}
},
items: widget.users.map((user) {
return DropdownMenuItem<User>(
value: user,
child: Text(user.accountNo.toString()),
);
}).toList(),
),
Padding(
InfoRow(
title: AppLocalizations.of(context).customerNumber,
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',
),
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),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
AppLocalizations.of(context).accountNumber,
style: const TextStyle(
fontWeight: FontWeight.bold, fontSize: 18),
),
DropdownButton<User>(
value: selectedUser,
onChanged: (User? newUser) {
if (newUser != null) {
setState(() {
selectedUser = newUser;
});
}
},
items: widget.users.map((user) {
return DropdownMenuItem<User>(
value: user,
child: Text(
user.accountNo.toString(),
style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),
),
);
}).toList(),
isExpanded: true,
),
],
),
users[selectedIndex].approvedAmount != null
? InfoRow(
title: AppLocalizations.of(context).approvedAmount,
value: selectedUser.approvedAmount ?? 'N/A',
)
: const SizedBox.shrink(),
],
),
IgnorePointer(
child: Center(
child: Opacity(
opacity: 0.07, // Reduced opacity
child: ClipOval(
child: Image.asset(
'assets/images/logo.png',
width: 200, // Adjust size as needed
height: 200, // Adjust size as needed
),
),
),
Expanded(
child: Card(
elevation: 4,
margin: const EdgeInsets.symmetric(vertical: 8.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ListView(
children: [
InfoRow(
title: AppLocalizations.of(context).customerNumber,
value: selectedUser.cifNumber ?? 'N/A',
),
InfoRow(
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',
),
],
),
),
),
),
],
),
),
IgnorePointer(
child: Center(
child: Opacity(
opacity: 0.07, // Reduced opacity
child: ClipOval(
child: Image.asset(
'assets/images/logo.png',
width: 200, // Adjust size as needed
height: 200, // Adjust size as needed
),
),
),
),
),
],
),
);
}
}
class InfoRow extends StatelessWidget {
@@ -130,15 +310,18 @@ class InfoRow extends StatelessWidget {
Text(
title,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
fontSize: 18,
fontWeight: FontWeight.bold,
color: theme.colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 3),
Text(
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:share_plus/share_plus.dart';
import 'package:kmobile/data/models/user.dart';
class AccountStatementScreen extends StatefulWidget {
final String accountNo;
final String balance;
final String accountType;
final List<User> users;
final int selectedIndex;
const AccountStatementScreen({
super.key,
required this.accountNo,
required this.balance,
required this.accountType,
required this.users,
required this.selectedIndex,
});
@override
@@ -30,6 +31,7 @@ class AccountStatementScreen extends StatefulWidget {
}
class _AccountStatementScreen extends State<AccountStatementScreen> {
late User selectedUser;
DateTime? fromDate;
DateTime? toDate;
bool _txLoading = true;
@@ -41,6 +43,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
@override
void initState() {
super.initState();
selectedUser = widget.users[widget.selectedIndex];
_loadTransactions();
}
@@ -52,7 +55,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
try {
final repo = getIt<TransactionRepository>();
final txs = await repo.fetchTransactions(
widget.accountNo,
selectedUser.accountNo?? '',
fromDate: fromDate,
toDate: toDate,
);
@@ -143,18 +146,27 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
"${AppLocalizations.of(context).accountNumber}: ",
style: const TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold,
),
),
Text(widget.accountNo,
style: const TextStyle(fontSize: 17)),
],
Text(
AppLocalizations.of(context).accountNumber,
style: const TextStyle(
fontWeight: FontWeight.w500, fontSize: 14),
),
DropdownButton<User>(
value: selectedUser,
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),
Row(
@@ -165,7 +177,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
fontSize: 17,
),
),
Text('${widget.balance}',
Text('${selectedUser.availableBalance}',
style: const TextStyle(fontSize: 17)),
],
),
@@ -298,9 +310,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
? Symbols.call_received
: Symbols.call_made,
color: tx.type == 'CR'
? Theme.of(context)
.colorScheme
.secondary
? const Color(0xFF10BB10)
: Theme.of(context).colorScheme.error,
),
title: Text(
@@ -413,10 +423,10 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
pw.Row(
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
children: [
pw.Text('Account Number: ${widget.accountNo}',
pw.Text('Account Number: ${selectedUser.accountNo}',
style:
pw.TextStyle(font: pw.Font.ttf(rubik), fontSize: 15)),
pw.Text('Account Type: ${widget.accountType}',
pw.Text('Account Type: ${selectedUser.productType}',
style: pw.TextStyle(
fontSize: 15,
font: pw.Font.ttf(rubik),

View File

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

View File

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