From 3358ec7669c46388b41ac28ca2a45583984cfc7e Mon Sep 17 00:00:00 2001 From: asif Date: Tue, 25 Nov 2025 12:51:29 +0530 Subject: [PATCH] UI #1 --- lib/app.dart | 6 +- lib/di/injection.dart | 4 +- .../accounts/screens/account_info_screen.dart | 315 ++++++++++++++---- .../screens/account_statement_screen.dart | 60 ++-- .../screens/transaction_details_screen.dart | 2 +- .../dashboard/screens/dashboard_screen.dart | 10 +- 6 files changed, 292 insertions(+), 105 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index fe72f70..0410684 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -319,11 +319,9 @@ class _NavigationScaffoldState extends State { 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.")); diff --git a/lib/di/injection.dart b/lib/di/injection.dart index 0e7aabc..37b1fb7 100644 --- a/lib/di/injection.dart +++ b/lib/di/injection.dart @@ -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: { diff --git a/lib/features/accounts/screens/account_info_screen.dart b/lib/features/accounts/screens/account_info_screen.dart index ae142c1..fa4567b 100644 --- a/lib/features/accounts/screens/account_info_screen.dart +++ b/lib/features/accounts/screens/account_info_screen.dart @@ -17,99 +17,279 @@ class AccountInfoScreen extends StatefulWidget { } class _AccountInfoScreen extends State { + 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( - value: selectedUser, - onChanged: (User? newUser) { - if (newUser != null) { - setState(() { - selectedUser = newUser; - }); - } - }, - items: widget.users.map((user) { - return DropdownMenuItem( - 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( + + value: selectedUser, + + onChanged: (User? newUser) { + + if (newUser != null) { + + setState(() { + + selectedUser = newUser; + + }); + + } + + }, + + items: widget.users.map((user) { + + return DropdownMenuItem( + + 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), ), ], ), diff --git a/lib/features/accounts/screens/account_statement_screen.dart b/lib/features/accounts/screens/account_statement_screen.dart index 892020e..62f068c 100644 --- a/lib/features/accounts/screens/account_statement_screen.dart +++ b/lib/features/accounts/screens/account_statement_screen.dart @@ -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 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 { + late User selectedUser; DateTime? fromDate; DateTime? toDate; bool _txLoading = true; @@ -41,6 +43,7 @@ class _AccountStatementScreen extends State { @override void initState() { super.initState(); + selectedUser = widget.users[widget.selectedIndex]; _loadTransactions(); } @@ -52,7 +55,7 @@ class _AccountStatementScreen extends State { try { final repo = getIt(); final txs = await repo.fetchTransactions( - widget.accountNo, + selectedUser.accountNo?? '', fromDate: fromDate, toDate: toDate, ); @@ -143,18 +146,27 @@ class _AccountStatementScreen extends State { 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( + value: selectedUser, + onChanged: (User? newUser) { + if (newUser != null) { + setState(() { + selectedUser = newUser; + }); + _loadTransactions(); + } + }, + items: widget.users.map((user) { + return DropdownMenuItem( + value: user, + child: Text(user.accountNo.toString()), + ); + }).toList(), ), const SizedBox(height: 15), Row( @@ -165,7 +177,7 @@ class _AccountStatementScreen extends State { fontSize: 17, ), ), - Text(' ₹ ${widget.balance}', + Text(' ₹ ${selectedUser.availableBalance}', style: const TextStyle(fontSize: 17)), ], ), @@ -298,9 +310,7 @@ class _AccountStatementScreen extends State { ? 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 { 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), diff --git a/lib/features/accounts/screens/transaction_details_screen.dart b/lib/features/accounts/screens/transaction_details_screen.dart index 8f01687..010b0c6 100644 --- a/lib/features/accounts/screens/transaction_details_screen.dart +++ b/lib/features/accounts/screens/transaction_details_screen.dart @@ -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, ), diff --git a/lib/features/dashboard/screens/dashboard_screen.dart b/lib/features/dashboard/screens/dashboard_screen.dart index dccc9f0..8400269 100644 --- a/lib/features/dashboard/screens/dashboard_screen.dart +++ b/lib/features/dashboard/screens/dashboard_screen.dart @@ -675,13 +675,8 @@ class _DashboardScreenState extends State 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 ), ); }, + disable: true, ), ], ),