Compare commits
105 Commits
language-t
...
live-1
Author | SHA1 | Date | |
---|---|---|---|
c729b775c9 | |||
465065db57 | |||
0a6dde9ead | |||
b513664a47 | |||
d8d87e8da4 | |||
1204507375 | |||
be9a6fc93f | |||
b8337d1152 | |||
d3792a1a06 | |||
845ce1fe78 | |||
45dbf8464a | |||
|
a1ea60841e | ||
|
2abc315af9 | ||
|
a44ac67842 | ||
|
1b684af3a8 | ||
|
aa5a7877e4 | ||
|
d6a99ea295 | ||
|
cf8964ca36 | ||
|
c489bf3895 | ||
|
ba819f51d7 | ||
|
48f169d10c | ||
|
64e80148a3 | ||
|
85f58c1e25 | ||
|
3b9b1e507c | ||
57439f2acb | |||
52534f9210 | |||
d9f78629d2 | |||
3e3465d5e8 | |||
be76465774 | |||
de596aa138 | |||
720c6ec03a | |||
d081a5433c | |||
90f4a6bb81 | |||
|
f71c8d646b | ||
|
6a8f091ac5 | ||
|
596f0a96eb | ||
|
768d312066 | ||
|
4277ca9169 | ||
|
53caa5b7ae | ||
|
bfa0721e79 | ||
|
75bcce8201 | ||
|
99f4b1b735 | ||
|
6ebc96d153 | ||
|
6496aa95c0 | ||
|
e91efafa0e | ||
|
61a6e356d9 | ||
|
a48781ad1b | ||
|
d425af184e | ||
|
bc2c460f96 | ||
|
ef3556f207 | ||
|
6724d8bed0 | ||
|
83ed973b44 | ||
|
f7dd31fb93 | ||
|
9c60dc1c1c | ||
|
c369ad415d | ||
|
f934f0bff6 | ||
|
da0287ef38 | ||
|
f65507a706 | ||
9f6b35d3eb | |||
a33b4bc1e1 | |||
0d629226a8 | |||
6d502a0c81 | |||
96d1e37c42 | |||
b0610ad84d | |||
ceb29ee7fe | |||
57cb93c124 | |||
0ac9a1f319 | |||
d3ad68b25c | |||
|
eb0e1c120e | ||
a64e68d642 | |||
80faa06272 | |||
0bab68a2e6 | |||
|
351ee84414 | ||
|
f77549310a | ||
4b28a113d4 | |||
bf35ec61d5 | |||
180d3a3a60 | |||
|
737ce6cce6 | ||
|
e75f48aed5 | ||
|
5ee88403dd | ||
|
7fe8e8f084 | ||
|
59eb509dda | ||
|
5f41c6e7f4 | ||
|
36474786c1 | ||
|
df51c4f30b | ||
|
cf8588b336 | ||
04c992c934 | |||
fc76528206 | |||
7527db3d2f | |||
19d3487552 | |||
|
60a5703c35 | ||
09618db28e | |||
712553e49f | |||
842eef2cc7 | |||
|
e6ea764785 | ||
e2a809d363 | |||
f48bfabb4a | |||
76d5874e19 | |||
913e31a6ab | |||
7f5258b5b7 | |||
|
82951b7919 | ||
8ae26e2f18 | |||
e7bbab13ba | |||
72862492c0 | |||
|
f91d0f739b |
3
.gitignore
vendored
@@ -41,3 +41,6 @@ app.*.map.json
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
lib/l10n/app_localizations.dart
|
||||
lib/l10n/app_localizations_en.dart
|
||||
lib/l10n/app_localizations_hi.dart
|
||||
|
@@ -7,6 +7,9 @@
|
||||
|
||||
# The following line activates a set of recommended lints for Flutter apps,
|
||||
# packages, and plugins designed to encourage good coding practices.
|
||||
analyzer:
|
||||
errors:
|
||||
dead_code: ignore
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
linter:
|
||||
|
@@ -25,7 +25,7 @@ if (flutterVersionName == null) {
|
||||
android {
|
||||
namespace "com.example.kmobile"
|
||||
compileSdk flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
ndkVersion "27.0.12077973"
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -45,7 +45,7 @@ android {
|
||||
applicationId "com.example.kmobile"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
minSdkVersion 29
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
@@ -56,6 +56,10 @@ android {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
android/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
-keep class io.flutter.app.** { *; }
|
||||
-keep class io.flutter.plugin.** { *; }
|
||||
-keep class io.flutter.util.** { *; }
|
||||
-keep class io.flutter.view.** { *; }
|
||||
-keep class io.flutter.embedding.** { *; }
|
||||
-keep class io.flutter.embedding.engine.plugins.** { *; }
|
||||
-keep class com.google.firebase.** { *; }
|
||||
-keep class com.google.android.gms.** { *; }
|
||||
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||
# This is generated automatically by the Android Gradle plugin.
|
||||
-dontwarn com.google.android.play.core.splitcompat.SplitCompatApplication
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallException
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManager
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManagerFactory
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest$Builder
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallSessionState
|
||||
-dontwarn com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener
|
||||
-dontwarn com.google.android.play.core.tasks.OnFailureListener
|
||||
-dontwarn com.google.android.play.core.tasks.OnSuccessListener
|
||||
-dontwarn com.google.android.play.core.tasks.Task
|
@@ -6,6 +6,7 @@
|
||||
android:label="kmobile"
|
||||
android:name="${applicationName}"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
663
android/build/reports/problems/problems-report.html
Normal file
BIN
assets/images/BankofBaroda_logo.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/images/axisbank_logo.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
assets/images/boi_logo.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
assets/images/canaraBank_logo.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
assets/images/hdfc_logo.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
assets/images/icici_logo.png
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
assets/images/kotak_logo.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
assets/images/pnb_logo.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/images/sbi_logo.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: unused_local_variable
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import '../../data/repositories/auth_repository.dart';
|
||||
|
||||
|
@@ -4,7 +4,6 @@ import '../../features/auth/models/auth_token.dart';
|
||||
import '../../features/auth/models/auth_credentials.dart';
|
||||
import '../../core/errors/exceptions.dart';
|
||||
|
||||
|
||||
class AuthService {
|
||||
final Dio _dio;
|
||||
AuthService(this._dio);
|
||||
@@ -15,7 +14,7 @@ class AuthService {
|
||||
'/api/auth/login',
|
||||
data: credentials.toJson(),
|
||||
);
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return AuthToken.fromJson(response.data);
|
||||
} else {
|
||||
@@ -30,7 +29,8 @@ class AuthService {
|
||||
}
|
||||
throw NetworkException('Network error during login');
|
||||
} catch (e) {
|
||||
throw UnexpectedException('Unexpected error during login: ${e.toString()}');
|
||||
throw UnexpectedException(
|
||||
'Unexpected error during login: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class AuthService {
|
||||
'/auth/refresh',
|
||||
data: {'refresh_token': refreshToken},
|
||||
);
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return AuthToken.fromJson(response.data);
|
||||
} else {
|
||||
@@ -54,7 +54,7 @@ class AuthService {
|
||||
Future<bool> checkTpin() async {
|
||||
try {
|
||||
final response = await _dio.get('/api/auth/tpin');
|
||||
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['tpinSet'] as bool;
|
||||
} else {
|
||||
@@ -66,7 +66,8 @@ class AuthService {
|
||||
}
|
||||
throw NetworkException('Network error during TPIN check');
|
||||
} catch (e) {
|
||||
throw UnexpectedException('Unexpected error during TPIN check: ${e.toString()}');
|
||||
throw UnexpectedException(
|
||||
'Unexpected error during TPIN check: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ class AuthService {
|
||||
'/api/auth/tpin',
|
||||
data: {'tpin': tpin},
|
||||
);
|
||||
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw AuthException('Failed to set TPIN');
|
||||
}
|
||||
@@ -86,8 +87,8 @@ class AuthService {
|
||||
}
|
||||
throw NetworkException('Network error during TPIN setup');
|
||||
} catch (e) {
|
||||
throw UnexpectedException('Unexpected error during TPIN setup: ${e.toString()}');
|
||||
throw UnexpectedException(
|
||||
'Unexpected error during TPIN setup: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import 'dart:developer';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/core/errors/exceptions.dart';
|
||||
import 'package:kmobile/data/models/ifsc.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
|
||||
@@ -9,14 +11,16 @@ class BeneficiaryService {
|
||||
|
||||
Future<String> validateBeneficiaryWithinBank(String accountNumber) async {
|
||||
try {
|
||||
final response = await _dio.get('/api/beneficiary/validate/within-bank', queryParameters: {
|
||||
final response = await _dio
|
||||
.get('/api/beneficiary/validate/within-bank', queryParameters: {
|
||||
'accountNumber': accountNumber,
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['name'];
|
||||
} else {
|
||||
throw Exception(response.data['error'] ?? 'Failed to validate beneficiary');
|
||||
throw Exception(
|
||||
response.data['error'] ?? 'Failed to validate beneficiary');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Network error: ${e.message}');
|
||||
@@ -24,156 +28,99 @@ class BeneficiaryService {
|
||||
throw Exception('Unexpected error: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<ifsc?> validateIFSC(String ifscCode) async {
|
||||
try {
|
||||
final response = await _dio.get('/api/beneficiary/ifsc-details', queryParameters: {
|
||||
"ifscCode": ifscCode
|
||||
}
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return ifsc.fromJson(response.data);
|
||||
Future<Ifsc> validateIFSC(String ifscCode) async {
|
||||
try {
|
||||
final response = await _dio.get('/api/beneficiary/ifsc-details',
|
||||
queryParameters: {"ifscCode": ifscCode});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return Ifsc.fromJson(response.data);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404) {
|
||||
throw Exception('INVALID IFSC CODE');
|
||||
}
|
||||
else if (e.response?.statusCode == 401) {
|
||||
throw Exception('INVALID IFSC CODE');
|
||||
}
|
||||
} catch (e) {
|
||||
throw UnexpectedException(
|
||||
'Unexpected error during login: ${e.toString()}');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
if (e.response?.statusCode == 404) {
|
||||
print('Invalid IFSC code.');
|
||||
} else {
|
||||
print('API error: ${e.message}');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Unexpected error: $e');
|
||||
return Ifsc.fromJson({});
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
///Step 1: Validate beneficiary (returns refNo)
|
||||
Future<String?> validateBeneficiary({
|
||||
Future<String> validateBeneficiary({
|
||||
required String accountNo,
|
||||
required String ifscCode,
|
||||
required String remitterName,
|
||||
}) async {
|
||||
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
'/api/beneficiary/validate/outside_bank',
|
||||
queryParameters: {
|
||||
'accountNo': accountNo,
|
||||
'ifscCode': ifscCode,
|
||||
'remitterName': remitterName,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['refNo'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error validating beneficiary: $e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Step 2: Check validation status (returns Beneficiary name if success)
|
||||
Future<String?> checkValidationStatus(String refNo) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'/api/beneficiary/check',
|
||||
queryParameters: {
|
||||
'refNo': refNo,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
return Beneficiary.fromJson(response.data).name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error checking validation status: $e");
|
||||
return null;
|
||||
log('inside validate beneficiary service');
|
||||
final response = await _dio.get(
|
||||
'/api/beneficiary/validate/outside-bank',
|
||||
queryParameters: {
|
||||
'accountNo': accountNo,
|
||||
'ifscCode': ifscCode,
|
||||
'remitterName': remitterName,
|
||||
},
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception("Invalid Beneficiary Details");
|
||||
}
|
||||
return response.data['name'];
|
||||
}
|
||||
|
||||
// Send Data for Validation
|
||||
Future<void> sendForValidation(Beneficiary beneficiary) async {
|
||||
Future<bool> sendForValidation(Beneficiary beneficiary) async {
|
||||
try {
|
||||
print(beneficiary.toJson());
|
||||
final response = await _dio.post(
|
||||
'/api/beneficiary/add',
|
||||
'/api/beneficiary',
|
||||
data: beneficiary.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print("SENT FOR VALIDATION");
|
||||
return true;
|
||||
} else {
|
||||
print("VALIDATION REQUEST FAILED: ${response.statusCode}");
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
print("ERROR IN SENDING REQUEST: $e");
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
// Poll to check if beneficiary is found
|
||||
Future<bool> checkIfFound(String accountNo) async {
|
||||
const int timeoutInSeconds = 30;
|
||||
const int intervalInSeconds = 2;
|
||||
const int maxTries = timeoutInSeconds ~/ intervalInSeconds;
|
||||
|
||||
int attempts = 0;
|
||||
|
||||
while (attempts < maxTries) {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
'/api/beneficiary/check?',
|
||||
queryParameters: {
|
||||
'accountNo': accountNo
|
||||
}
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
print("FOUND");
|
||||
return true;
|
||||
} else if (response.statusCode == 404) {
|
||||
print("NOT FOUND");
|
||||
}
|
||||
} catch (e) {
|
||||
print("ERROR DURING STATUS: $e");
|
||||
}
|
||||
attempts++;
|
||||
}
|
||||
|
||||
print("Beneficiary not found within timeout.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<List<Beneficiary>> fetchBeneficiaryList() async{
|
||||
Future<List<Beneficiary>> fetchBeneficiaryList() async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
"/api/beneficiary/get",
|
||||
options: Options(
|
||||
"/api/beneficiary",
|
||||
options: Options(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return Beneficiary.listFromJson(response.data);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return Beneficiary.listFromJson(response.data);
|
||||
} else {
|
||||
throw Exception("Failed to fetch beneficiaries");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error fetching beneficiaries: $e");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> deleteBeneficiary(String accountNo) async {
|
||||
try {
|
||||
final response = await _dio.delete('/api/beneficiary/$accountNo');
|
||||
|
||||
if (response.statusCode != 204) {
|
||||
throw Exception('Failed to delete beneficiary');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
throw Exception('Network error: ${e.message}');
|
||||
} catch (e) {
|
||||
throw Exception('Unexpected error: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
0
lib/api/services/change_password_service.dart
Normal file
31
lib/api/services/imps_service.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/data/models/imps_response.dart';
|
||||
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||
|
||||
class ImpsService {
|
||||
final Dio _dio;
|
||||
|
||||
ImpsService(this._dio);
|
||||
|
||||
Future<ImpsResponse> processImpsTransaction(
|
||||
ImpsTransaction transaction) async {
|
||||
try {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
final response = await _dio.post(
|
||||
'/api/payment/imps',
|
||||
data: transaction.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return ImpsResponse.fromJson(response.data);
|
||||
} else {
|
||||
throw Exception(
|
||||
'IMPS transaction failed with status code: ${response.statusCode}');
|
||||
}
|
||||
} on DioException {
|
||||
rethrow;
|
||||
} catch (e) {
|
||||
throw Exception('An unexpected error occurred: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
34
lib/api/services/neft_service.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/data/models/neft_response.dart';
|
||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||
|
||||
class NeftService {
|
||||
final Dio _dio;
|
||||
|
||||
NeftService(this._dio);
|
||||
|
||||
Future<NeftResponse> processNeftTransaction(
|
||||
NeftTransaction transaction) async {
|
||||
try {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
final response = await _dio.post(
|
||||
'/api/payment/neft',
|
||||
data: transaction.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return NeftResponse.fromJson(response.data);
|
||||
} else {
|
||||
throw Exception(
|
||||
'NEFT transaction failed with status code: ${response.statusCode}');
|
||||
}
|
||||
} on DioException {
|
||||
log('DioException Occured');
|
||||
rethrow;
|
||||
} catch (e) {
|
||||
throw Exception('An unexpected error occurred: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
@@ -11,7 +10,7 @@ class PaymentService {
|
||||
Future<PaymentResponse> processQuickPayWithinBank(Transfer transfer) async {
|
||||
try {
|
||||
await Future.delayed(const Duration(seconds: 3)); // Simulate delay
|
||||
|
||||
|
||||
await _dio.post('/api/payment/transfer', data: transfer.toJson());
|
||||
|
||||
return PaymentResponse(
|
||||
|
31
lib/api/services/rtgs_service.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/data/models/rtgs_response.dart';
|
||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||
|
||||
class RtgsService {
|
||||
final Dio _dio;
|
||||
|
||||
RtgsService(this._dio);
|
||||
|
||||
Future<RtgsResponse> processRtgsTransaction(
|
||||
RtgsTransaction transaction) async {
|
||||
try {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
final response = await _dio.post(
|
||||
'/api/payment/rtgs',
|
||||
data: transaction.toJson(),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return RtgsResponse.fromJson(response.data);
|
||||
} else {
|
||||
throw Exception(
|
||||
'RTGS transaction failed with status code: ${response.statusCode}');
|
||||
}
|
||||
} on DioException {
|
||||
rethrow;
|
||||
} catch (e) {
|
||||
throw Exception('An unexpected error occurred: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
@@ -28,4 +28,4 @@ class UserService {
|
||||
throw Exception('Unexpected error: ${e.toString()}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
199
lib/app.dart
@@ -2,6 +2,8 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_state.dart';
|
||||
import 'package:kmobile/security/secure_storage.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import './l10n/app_localizations.dart';
|
||||
@@ -11,7 +13,7 @@ import 'config/routes.dart';
|
||||
import 'di/injection.dart';
|
||||
import 'features/auth/controllers/auth_cubit.dart';
|
||||
import 'features/card/screens/card_management_screen.dart';
|
||||
import 'features/auth/screens/welcome_screen.dart';
|
||||
import 'features/auth/screens/splash_screen.dart';
|
||||
import 'features/auth/screens/login_screen.dart';
|
||||
import 'features/service/screens/service_screen.dart';
|
||||
import 'features/dashboard/screens/dashboard_screen.dart';
|
||||
@@ -26,7 +28,8 @@ class KMobile extends StatefulWidget {
|
||||
State<KMobile> createState() => _KMobileState();
|
||||
|
||||
static void setLocale(BuildContext context, Locale newLocale) {
|
||||
final _KMobileState? state = context.findAncestorStateOfType<_KMobileState>();
|
||||
final _KMobileState? state =
|
||||
context.findAncestorStateOfType<_KMobileState>();
|
||||
state?.setLocale(newLocale);
|
||||
}
|
||||
}
|
||||
@@ -35,12 +38,11 @@ class _KMobileState extends State<KMobile> {
|
||||
bool showSplash = true;
|
||||
Locale? _locale;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loadPreferences();
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
setState(() {
|
||||
showSplash = false;
|
||||
});
|
||||
@@ -57,7 +59,6 @@ class _KMobileState extends State<KMobile> {
|
||||
_locale = Locale(langCode);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void setLocale(Locale locale) {
|
||||
@@ -66,54 +67,54 @@ class _KMobileState extends State<KMobile> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Set status bar color and brightness
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
);
|
||||
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
||||
BlocProvider<ThemeCubit>(create: (_) => getIt<ThemeCubit>()),
|
||||
],
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
builder: (context, themeState) {
|
||||
print('global theme state changed');
|
||||
print(themeState);
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: _locale ?? const Locale('en'),
|
||||
supportedLocales: const [
|
||||
Locale('en'),
|
||||
Locale('hi'),
|
||||
],
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
title: 'kMobile',
|
||||
//theme: AppThemes.getLightTheme(themeState.themeType),
|
||||
theme: themeState.getThemeData(),
|
||||
// darkTheme: AppThemes.getDarkTheme(themeState.themeType),
|
||||
themeMode: ThemeMode.system,
|
||||
onGenerateRoute: AppRoutes.generateRoute,
|
||||
initialRoute: AppRoutes.splash,
|
||||
home: showSplash ? const SplashScreen() : const AuthGate(),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
return MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
||||
BlocProvider<ThemeCubit>(create: (_) => ThemeCubit()),
|
||||
BlocProvider<ThemeModeCubit>(create: (_) => ThemeModeCubit()),
|
||||
],
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
builder: (context, themeState) {
|
||||
return BlocBuilder<ThemeModeCubit, ThemeModeState>(
|
||||
builder: (context, modeState) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
locale: _locale ?? const Locale('en'),
|
||||
supportedLocales: const [
|
||||
Locale('en'),
|
||||
Locale('hi'),
|
||||
],
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
title: 'kMobile',
|
||||
theme: themeState.getLightThemeData(),
|
||||
darkTheme: themeState.getDarkThemeData(),
|
||||
themeMode: context.watch<ThemeModeCubit>().state.mode,
|
||||
onGenerateRoute: AppRoutes.generateRoute,
|
||||
initialRoute: AppRoutes.splash,
|
||||
home: showSplash ? const SplashScreen() : const AuthGate(),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class AuthGate extends StatefulWidget {
|
||||
const AuthGate({super.key});
|
||||
|
||||
@@ -124,7 +125,6 @@ class AuthGate extends StatefulWidget {
|
||||
class _AuthGateState extends State<AuthGate> {
|
||||
bool _checking = true;
|
||||
bool _isLoggedIn = false;
|
||||
bool _showWelcome = true;
|
||||
bool _hasMPin = false;
|
||||
bool _biometricEnabled = false;
|
||||
bool _biometricTried = false;
|
||||
@@ -142,8 +142,7 @@ class _AuthGateState extends State<AuthGate> {
|
||||
final mpin = await storage.read('mpin');
|
||||
final biometric = await storage.read('biometric_enabled');
|
||||
setState(() {
|
||||
_isLoggedIn =
|
||||
accessToken != null &&
|
||||
_isLoggedIn = accessToken != null &&
|
||||
accessTokenExpiry != null &&
|
||||
DateTime.parse(accessTokenExpiry).isAfter(DateTime.now());
|
||||
_hasMPin = mpin != null;
|
||||
@@ -158,9 +157,13 @@ class _AuthGateState extends State<AuthGate> {
|
||||
final localAuth = LocalAuthentication();
|
||||
final canCheck = await localAuth.canCheckBiometrics;
|
||||
if (!canCheck) return false;
|
||||
String localizedReason = "";
|
||||
if (mounted) {
|
||||
localizedReason = AppLocalizations.of(context).authenticateToAccess;
|
||||
}
|
||||
try {
|
||||
final didAuth = await localAuth.authenticate(
|
||||
localizedReason: AppLocalizations.of(context).authenticateToAccess,
|
||||
localizedReason: localizedReason,
|
||||
options: const AuthenticationOptions(
|
||||
stickyAuth: true,
|
||||
biometricOnly: true,
|
||||
@@ -172,24 +175,12 @@ class _AuthGateState extends State<AuthGate> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_checking) {
|
||||
return const SplashScreen();
|
||||
}
|
||||
// ✅ Step 1: Show welcome screen first, only once
|
||||
if (_showWelcome) {
|
||||
return WelcomeScreen(
|
||||
onContinue: () {
|
||||
setState(() {
|
||||
_showWelcome = false;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ✅ Step 2: Check login status
|
||||
if (_isLoggedIn) {
|
||||
if (_hasMPin) {
|
||||
if (_biometricEnabled) {
|
||||
@@ -204,7 +195,6 @@ class _AuthGateState extends State<AuthGate> {
|
||||
return const NavigationScaffold(); // Authenticated
|
||||
}
|
||||
|
||||
// ❌ Biometric failed → Show MPIN screen
|
||||
return MPinScreen(
|
||||
mode: MPinMode.enter,
|
||||
onCompleted: (_) {
|
||||
@@ -230,7 +220,6 @@ class _AuthGateState extends State<AuthGate> {
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// No MPIN set → show MPIN set screen + biometric dialog
|
||||
return MPinScreen(
|
||||
mode: MPinMode.set,
|
||||
onCompleted: (_) async {
|
||||
@@ -261,11 +250,14 @@ class _AuthGateState extends State<AuthGate> {
|
||||
if (optIn == true) {
|
||||
final canCheck = await localAuth.canCheckBiometrics;
|
||||
bool didAuth = false;
|
||||
String authEnable = "";
|
||||
if (context.mounted) {
|
||||
authEnable = AppLocalizations.of(context).authenticateToEnable;
|
||||
}
|
||||
|
||||
if (canCheck) {
|
||||
didAuth = await localAuth.authenticate(
|
||||
localizedReason:
|
||||
AppLocalizations.of(context).authenticateToEnable,
|
||||
localizedReason: authEnable,
|
||||
options: const AuthenticationOptions(
|
||||
stickyAuth: true,
|
||||
biometricOnly: true,
|
||||
@@ -278,17 +270,17 @@ class _AuthGateState extends State<AuthGate> {
|
||||
}
|
||||
}
|
||||
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const NavigationScaffold(),
|
||||
),
|
||||
);
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const NavigationScaffold(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Step 3: If not logged in, show login screen
|
||||
return const LoginScreen();
|
||||
}
|
||||
}
|
||||
@@ -310,13 +302,6 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
||||
const ServiceScreen(),
|
||||
];
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
_pageController.jumpToPage(index);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
@@ -357,10 +342,16 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _selectedIndex,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // Light blue background
|
||||
selectedItemColor: Theme.of(context).primaryColor,
|
||||
unselectedItemColor: Colors.black54,
|
||||
onTap: _onItemTapped,
|
||||
backgroundColor: const Color(0XFF1E58AD),
|
||||
selectedItemColor: Theme.of(context).colorScheme.onPrimary,
|
||||
unselectedItemColor:
|
||||
Theme.of(context).colorScheme.onSecondary,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
_pageController.jumpToPage(index);
|
||||
},
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: const Icon(Icons.home_filled),
|
||||
@@ -381,29 +372,6 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
||||
}
|
||||
}
|
||||
|
||||
class SplashScreen extends StatelessWidget {
|
||||
const SplashScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context).loading,
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Add this widget at the end of the file
|
||||
class BiometricPromptScreen extends StatelessWidget {
|
||||
final VoidCallback onCompleted;
|
||||
@@ -416,8 +384,12 @@ class BiometricPromptScreen extends StatelessWidget {
|
||||
onCompleted();
|
||||
return;
|
||||
}
|
||||
String localizedReason = "";
|
||||
if (context.mounted) {
|
||||
localizedReason = AppLocalizations.of(context).enableFingerprintQuick;
|
||||
}
|
||||
final didAuth = await localAuth.authenticate(
|
||||
localizedReason: AppLocalizations.of(context).enableFingerprintQuick,
|
||||
localizedReason: localizedReason,
|
||||
options: const AuthenticationOptions(
|
||||
stickyAuth: true,
|
||||
biometricOnly: true,
|
||||
@@ -461,6 +433,9 @@ class BiometricPromptScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
if (result == true) {
|
||||
await _handleBiometric(context);
|
||||
} else {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/auth/screens/mpin_screen.dart';
|
||||
import 'package:kmobile/features/auth/screens/splash_screen.dart';
|
||||
import '../app.dart';
|
||||
import '../features/auth/screens/login_screen.dart';
|
||||
// import '../features/auth/screens/forgot_password_screen.dart';
|
||||
@@ -13,7 +14,7 @@ import '../features/dashboard/screens/dashboard_screen.dart';
|
||||
class AppRoutes {
|
||||
// Private constructor to prevent instantiation
|
||||
AppRoutes._();
|
||||
|
||||
|
||||
// Route names
|
||||
static const String splash = '/';
|
||||
static const String login = '/login';
|
||||
@@ -25,7 +26,7 @@ class AppRoutes {
|
||||
static const String accounts = '/accounts';
|
||||
static const String transactions = '/transactions';
|
||||
static const String payments = '/payments';
|
||||
|
||||
|
||||
// Route generator
|
||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
@@ -35,13 +36,16 @@ class AppRoutes {
|
||||
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
||||
|
||||
case mPin:
|
||||
return MaterialPageRoute(builder: (_) => const MPinScreen(mode: MPinMode.enter,));
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => const MPinScreen(
|
||||
mode: MPinMode.enter,
|
||||
));
|
||||
|
||||
case register:
|
||||
// Placeholder - create the RegisterScreen class and uncomment
|
||||
// return MaterialPageRoute(builder: (_) => const RegisterScreen());
|
||||
return _errorRoute();
|
||||
|
||||
|
||||
case forgotPassword:
|
||||
// Placeholder - create the ForgotPasswordScreen class and uncomment
|
||||
// return MaterialPageRoute(builder: (_) => const ForgotPasswordScreen());
|
||||
@@ -49,31 +53,30 @@ class AppRoutes {
|
||||
|
||||
case navigationScaffold:
|
||||
return MaterialPageRoute(builder: (_) => const NavigationScaffold());
|
||||
|
||||
|
||||
case dashboard:
|
||||
return MaterialPageRoute(builder: (_) => const DashboardScreen());
|
||||
|
||||
|
||||
case accounts:
|
||||
// Placeholder - create the AccountsScreen class and uncomment
|
||||
// return MaterialPageRoute(builder: (_) => const AccountsScreen());
|
||||
return _errorRoute();
|
||||
|
||||
|
||||
case transactions:
|
||||
// Placeholder - create the TransactionsScreen class and uncomment
|
||||
// return MaterialPageRoute(builder: (_) => const TransactionsScreen());
|
||||
return _errorRoute();
|
||||
|
||||
|
||||
case payments:
|
||||
// Placeholder - create the PaymentsScreen class and uncomment
|
||||
// return MaterialPageRoute(builder: (_) => const PaymentsScreen());
|
||||
return _errorRoute();
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return _errorRoute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Error route
|
||||
static Route<dynamic> _errorRoute() {
|
||||
return MaterialPageRoute(builder: (_) {
|
||||
@@ -87,4 +90,4 @@ class AppRoutes {
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
enum ThemeType {
|
||||
violet,
|
||||
green,
|
||||
orange,
|
||||
blue,
|
||||
}
|
||||
violet,
|
||||
green,
|
||||
orange,
|
||||
blue,
|
||||
yellow,
|
||||
}
|
||||
|
@@ -1,32 +1,52 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'theme_type.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class AppThemes {
|
||||
static ThemeData getLightTheme(ThemeType type) {
|
||||
switch (type) {
|
||||
case ThemeType.green:
|
||||
return ThemeData(primarySwatch: Colors.green);
|
||||
case ThemeType.orange:
|
||||
return ThemeData(primarySwatch: Colors.orange);
|
||||
case ThemeType.blue:
|
||||
return ThemeData(primarySwatch: Colors.blue);
|
||||
case ThemeType.violet:
|
||||
default:
|
||||
return ThemeData(primarySwatch: Colors.deepPurple);
|
||||
}
|
||||
}
|
||||
final Color seedColor = _getSeedColor(type);
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: seedColor,
|
||||
brightness: Brightness.light,
|
||||
);
|
||||
return ThemeData.from(
|
||||
colorScheme: colorScheme,
|
||||
useMaterial3: true,
|
||||
textTheme: GoogleFonts.rubikTextTheme(),
|
||||
);
|
||||
}
|
||||
|
||||
static ThemeData getDarkTheme(ThemeType type) {
|
||||
final Color seedColor = _getSeedColor(type);
|
||||
log(seedColor.toString());
|
||||
final colorScheme = ColorScheme.fromSeed(
|
||||
seedColor: seedColor,
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
|
||||
return ThemeData.from(
|
||||
colorScheme: colorScheme,
|
||||
useMaterial3: true,
|
||||
textTheme: GoogleFonts.rubikTextTheme(
|
||||
ThemeData(brightness: Brightness.dark).textTheme,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Color _getSeedColor(ThemeType type) {
|
||||
switch (type) {
|
||||
case ThemeType.green:
|
||||
return ThemeData.dark().copyWith(primaryColor: Colors.green);
|
||||
return Colors.green;
|
||||
case ThemeType.orange:
|
||||
return ThemeData.dark().copyWith(primaryColor: Colors.orange);
|
||||
return Colors.orange;
|
||||
case ThemeType.blue:
|
||||
return ThemeData.dark().copyWith(primaryColor: Colors.blue);
|
||||
return Colors.blue;
|
||||
case ThemeType.violet:
|
||||
default:
|
||||
return ThemeData.dark().copyWith(primaryColor: Colors.deepPurple);
|
||||
return Colors.deepPurple;
|
||||
case ThemeType.yellow:
|
||||
return Colors.yellow;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
class AppException implements Exception {
|
||||
final String message;
|
||||
|
||||
|
||||
AppException(this.message);
|
||||
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class NetworkException extends AppException {
|
||||
NetworkException(super.message);
|
||||
}
|
||||
|
||||
class AuthException implements Exception{
|
||||
class AuthException implements Exception {
|
||||
final String message;
|
||||
AuthException(this.message);
|
||||
|
||||
@@ -21,4 +21,4 @@ class AuthException implements Exception{
|
||||
|
||||
class UnexpectedException extends AppException {
|
||||
UnexpectedException(super.message);
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,3 @@
|
||||
|
||||
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
|
||||
class Beneficiary {
|
||||
final String accountNo;
|
||||
final String accountType;
|
||||
@@ -9,6 +5,7 @@ class Beneficiary {
|
||||
final String ifscCode;
|
||||
final String? bankName;
|
||||
final String? branchName;
|
||||
final String? tpin;
|
||||
|
||||
Beneficiary({
|
||||
required this.accountNo,
|
||||
@@ -17,31 +14,43 @@ class Beneficiary {
|
||||
required this.ifscCode,
|
||||
this.bankName,
|
||||
this.branchName,
|
||||
this.tpin,
|
||||
});
|
||||
|
||||
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
||||
return Beneficiary(
|
||||
accountNo: json['accountNo'] ?? '',
|
||||
accountType: json['accountType'] ?? '',
|
||||
accountNo: json['account_no'] ?? json['accountNo'] ?? '',
|
||||
accountType: json['account_type'] ?? json['accountType'] ?? '',
|
||||
name: json['name'] ?? '',
|
||||
ifscCode: json['ifscCode'] ?? '',
|
||||
bankName: json['bankName'] ?? '',
|
||||
branchName: json['branchName'] ?? '',
|
||||
ifscCode: json['ifsc_code'] ?? json['ifscCode'] ?? '',
|
||||
bankName: json['bank_name'] ?? json['bankName'] ?? '',
|
||||
branchName: json['branch_name'] ?? json['branchName'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
final Map<String, dynamic> json = {
|
||||
'accountNo': accountNo,
|
||||
'accountType': accountType,
|
||||
'name': name,
|
||||
'ifscCode' : ifscCode,
|
||||
'ifscCode': ifscCode,
|
||||
};
|
||||
if (bankName != null && bankName!.isNotEmpty) {
|
||||
json['bankName'] = bankName;
|
||||
}
|
||||
if (branchName != null && branchName!.isNotEmpty) {
|
||||
json['branchName'] = branchName;
|
||||
}
|
||||
if (tpin != null && tpin!.isNotEmpty) {
|
||||
json['tpin'] = tpin;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
static List<Beneficiary> listFromJson(List<dynamic> jsonList) {
|
||||
final beneficiaryList = jsonList.map((beneficiary) => Beneficiary.fromJson(beneficiary)).toList();
|
||||
print(beneficiaryList);
|
||||
final beneficiaryList = jsonList
|
||||
.map((beneficiary) => Beneficiary.fromJson(beneficiary))
|
||||
.toList();
|
||||
return beneficiaryList;
|
||||
}
|
||||
|
||||
@@ -49,4 +58,4 @@ class Beneficiary {
|
||||
String toString() {
|
||||
return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,45 +0,0 @@
|
||||
class BeneficiaryRecieve {
|
||||
final String accountNo;
|
||||
final String accountType;
|
||||
final String name;
|
||||
final String ifscCode;
|
||||
final String bankName;
|
||||
final String branchName;
|
||||
|
||||
|
||||
BeneficiaryRecieve({
|
||||
required this.accountNo,
|
||||
required this.accountType,
|
||||
required this.name,
|
||||
required this.ifscCode,
|
||||
required this.bankName,
|
||||
required this.branchName,
|
||||
});
|
||||
|
||||
factory BeneficiaryRecieve.fromJson(Map<String, dynamic> json) {
|
||||
return BeneficiaryRecieve(
|
||||
accountNo: json['account_no'] ?? '',
|
||||
accountType: json['account_type'] ?? '',
|
||||
name: json['name'] ?? '',
|
||||
ifscCode: json['ifsc_code'] ?? '',
|
||||
bankName: json['bank_name'] ?? '',
|
||||
branchName: json['branch_name'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'account_no': accountNo,
|
||||
'account_type': accountType,
|
||||
'name': name,
|
||||
'ifsc_code' : ifscCode,
|
||||
'bank_name' : bankName,
|
||||
'branch_name' : branchName
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ListBeneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name, bankName: $bankName, branchName: $branchName)';
|
||||
}
|
||||
}
|
@@ -1,16 +1,16 @@
|
||||
class ifsc {
|
||||
class Ifsc {
|
||||
final String ifscCode;
|
||||
final String bankName;
|
||||
final String branchName;
|
||||
|
||||
ifsc({
|
||||
Ifsc({
|
||||
required this.ifscCode,
|
||||
required this.bankName,
|
||||
required this.branchName,
|
||||
});
|
||||
|
||||
factory ifsc.fromJson(Map<String, dynamic> json) {
|
||||
return ifsc(
|
||||
factory Ifsc.fromJson(Map<String, dynamic> json) {
|
||||
return Ifsc(
|
||||
ifscCode: json['ifsc_code'] ?? '',
|
||||
bankName: json['bank_name'] ?? '',
|
||||
branchName: json['branch_name'] ?? '',
|
||||
@@ -29,4 +29,4 @@ class ifsc {
|
||||
String toString() {
|
||||
return 'IFSC(ifscCode: $ifscCode, bankName: $bankName, branchName: $branchName)';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
lib/data/models/imps_response.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class ImpsResponse {
|
||||
final String message;
|
||||
final String utr;
|
||||
|
||||
ImpsResponse({
|
||||
required this.message,
|
||||
required this.utr,
|
||||
});
|
||||
|
||||
factory ImpsResponse.fromJson(Map<String, dynamic> json) {
|
||||
return ImpsResponse(
|
||||
message: json['message'] ?? '',
|
||||
utr: json['utr'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
31
lib/data/models/imps_transaction.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class ImpsTransaction {
|
||||
final String fromAccount;
|
||||
final String toAccount;
|
||||
final String amount;
|
||||
final String ifscCode;
|
||||
final String? remitterName;
|
||||
final String beneficiaryName;
|
||||
final String tpin;
|
||||
|
||||
ImpsTransaction({
|
||||
required this.fromAccount,
|
||||
required this.toAccount,
|
||||
required this.amount,
|
||||
required this.ifscCode,
|
||||
this.remitterName,
|
||||
required this.beneficiaryName,
|
||||
required this.tpin,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'fromAccount': fromAccount,
|
||||
'toAccount': toAccount,
|
||||
'amount': amount,
|
||||
'ifscCode': ifscCode,
|
||||
'remitterName': remitterName,
|
||||
'beneficiaryName': beneficiaryName,
|
||||
'tpin': tpin,
|
||||
};
|
||||
}
|
||||
}
|
16
lib/data/models/neft_response.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class NeftResponse {
|
||||
final String message;
|
||||
final String utr;
|
||||
|
||||
NeftResponse({
|
||||
required this.message,
|
||||
required this.utr,
|
||||
});
|
||||
|
||||
factory NeftResponse.fromJson(Map<String, dynamic> json) {
|
||||
return NeftResponse(
|
||||
message: json['message'] ?? '',
|
||||
utr: json['utr'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
31
lib/data/models/neft_transaction.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class NeftTransaction {
|
||||
final String fromAccount;
|
||||
final String toAccount;
|
||||
final String amount;
|
||||
final String ifscCode;
|
||||
final String remitterName;
|
||||
final String beneficiaryName;
|
||||
final String tpin;
|
||||
|
||||
NeftTransaction({
|
||||
required this.fromAccount,
|
||||
required this.toAccount,
|
||||
required this.amount,
|
||||
required this.ifscCode,
|
||||
required this.remitterName,
|
||||
required this.beneficiaryName,
|
||||
required this.tpin,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'fromAccount': fromAccount,
|
||||
'toAccount': toAccount,
|
||||
'amount': amount,
|
||||
'ifscCode': ifscCode,
|
||||
'remitterName': remitterName,
|
||||
'beneficiaryName': beneficiaryName,
|
||||
'tpin': tpin,
|
||||
};
|
||||
}
|
||||
}
|
16
lib/data/models/otp.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class Otp {
|
||||
final String mobileNumber;
|
||||
final String type;
|
||||
|
||||
Otp({
|
||||
required this.mobileNumber,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'mobileNumber': mobileNumber,
|
||||
'type': type,
|
||||
};
|
||||
}
|
||||
}
|
14
lib/data/models/otp_verify.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
class OtpVerify{
|
||||
final String otp;
|
||||
|
||||
OtpVerify({
|
||||
required this.otp,
|
||||
}
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'otp': otp,
|
||||
};
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ class PaymentResponse {
|
||||
final String? currency;
|
||||
final String? errorMessage;
|
||||
final String? errorCode;
|
||||
final String? utr;
|
||||
|
||||
PaymentResponse({
|
||||
required this.isSuccess,
|
||||
@@ -15,5 +16,6 @@ class PaymentResponse {
|
||||
this.currency,
|
||||
this.errorMessage,
|
||||
this.errorCode,
|
||||
this.utr,
|
||||
});
|
||||
}
|
||||
|
16
lib/data/models/rtgs_response.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
class RtgsResponse {
|
||||
final String message;
|
||||
final String utr;
|
||||
|
||||
RtgsResponse({
|
||||
required this.message,
|
||||
required this.utr,
|
||||
});
|
||||
|
||||
factory RtgsResponse.fromJson(Map<String, dynamic> json) {
|
||||
return RtgsResponse(
|
||||
message: json['message'] ?? '',
|
||||
utr: json['utr'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
31
lib/data/models/rtgs_transaction.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class RtgsTransaction {
|
||||
final String fromAccount;
|
||||
final String toAccount;
|
||||
final String amount;
|
||||
final String ifscCode;
|
||||
final String remitterName;
|
||||
final String beneficiaryName;
|
||||
final String tpin;
|
||||
|
||||
RtgsTransaction({
|
||||
required this.fromAccount,
|
||||
required this.toAccount,
|
||||
required this.amount,
|
||||
required this.ifscCode,
|
||||
required this.remitterName,
|
||||
required this.beneficiaryName,
|
||||
required this.tpin,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'fromAccount': fromAccount,
|
||||
'toAccount': toAccount,
|
||||
'amount': amount,
|
||||
'ifscCode': ifscCode,
|
||||
'remitterName': remitterName,
|
||||
'beneficiaryName': beneficiaryName,
|
||||
'tpin': tpin,
|
||||
};
|
||||
}
|
||||
}
|
@@ -32,7 +32,7 @@ class TransferResponse {
|
||||
TransferResponse({
|
||||
required this.status,
|
||||
required this.message,
|
||||
required this.error,
|
||||
required this.error,
|
||||
});
|
||||
|
||||
factory TransferResponse.fromJson(Map<String, dynamic> json) {
|
||||
@@ -42,4 +42,4 @@ class TransferResponse {
|
||||
error: json['error'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ class AuthRepository {
|
||||
final AuthService _authService;
|
||||
final UserService _userService;
|
||||
final SecureStorage _secureStorage;
|
||||
|
||||
|
||||
static const _accessTokenKey = 'access_token';
|
||||
static const _tokenExpiryKey = 'token_expiry';
|
||||
|
||||
@@ -18,35 +18,43 @@ class AuthRepository {
|
||||
|
||||
Future<List<User>> login(String customerNo, String password) async {
|
||||
// Create credentials and call service
|
||||
final credentials = AuthCredentials(customerNo: customerNo, password: password);
|
||||
final credentials =
|
||||
AuthCredentials(customerNo: customerNo, password: password);
|
||||
final authToken = await _authService.login(credentials);
|
||||
|
||||
|
||||
// Save token securely
|
||||
await _saveAuthToken(authToken);
|
||||
|
||||
|
||||
// Get and save user profile
|
||||
final users = await _userService.getUserDetails();
|
||||
return users;
|
||||
}
|
||||
|
||||
|
||||
Future<bool> isLoggedIn() async {
|
||||
final token = await _getAuthToken();
|
||||
return token != null && !token.isExpired;
|
||||
}
|
||||
|
||||
|
||||
Future<String?> getAccessToken() async {
|
||||
final token = await _getAuthToken();
|
||||
if (token == null) return null;
|
||||
|
||||
|
||||
return token.accessToken;
|
||||
}
|
||||
|
||||
|
||||
// Private helper methods
|
||||
Future<void> _saveAuthToken(AuthToken token) async {
|
||||
await _secureStorage.write(_accessTokenKey, token.accessToken);
|
||||
await _secureStorage.write(_tokenExpiryKey, token.expiresAt.toIso8601String());
|
||||
await _secureStorage.write(
|
||||
_tokenExpiryKey, token.expiresAt.toIso8601String());
|
||||
}
|
||||
|
||||
|
||||
Future<void> clearAuthTokens() async {
|
||||
await _secureStorage.deleteAll();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Future<AuthToken?> _getAuthToken() async {
|
||||
final accessToken = await _secureStorage.read(_accessTokenKey);
|
||||
final expiryString = await _secureStorage.read(_tokenExpiryKey);
|
||||
@@ -59,4 +67,4 @@ class AuthRepository {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,12 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:kmobile/data/models/transaction.dart';
|
||||
|
||||
abstract class TransactionRepository {
|
||||
Future<List<Transaction>> fetchTransactions(String accountNo);
|
||||
Future<List<Transaction>> fetchTransactions(String accountNo,
|
||||
{DateTime? fromDate, DateTime? toDate});
|
||||
}
|
||||
|
||||
class TransactionRepositoryImpl implements TransactionRepository {
|
||||
@@ -10,9 +14,23 @@ class TransactionRepositoryImpl implements TransactionRepository {
|
||||
TransactionRepositoryImpl(this._dio);
|
||||
|
||||
@override
|
||||
Future<List<Transaction>> fetchTransactions(String accountNo) async {
|
||||
Future<List<Transaction>> fetchTransactions(String accountNo,
|
||||
{DateTime? fromDate, DateTime? toDate}) async {
|
||||
final queryParameters = <String, String>{};
|
||||
|
||||
final resp = await _dio.get('/api/transactions/account/$accountNo');
|
||||
if (fromDate != null) {
|
||||
queryParameters['fromDate'] = DateFormat('ddMMyyyy').format(fromDate);
|
||||
}
|
||||
if (toDate != null) {
|
||||
queryParameters['toDate'] = DateFormat('ddMMyyyy').format(toDate);
|
||||
}
|
||||
|
||||
log('query params below');
|
||||
log(queryParameters.toString());
|
||||
final resp = await _dio.get(
|
||||
'/api/transactions/account/$accountNo',
|
||||
queryParameters: queryParameters.isNotEmpty ? queryParameters : null,
|
||||
);
|
||||
|
||||
if (resp.statusCode != 200) {
|
||||
throw Exception(
|
||||
@@ -25,4 +43,4 @@ class TransactionRepositoryImpl implements TransactionRepository {
|
||||
.map((e) => Transaction.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
|
||||
abstract class TransferRepository {
|
||||
Future<TransferResponse> transfer(Transfer transfer);
|
||||
}
|
||||
@@ -25,4 +24,4 @@ class TransferRepositoryImpl implements TransferRepository {
|
||||
|
||||
return TransferResponse.fromJson(resp.data as Map<String, dynamic>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,6 @@
|
||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||
import 'package:kmobile/api/services/neft_service.dart';
|
||||
import 'package:kmobile/api/services/imps_service.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
@@ -5,20 +8,20 @@ import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/api/services/user_service.dart';
|
||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||
import '../api/services/auth_service.dart';
|
||||
import '../api/interceptors/auth_interceptor.dart';
|
||||
import '../data/repositories/auth_repository.dart';
|
||||
import '../features/auth/controllers/auth_cubit.dart';
|
||||
import '../security/secure_storage.dart';
|
||||
|
||||
|
||||
final getIt = GetIt.instance;
|
||||
|
||||
Future<void> setupDependencies() async {
|
||||
|
||||
//getIt.registerLazySingleton<ThemeController>(() => ThemeController());
|
||||
//getIt.registerLazySingleton<ThemeModeController>(() => ThemeModeController());
|
||||
getIt.registerSingleton<ThemeCubit>( ThemeCubit());
|
||||
getIt.registerSingleton<ThemeCubit>(ThemeCubit());
|
||||
getIt.registerSingleton<ThemeModeCubit>(ThemeModeCubit());
|
||||
|
||||
// Register Dio client
|
||||
getIt.registerSingleton<Dio>(_createDioClient());
|
||||
@@ -42,6 +45,9 @@ Future<void> setupDependencies() async {
|
||||
|
||||
getIt.registerSingleton<PaymentService>(PaymentService(getIt<Dio>()));
|
||||
getIt.registerSingleton<BeneficiaryService>(BeneficiaryService(getIt<Dio>()));
|
||||
getIt.registerSingleton<NeftService>(NeftService(getIt<Dio>()));
|
||||
getIt.registerSingleton<RtgsService>(RtgsService(getIt<Dio>()));
|
||||
getIt.registerSingleton<ImpsService>(ImpsService(getIt<Dio>()));
|
||||
|
||||
// Add auth interceptor after repository is available
|
||||
getIt<Dio>().interceptors.add(
|
||||
@@ -51,17 +57,17 @@ Future<void> setupDependencies() async {
|
||||
// Register controllers/cubits
|
||||
getIt.registerFactory<AuthCubit>(
|
||||
() => AuthCubit(getIt<AuthRepository>(), getIt<UserService>()));
|
||||
|
||||
}
|
||||
|
||||
Dio _createDioClient() {
|
||||
final dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl:
|
||||
//'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
||||
'http://localhost:8081',
|
||||
// 'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
||||
//'http://localhost:8081',
|
||||
'http://localhost:8082',
|
||||
connectTimeout: const Duration(seconds: 5),
|
||||
receiveTimeout: const Duration(seconds: 3),
|
||||
receiveTimeout: const Duration(seconds: 10),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
|
@@ -4,7 +4,7 @@ class Account {
|
||||
final String accountType;
|
||||
final double balance;
|
||||
final String currency;
|
||||
|
||||
|
||||
Account({
|
||||
required this.id,
|
||||
required this.accountNumber,
|
||||
@@ -12,4 +12,4 @@ class Account {
|
||||
required this.balance,
|
||||
required this.currency,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/data/models/user.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class AccountInfoScreen extends StatefulWidget {
|
||||
@@ -32,35 +30,9 @@ class _AccountInfoScreen extends State<AccountInfoScreen> {
|
||||
int selectedIndex = widget.selectedIndex;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).accountInfo,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
title: Text(AppLocalizations.of(context)
|
||||
.accountInfo
|
||||
.replaceFirst(RegExp('\n'), '')),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -70,7 +42,6 @@ class _AccountInfoScreen extends State<AccountInfoScreen> {
|
||||
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14),
|
||||
),
|
||||
|
||||
/// Dropdown to change account
|
||||
DropdownButton<User>(
|
||||
value: selectedUser,
|
||||
onChanged: (User? newUser) {
|
||||
@@ -88,12 +59,6 @@ class _AccountInfoScreen extends State<AccountInfoScreen> {
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
/*InfoRow(
|
||||
title: AppLocalizations.of(context).accountNumber,
|
||||
value: users[selectedIndex].accountNo ?? 'N/A'),
|
||||
// InfoRow(title: 'Nominee Customer No', value: user.nomineeCustomerNo),
|
||||
// InfoRow(title: 'SMS Service', value: user.smsService),
|
||||
// InfoRow(title: 'Missed Call Service', value: user.missedCallService),*/
|
||||
InfoRow(
|
||||
title: AppLocalizations.of(context).customerNumber,
|
||||
value: selectedUser.cifNumber ?? 'N/A',
|
||||
@@ -136,6 +101,7 @@ class InfoRow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||
@@ -144,16 +110,16 @@ class InfoRow extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(fontSize: 16, color: Colors.black),
|
||||
style: TextStyle(fontSize: 16, color: theme.colorScheme.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@@ -1,15 +1,30 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:kmobile/data/models/transaction.dart';
|
||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'transaction_details_screen.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'dart:html' as html; // Import for web-specific code
|
||||
import 'dart:typed_data';
|
||||
|
||||
class AccountStatementScreen extends StatefulWidget {
|
||||
final String accountNo;
|
||||
const AccountStatementScreen({super.key, required this.accountNo});
|
||||
final String balance;
|
||||
final String accountType;
|
||||
const AccountStatementScreen({
|
||||
super.key,
|
||||
required this.accountNo,
|
||||
required this.balance,
|
||||
required this.accountType,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AccountStatementScreen> createState() => _AccountStatementScreen();
|
||||
@@ -22,6 +37,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
List<Transaction> _transactions = [];
|
||||
final _minAmountController = TextEditingController();
|
||||
final _maxAmountController = TextEditingController();
|
||||
//Future<Map<String, dynamic>?>? accountStatementsFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -36,7 +52,11 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
});
|
||||
try {
|
||||
final repo = getIt<TransactionRepository>();
|
||||
final txs = await repo.fetchTransactions(widget.accountNo);
|
||||
final txs = await repo.fetchTransactions(
|
||||
widget.accountNo,
|
||||
fromDate: fromDate,
|
||||
toDate: toDate,
|
||||
);
|
||||
setState(() => _transactions = txs);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
@@ -109,30 +129,10 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).accountStatement,
|
||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
@@ -144,7 +144,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
Text(
|
||||
"${AppLocalizations.of(context).accountNumber}: ",
|
||||
style: const TextStyle(
|
||||
fontSize: 19,
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
@@ -152,6 +152,19 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"${AppLocalizations.of(context).availableBalance}: ",
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
Text(' ₹ ${widget.balance}',
|
||||
style: const TextStyle(fontSize: 17)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
AppLocalizations.of(context).filters,
|
||||
style: const TextStyle(fontSize: 17),
|
||||
@@ -181,56 +194,29 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _minAmountController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).minAmount,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loadTransactions,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).search,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _maxAmountController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).maxAmount,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loadTransactions,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
child: Icon(
|
||||
Symbols.arrow_forward,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 35),
|
||||
if (!_txLoading && _transactions.isNotEmpty)
|
||||
const SizedBox(height: 15),
|
||||
if (!_txLoading &&
|
||||
_transactions.isNotEmpty &&
|
||||
fromDate == null &&
|
||||
toDate == null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: Text(
|
||||
@@ -238,7 +224,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.grey[700],
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -252,7 +238,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: CircleAvatar(
|
||||
radius: 12,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
title: Shimmer.fromColors(
|
||||
@@ -278,12 +265,13 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
: _transactions.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).noTransactions,
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: Colors.grey[600]),
|
||||
),
|
||||
AppLocalizations.of(context).noTransactions,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
)),
|
||||
)
|
||||
: ListView.builder(
|
||||
: ListView.separated(
|
||||
itemCount: _transactions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final tx = _transactions[index];
|
||||
@@ -292,40 +280,375 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
tx.type == 'CR'
|
||||
? Symbols.call_received
|
||||
: Symbols.call_made,
|
||||
color:
|
||||
tx.type == 'CR' ? Colors.green : Colors.red,
|
||||
color: tx.type == 'CR'
|
||||
? Colors.green
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
tx.name != null
|
||||
? (tx.name!.length > 18
|
||||
? tx.name!.substring(0, 20)
|
||||
: tx.name!)
|
||||
: '',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
tx.date ?? '',
|
||||
style: const TextStyle(fontSize: 15),
|
||||
),
|
||||
subtitle: Text(
|
||||
tx.date ?? '',
|
||||
tx.name != null
|
||||
? (tx.name!.length > 18
|
||||
? tx.name!.substring(0, 22)
|
||||
: tx.name!)
|
||||
: '',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
trailing: Text(
|
||||
"₹${tx.amount}",
|
||||
style: const TextStyle(fontSize: 16),
|
||||
style: const TextStyle(fontSize: 17),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => TransactionDetailsScreen(
|
||||
transaction: tx),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
_exportToPdf();
|
||||
},
|
||||
child: const Icon(Icons.download),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _exportToPdf() async {
|
||||
// Step 1: Check if there are any transactions to export.
|
||||
if (_transactions.isEmpty) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('No transactions to export.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2: Handle storage permissions for Android.
|
||||
/*if (Platform.isAndroid) {
|
||||
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||
if (androidInfo.version.sdkInt < 33) { // Target Android 12 & below
|
||||
final status = await Permission.storage.status;
|
||||
if (status.isDenied) {
|
||||
final result = await Permission.storage.request();
|
||||
if (result.isDenied) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Storage permission is required to save PDF'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Step 3: Load assets for the PDF.
|
||||
// IMPORTANT: The original path 'assets/logos/logo.svg' is incorrect.
|
||||
// I've corrected it to 'assets/images/icon.svg' based on your project structure.
|
||||
String logoSvg = await rootBundle.loadString('assets/images/icon.svg');
|
||||
var rubik = await rootBundle.load("assets/fonts/Rubik-Regular.ttf");
|
||||
|
||||
try {
|
||||
final pdf = pw.Document();
|
||||
pdf.addPage(
|
||||
pw.MultiPage(
|
||||
margin: const pw.EdgeInsets.all(20),
|
||||
build: (pw.Context context) {
|
||||
return [
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.start,
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||
children: [
|
||||
pw.SvgImage(svg: logoSvg, width: 50, height: 50),
|
||||
pw.SizedBox(width: 20),
|
||||
pw.Text(
|
||||
"Account Statement - KCCB",
|
||||
style: pw.TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: pw.FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.SizedBox(height: 20),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text(
|
||||
'Account Number: ${widget.accountNo}',
|
||||
style: pw.TextStyle(font: pw.Font.ttf(rubik), fontSize: 15),
|
||||
),
|
||||
pw.Text(
|
||||
'Account Type: ${widget.accountType}',
|
||||
style: pw.TextStyle(font: pw.Font.ttf(rubik), fontSize: 15),
|
||||
),
|
||||
],
|
||||
),
|
||||
pw.SizedBox(height: 20),
|
||||
// Step 4: Build the table from the _transactions list.
|
||||
pw.Table.fromTextArray(
|
||||
border: pw.TableBorder.all(),
|
||||
headerStyle: pw.TextStyle(fontWeight: pw.FontWeight.bold),
|
||||
headerDecoration: const pw.BoxDecoration(
|
||||
color: PdfColors.grey300,
|
||||
),
|
||||
cellHeight: 30,
|
||||
cellAlignments: {
|
||||
0: pw.Alignment.centerLeft,
|
||||
1: pw.Alignment.centerLeft,
|
||||
2: pw.Alignment.centerRight,
|
||||
3: pw.Alignment.center,
|
||||
},
|
||||
headers: ['Date', 'Description', 'Amount', 'Type'],
|
||||
data: _transactions.map((tx) => [
|
||||
tx.date ?? 'N/A',
|
||||
tx.name ?? 'N/A',
|
||||
'₹${tx.amount}',
|
||||
tx.type ?? 'N/A',
|
||||
]).toList(),
|
||||
),
|
||||
];
|
||||
},
|
||||
footer: (pw.Context context) {
|
||||
return pw.Container(
|
||||
alignment: pw.Alignment.centerRight,
|
||||
margin: const pw.EdgeInsets.only(top: 10),
|
||||
child: pw.Text(
|
||||
'Kangra Central Co-Operative bank Pvt Ltd. ©. All rights reserved.',
|
||||
style: pw.TextStyle(
|
||||
font: pw.Font.ttf(rubik),
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
// Step 5: Save the PDF to the device.
|
||||
Directory? directory = await getDownloadsDirectory();
|
||||
if (directory == null) {
|
||||
throw Exception('Could not access downloads directory');
|
||||
}
|
||||
final String timestamp = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
final file = File('${directory.path}/account_statement_$timestamp.pdf');
|
||||
|
||||
await file.writeAsBytes(await pdf.save());
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('PDF saved to: ${file.path}'),
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Error saving PDF: $e'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
String logoSvg = await rootBundle.loadString('assets/images/kccb_logo.svg'); // Corrected asset path
|
||||
var rubik = await rootBundle.load("assets/fonts/Rubik-Regular.ttf");
|
||||
final pdf = pw.Document();
|
||||
|
||||
pdf.addPage(pw.MultiPage(
|
||||
margin: const pw.EdgeInsets.all(20),
|
||||
build: (pw.Context context) {
|
||||
return [
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.start,
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||
children: [
|
||||
pw.SvgImage(svg: logoSvg, width: 50, height: 50),
|
||||
pw.SizedBox(width: 20),
|
||||
pw.Text('Account Statement - KCCB',
|
||||
style: pw.TextStyle(
|
||||
fontSize: 24, fontWeight: pw.FontWeight.bold)),
|
||||
]),
|
||||
pw.SizedBox(height: 20),
|
||||
pw.Row(
|
||||
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
pw.Text('Account Number: ${widget.accountNo}',
|
||||
style: pw.TextStyle(
|
||||
font: pw.Font.ttf(rubik), fontSize: 15)),
|
||||
pw.Text('Account Type: ${widget.accountType}',
|
||||
style: pw.TextStyle(
|
||||
fontSize: 15,
|
||||
font: pw.Font.ttf(rubik),
|
||||
)),
|
||||
]),
|
||||
pw.SizedBox(height: 20),
|
||||
pw.Table(border: pw.TableBorder.all(), columnWidths: {
|
||||
0: const pw.FractionColumnWidth(0.2),
|
||||
1: const pw.FractionColumnWidth(0.5),
|
||||
2: const pw.FractionColumnWidth(0.15),
|
||||
3: const pw.FractionColumnWidth(0.15),
|
||||
}, children: [
|
||||
pw.TableRow(
|
||||
children: [
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(4),
|
||||
child: pw.Text('Date')),
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(4),
|
||||
child: pw.Text('Description', softWrap: true)),
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(4),
|
||||
child: pw.Text('Amount')),
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(4),
|
||||
child: pw.Text('Balance')),
|
||||
],
|
||||
),
|
||||
..._transactions.map<pw.TableRow>((tx) {
|
||||
return pw.TableRow(children: [
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(10),
|
||||
child: pw.Text(tx.date ?? '',
|
||||
style: pw.TextStyle(
|
||||
fontSize: 12,
|
||||
font: pw.Font.ttf(rubik),
|
||||
))),
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(10),
|
||||
child: pw.Text(tx.name ?? '',
|
||||
style: pw.TextStyle(
|
||||
fontSize: 12, font: pw.Font.ttf(rubik)))),
|
||||
pw.Padding(
|
||||
padding: const pw.EdgeInsets.all(10),
|
||||
child: pw.Text("₹${tx.amount}",
|
||||
style: pw.TextStyle(
|
||||
fontSize: 12,
|
||||
font: pw.Font.ttf(rubik),
|
||||
))),
|
||||
]);
|
||||
}).toList(),
|
||||
])
|
||||
];
|
||||
},
|
||||
footer: (pw.Context context) {
|
||||
return pw.Container(
|
||||
alignment: pw.Alignment.centerRight,
|
||||
margin: const pw.EdgeInsets.only(top: 10),
|
||||
child: pw.Text(
|
||||
'Kangra Central Co-Operative Bank Pvt Ltd. ©. All rights reserved.',
|
||||
style: pw.TextStyle(
|
||||
font: pw.Font.ttf(rubik),
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
);
|
||||
}));
|
||||
|
||||
//Logic For all platforms
|
||||
try {
|
||||
final Uint8List pdfBytes = await pdf.save();
|
||||
final String timestamp = DateTime.now().millisecondsSinceEpoch.toString();
|
||||
final String fileName = 'account_statement_$timestamp.pdf';
|
||||
|
||||
// For Web
|
||||
if (kIsWeb) {
|
||||
final blob = html.Blob([pdfBytes], 'application/pdf');
|
||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||
html.Url.revokeObjectUrl(url);
|
||||
print('Generated PDF Blob URL for web: $url');
|
||||
|
||||
final anchor = html.document.createElement('a') as html.AnchorElement
|
||||
..href = url
|
||||
..style.display = 'none'
|
||||
..download = fileName;
|
||||
|
||||
html.document.body!.children.add(anchor);
|
||||
anchor.click();
|
||||
html.document.body!.children.remove(anchor);
|
||||
|
||||
html.Url.revokeObjectUrl(url);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('PDF download started: $fileName'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// For Android
|
||||
else if (Platform.isAndroid) {
|
||||
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||
if (androidInfo.version.sdkInt < 29) {
|
||||
final status = await Permission.storage.status;
|
||||
if (status.isDenied) {
|
||||
final result = await Permission.storage.request();
|
||||
if (result.isDenied) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Storage permission is required to save PDF'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final directory = Directory('/storage/emulated/0/Download');
|
||||
final file = File('${directory.path}/$fileName');
|
||||
await file.writeAsBytes(pdfBytes);
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('PDF saved to: ${file.path}'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// Add for IOS
|
||||
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Error saving PDF: $e'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildDateBox(String label, DateTime? date) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
border:
|
||||
Border.all(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Row(
|
||||
@@ -335,7 +658,9 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
date != null ? _formatDate(date) : label,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: date != null ? Colors.black : Colors.grey,
|
||||
color: date != null
|
||||
? Theme.of(context).colorScheme.onSurface
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
|
110
lib/features/accounts/screens/transaction_details_screen.dart
Normal file
@@ -0,0 +1,110 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/l10n/app_localizations.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
class TransactionDetailsScreen extends StatelessWidget {
|
||||
final dynamic transaction;
|
||||
|
||||
const TransactionDetailsScreen({super.key, required this.transaction});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isCredit = transaction.type?.toUpperCase() == 'CR';
|
||||
|
||||
return Scaffold(
|
||||
appBar:
|
||||
AppBar(title: Text(AppLocalizations.of(context).transactionDetails)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Amount + icon + Share Button
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"₹ ${transaction.amount}",
|
||||
style: const TextStyle(
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
isCredit ? Symbols.call_received : Symbols.call_made,
|
||||
color: isCredit ? Colors.green : Colors.red,
|
||||
size: 28,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Date centered
|
||||
Text(
|
||||
transaction.date ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: ListView(
|
||||
children: [
|
||||
_buildDetailRow(AppLocalizations.of(context).transactionType,
|
||||
transaction.type ?? ""),
|
||||
_buildDetailRow(AppLocalizations.of(context).transferType,
|
||||
transaction.name.split("/").first ?? ""),
|
||||
if (transaction.name.length > 12) ...[
|
||||
_buildDetailRow(AppLocalizations.of(context).utrNo,
|
||||
transaction.name.split("= ")[1].split(" ")[0] ?? ""),
|
||||
_buildDetailRow(
|
||||
AppLocalizations.of(context).beneficiaryAccountNo,
|
||||
transaction.name.split("A/C ").last ?? "")
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"$label: ",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 17,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,48 +1,27 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'theme_state.dart';
|
||||
import 'package:kmobile/config/theme_type.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'theme_state.dart';
|
||||
|
||||
class ThemeCubit extends Cubit<ThemeState> {
|
||||
ThemeCubit(): super(ThemeViolet()) {
|
||||
ThemeCubit() : super(const ThemeState(themeType: ThemeType.violet)) {
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
Future<void> loadTheme() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final themeIndex = prefs.getInt('theme_type') ?? 0;
|
||||
// final isDark = prefs.getBool('is_dark_mode') ?? false;
|
||||
|
||||
final type = ThemeType.values[themeIndex];
|
||||
switch(type) {
|
||||
case ThemeType.blue:
|
||||
emit(ThemeBlue());
|
||||
case ThemeType.violet:
|
||||
emit(ThemeViolet());
|
||||
default:
|
||||
emit(ThemeViolet());
|
||||
}
|
||||
emit(ThemeState(themeType: type));
|
||||
}
|
||||
|
||||
Future<void> changeTheme(ThemeType type) async {
|
||||
log("Attempting to change theme...");
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('theme_type', type.index);
|
||||
log("Mode Change");
|
||||
print("mode changed");
|
||||
switch(type) {
|
||||
case ThemeType.blue:
|
||||
emit(ThemeBlue());
|
||||
print('blue matched');
|
||||
break;
|
||||
case ThemeType.violet:
|
||||
emit(ThemeViolet());
|
||||
print('violet matched');
|
||||
break;
|
||||
default:
|
||||
emit(ThemeBlue());
|
||||
print('default macthed');
|
||||
}
|
||||
emit(ThemeState(themeType: type));
|
||||
}
|
||||
}
|
||||
|
||||
|
23
lib/features/auth/controllers/theme_mode_cubit.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'theme_mode_state.dart';
|
||||
|
||||
class ThemeModeCubit extends Cubit<ThemeModeState> {
|
||||
ThemeModeCubit() : super(const ThemeModeState(mode: ThemeMode.system)) {
|
||||
loadThemeMode();
|
||||
}
|
||||
|
||||
Future<void> loadThemeMode() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final modeIndex = prefs.getInt('theme_mode') ?? 0; // default system
|
||||
final mode = ThemeMode.values[modeIndex];
|
||||
emit(ThemeModeState(mode: mode));
|
||||
}
|
||||
|
||||
Future<void> changeThemeMode(ThemeMode mode) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('theme_mode', mode.index);
|
||||
emit(ThemeModeState(mode: mode));
|
||||
}
|
||||
}
|
11
lib/features/auth/controllers/theme_mode_state.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ThemeModeState extends Equatable {
|
||||
final ThemeMode mode;
|
||||
|
||||
const ThemeModeState({required this.mode});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [mode];
|
||||
}
|
@@ -1,27 +1,41 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
/*import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/config/theme_type.dart';
|
||||
import 'package:kmobile/config/themes.dart';
|
||||
|
||||
class ThemeState extends Equatable {
|
||||
final ThemeType themeType;
|
||||
|
||||
abstract class ThemeState extends Equatable {
|
||||
getThemeData();
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
const ThemeState({required this.themeType});
|
||||
|
||||
class ThemeBlue extends ThemeState {
|
||||
|
||||
@override
|
||||
getThemeData() {
|
||||
print('returning blue theme');
|
||||
return AppThemes.getLightTheme(ThemeType.blue);
|
||||
ThemeData getThemeData() {
|
||||
return AppThemes.getLightTheme(themeType);
|
||||
}
|
||||
}
|
||||
|
||||
class ThemeViolet extends ThemeState {
|
||||
@override
|
||||
getThemeData() {
|
||||
print('returning violet theme');
|
||||
return AppThemes.getLightTheme(ThemeType.violet);
|
||||
List<Object?> get props => [themeType];
|
||||
}*/
|
||||
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/config/theme_type.dart';
|
||||
import 'package:kmobile/config/themes.dart';
|
||||
class ThemeState extends Equatable {
|
||||
final ThemeType themeType;
|
||||
const ThemeState({required this.themeType});
|
||||
|
||||
ThemeData getLightThemeData() {
|
||||
return AppThemes.getLightTheme(themeType);
|
||||
}
|
||||
|
||||
ThemeData getDarkThemeData() {
|
||||
return AppThemes.getDarkTheme(themeType);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [themeType];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -6,12 +6,12 @@ import 'package:equatable/equatable.dart';
|
||||
class AuthToken extends Equatable {
|
||||
final String accessToken;
|
||||
final DateTime expiresAt;
|
||||
|
||||
|
||||
const AuthToken({
|
||||
required this.accessToken,
|
||||
required this.expiresAt,
|
||||
});
|
||||
|
||||
|
||||
factory AuthToken.fromJson(Map<String, dynamic> json) {
|
||||
return AuthToken(
|
||||
accessToken: json['token'],
|
||||
@@ -29,7 +29,8 @@ class AuthToken extends Equatable {
|
||||
// Pad the payload if necessary
|
||||
String normalized = base64Url.normalize(payload);
|
||||
final payloadMap = json.decode(utf8.decode(base64Url.decode(normalized)));
|
||||
if (payloadMap is! Map<String, dynamic> || !payloadMap.containsKey('exp')) {
|
||||
if (payloadMap is! Map<String, dynamic> ||
|
||||
!payloadMap.containsKey('exp')) {
|
||||
throw Exception('Invalid payload');
|
||||
}
|
||||
final exp = payloadMap['exp'];
|
||||
@@ -40,9 +41,9 @@ class AuthToken extends Equatable {
|
||||
return DateTime.now().add(const Duration(hours: 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
||||
|
||||
|
||||
@override
|
||||
List<Object> get props => [accessToken, expiresAt];
|
||||
}
|
||||
|
@@ -23,23 +23,9 @@ class LoginScreenState extends State<LoginScreen>
|
||||
final _passwordController = TextEditingController();
|
||||
bool _obscurePassword = true;
|
||||
//bool _showWelcome = true;
|
||||
late AnimationController _logoController;
|
||||
late Animation<double> _logoAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_logoController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(seconds: 1),
|
||||
)..repeat(reverse: true);
|
||||
|
||||
_logoAnimation = Tween<double>(begin: 0.2, end: 1).animate(_logoController);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_logoController.dispose();
|
||||
_customerNumberController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
@@ -48,9 +34,9 @@ class LoginScreenState extends State<LoginScreen>
|
||||
void _submitForm() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
context.read<AuthCubit>().login(
|
||||
_customerNumberController.text.trim(),
|
||||
_passwordController.text,
|
||||
);
|
||||
_customerNumberController.text.trim(),
|
||||
_passwordController.text,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +49,7 @@ class LoginScreenState extends State<LoginScreen>
|
||||
if (state is Authenticated) {
|
||||
final storage = getIt<SecureStorage>();
|
||||
final mpin = await storage.read('mpin');
|
||||
if (!context.mounted) return;
|
||||
if (mpin == null) {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
@@ -100,21 +87,17 @@ class LoginScreenState extends State<LoginScreen>
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// 🔁 Animated Blinking Logo
|
||||
FadeTransition(
|
||||
opacity: _logoAnimation,
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 150,
|
||||
height: 150,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Icon(
|
||||
Icons.account_balance,
|
||||
size: 100,
|
||||
color: Theme.of(context).primaryColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 150,
|
||||
height: 150,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Icon(
|
||||
Icons.account_balance,
|
||||
size: 100,
|
||||
color: Theme.of(context).primaryColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Title
|
||||
@@ -133,15 +116,15 @@ class LoginScreenState extends State<LoginScreen>
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).customerNumber,
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
@@ -159,19 +142,18 @@ class LoginScreenState extends State<LoginScreen>
|
||||
controller: _passwordController,
|
||||
obscureText: _obscurePassword,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) =>
|
||||
_submitForm(), // ⌨️ Enter key submits
|
||||
onFieldSubmitted: (_) => _submitForm(),
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).password,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
@@ -202,31 +184,32 @@ class LoginScreenState extends State<LoginScreen>
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: Theme.of(context).primaryColorDark,
|
||||
side: const BorderSide(color: Colors.black, width: 1),
|
||||
side: BorderSide(color: Theme.of(context).colorScheme.outline, width: 1),
|
||||
elevation: 0,
|
||||
),
|
||||
child: state is AuthLoading
|
||||
? const CircularProgressIndicator()
|
||||
: Text(
|
||||
AppLocalizations.of(context).login,
|
||||
style: TextStyle(fontSize: 16),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onPrimaryContainer),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Divider()),
|
||||
const Expanded(child: Divider()),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text(AppLocalizations.of(context).or),
|
||||
),
|
||||
Expanded(child: Divider()),
|
||||
const Expanded(child: Divider()),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -242,10 +225,11 @@ class LoginScreenState extends State<LoginScreen>
|
||||
style: OutlinedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColorLight,
|
||||
foregroundColor: Colors.black,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).register),
|
||||
child: Text(AppLocalizations.of(context).register,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onPrimary),),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -257,227 +241,3 @@ class LoginScreenState extends State<LoginScreen>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/auth/screens/mpin_screen.dart';
|
||||
import 'package:kmobile/security/secure_storage.dart';
|
||||
import '../../../app.dart';
|
||||
import '../controllers/auth_cubit.dart';
|
||||
import '../controllers/auth_state.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
|
||||
@override
|
||||
LoginScreenState createState() => LoginScreenState();
|
||||
}
|
||||
|
||||
class LoginScreenState extends State<LoginScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _customerNumberController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
bool _obscurePassword = true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_customerNumberController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _submitForm() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
context.read<AuthCubit>().login(
|
||||
_customerNumberController.text.trim(),
|
||||
_passwordController.text,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
// appBar: AppBar(title: const Text('Login')),
|
||||
body: BlocConsumer<AuthCubit, AuthState>(
|
||||
listener: (context, state) async {
|
||||
if (state is Authenticated) {
|
||||
final storage = getIt<SecureStorage>();
|
||||
final mpin = await storage.read('mpin');
|
||||
if (mpin == null) {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => MPinScreen(
|
||||
mode: MPinMode.set,
|
||||
onCompleted: (_) {
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const NavigationScaffold()),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
||||
);
|
||||
}
|
||||
} else if (state is AuthError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.message)),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image.asset('assets/images/logo.png', width: 150, height: 150,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Icon(Icons.account_balance,
|
||||
size: 100, color: Colors.blue);
|
||||
}),
|
||||
const SizedBox(height: 16),
|
||||
// Title
|
||||
const Text(
|
||||
'KCCB',
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.blue),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
|
||||
TextFormField(
|
||||
controller: _customerNumberController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Customer Number',
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter your username';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
TextFormField(
|
||||
controller: _passwordController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
// prefixIcon: const Icon(Icons.lock),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_obscurePassword
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_obscurePassword = !_obscurePassword;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.done,
|
||||
obscureText: _obscurePassword,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter your password';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: ElevatedButton(
|
||||
onPressed: state is AuthLoading ? null : _submitForm,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.blueAccent,
|
||||
side: const BorderSide(color: Colors.black, width: 1),
|
||||
elevation: 0),
|
||||
child: state is AuthLoading
|
||||
? const CircularProgressIndicator()
|
||||
: const Text(
|
||||
'Login',
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Divider()),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Text('OR'),
|
||||
),
|
||||
Expanded(child: Divider()),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
|
||||
// Register Button
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: ElevatedButton(
|
||||
//disable until registration is implemented
|
||||
onPressed: null,
|
||||
style: OutlinedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Colors.lightBlue[100],
|
||||
foregroundColor: Colors.black),
|
||||
child: const Text('Register'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@@ -1,12 +1,14 @@
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'dart:math';
|
||||
|
||||
import 'dart:developer';
|
||||
// import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/app.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/security/secure_storage.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
enum MPinMode { enter, set, confirm }
|
||||
|
||||
@@ -26,26 +28,78 @@ class MPinScreen extends StatefulWidget {
|
||||
State<MPinScreen> createState() => _MPinScreenState();
|
||||
}
|
||||
|
||||
class _MPinScreenState extends State<MPinScreen> {
|
||||
class _MPinScreenState extends State<MPinScreen> with TickerProviderStateMixin {
|
||||
List<String> mPin = [];
|
||||
String? errorText;
|
||||
|
||||
// Animation controllers
|
||||
late final AnimationController _bounceController;
|
||||
late final Animation<double> _bounceAnimation;
|
||||
late final AnimationController _shakeController;
|
||||
late final AnimationController _waveController;
|
||||
late final Animation<double> _waveAnimation;
|
||||
|
||||
// State flags for animations
|
||||
bool _isError = false;
|
||||
bool _isSuccess = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Bounce animation for single dot entry
|
||||
_bounceController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
);
|
||||
_bounceAnimation = Tween<double>(begin: 1.0, end: 1.2).animate(
|
||||
CurvedAnimation(
|
||||
parent: _bounceController,
|
||||
curve: Curves.elasticIn,
|
||||
reverseCurve: Curves.elasticOut,
|
||||
),
|
||||
)..addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
_bounceController.reverse();
|
||||
}
|
||||
});
|
||||
|
||||
// Shake animation for error
|
||||
_shakeController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
);
|
||||
|
||||
// Wave animation for success
|
||||
_waveController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 800),
|
||||
);
|
||||
_waveAnimation = Tween<double>(begin: 0, end: 1).animate(
|
||||
CurvedAnimation(parent: _waveController, curve: Curves.easeInOut),
|
||||
);
|
||||
|
||||
if (widget.mode == MPinMode.enter) {
|
||||
_tryBiometricBeforePin();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bounceController.dispose();
|
||||
_shakeController.dispose();
|
||||
_waveController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _tryBiometricBeforePin() async {
|
||||
final storage = getIt<SecureStorage>();
|
||||
final enabled = await storage.read('biometric_enabled');
|
||||
log('biometric_enabled: $enabled');
|
||||
// log('biometric_enabled: $enabled');
|
||||
if (enabled != null && enabled) {
|
||||
final auth = LocalAuthentication();
|
||||
if (await auth.canCheckBiometrics) {
|
||||
final didAuth = await auth.authenticate(
|
||||
// ignore: use_build_context_synchronously
|
||||
localizedReason: AppLocalizations.of(context).authenticateToAccess,
|
||||
options: const AuthenticationOptions(biometricOnly: true),
|
||||
);
|
||||
@@ -61,11 +115,13 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
}
|
||||
|
||||
void addDigit(String digit) {
|
||||
if (_shakeController.isAnimating || _waveController.isAnimating) return;
|
||||
if (mPin.length < 4) {
|
||||
setState(() {
|
||||
mPin.add(digit);
|
||||
errorText = null;
|
||||
});
|
||||
_bounceController.forward(from: 0);
|
||||
if (mPin.length == 4) {
|
||||
_handleComplete();
|
||||
}
|
||||
@@ -73,6 +129,7 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
}
|
||||
|
||||
void deleteDigit() {
|
||||
if (_shakeController.isAnimating || _waveController.isAnimating) return;
|
||||
if (mPin.isNotEmpty) {
|
||||
setState(() {
|
||||
mPin.removeLast();
|
||||
@@ -82,19 +139,36 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
}
|
||||
|
||||
Future<void> _handleComplete() async {
|
||||
if (_shakeController.isAnimating || _waveController.isAnimating) return;
|
||||
|
||||
final pin = mPin.join();
|
||||
final storage = SecureStorage();
|
||||
|
||||
switch (widget.mode) {
|
||||
case MPinMode.enter:
|
||||
final storedPin = await storage.read('mpin');
|
||||
log('storedPin: $storedPin');
|
||||
// log('storedPin: $storedPin');
|
||||
if (storedPin == int.tryParse(pin)) {
|
||||
widget.onCompleted?.call(pin);
|
||||
} else {
|
||||
// Correct PIN
|
||||
setState(() {
|
||||
_isSuccess = true;
|
||||
errorText = null;
|
||||
});
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
_waveController.forward(from: 0).whenComplete(() {
|
||||
widget.onCompleted?.call(pin);
|
||||
});
|
||||
} else {
|
||||
// Incorrect PIN
|
||||
setState(() {
|
||||
_isError = true;
|
||||
errorText = AppLocalizations.of(context).incorrectMPIN;
|
||||
});
|
||||
await _shakeController.forward(from: 0);
|
||||
setState(() {
|
||||
mPin.clear();
|
||||
_isError = false;
|
||||
// Keep error text until next digit is entered
|
||||
});
|
||||
}
|
||||
break;
|
||||
@@ -125,28 +199,81 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
_isError = true;
|
||||
errorText = AppLocalizations.of(context).pinsDoNotMatch;
|
||||
});
|
||||
await _shakeController.forward(from: 0);
|
||||
setState(() {
|
||||
mPin.clear();
|
||||
_isError = false;
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildMPinDots() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(4, (index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
width: 15,
|
||||
height: 15,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: index < mPin.length ? Colors.black : Colors.grey[400],
|
||||
Widget buildMPinDots(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: Listenable.merge(
|
||||
[_bounceController, _shakeController, _waveController]),
|
||||
builder: (context, child) {
|
||||
double shakeOffset = 0;
|
||||
if (_shakeController.isAnimating) {
|
||||
// 4 cycles of sine wave for shake
|
||||
shakeOffset = sin(_shakeController.value * 4 * pi) * 12;
|
||||
}
|
||||
|
||||
return Transform.translate(
|
||||
offset: Offset(shakeOffset, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(4, (index) {
|
||||
final isFilled = index < mPin.length;
|
||||
|
||||
// Bounce animation for single dot
|
||||
final isAnimatingBounce =
|
||||
index == mPin.length - 1 && _bounceController.isAnimating;
|
||||
double bounceScale =
|
||||
isAnimatingBounce ? _bounceAnimation.value : 1.0;
|
||||
|
||||
// Success wave animation
|
||||
double waveScale = 1.0;
|
||||
if (_isSuccess) {
|
||||
final waveDelay = index * 0.15;
|
||||
final waveValue =
|
||||
(_waveAnimation.value - waveDelay).clamp(0.0, 1.0);
|
||||
// Grow and shrink
|
||||
waveScale = 1.0 + sin(waveValue * pi) * 0.4;
|
||||
}
|
||||
|
||||
// Determine dot color
|
||||
Color dotColor;
|
||||
if (_isError) {
|
||||
dotColor = Theme.of(context).colorScheme.error;
|
||||
} else if (_isSuccess) {
|
||||
dotColor = Colors.green.shade600;
|
||||
} else {
|
||||
dotColor = isFilled
|
||||
? Theme.of(context).colorScheme.onSurfaceVariant
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
}
|
||||
|
||||
return Transform.scale(
|
||||
scale: bounceScale * waveScale,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
width: 25,
|
||||
height: 25,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: dotColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,9 +291,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: row.map((key) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.all(1.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
HapticFeedback.lightImpact();
|
||||
if (key == '<') {
|
||||
deleteDigit();
|
||||
} else if (key == 'Enter') {
|
||||
@@ -184,11 +312,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 70,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.grey[200],
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: key == 'Enter'
|
||||
@@ -196,8 +323,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
: Text(
|
||||
key == '<' ? '⌫' : key,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: key == 'Enter' ? Theme.of(context).primaryColor : Colors.black,
|
||||
fontSize: 30,
|
||||
color: key == 'Enter'
|
||||
? Theme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -226,7 +355,7 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
const SizedBox(height: 50),
|
||||
// Logo
|
||||
Image.asset('assets/images/logo.png', height: 100),
|
||||
const SizedBox(height: 20),
|
||||
@@ -234,19 +363,18 @@ class _MPinScreenState extends State<MPinScreen> {
|
||||
getTitle(),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
buildMPinDots(),
|
||||
const Spacer(),
|
||||
buildMPinDots(context),
|
||||
if (errorText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
errorText!,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
buildNumberPad(),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
62
lib/features/auth/screens/splash_screen.dart
Normal file
@@ -0,0 +1,62 @@
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SplashScreen> createState() => _SplashScreenState();
|
||||
}
|
||||
|
||||
class _SplashScreenState extends State<SplashScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/kconnect2.webp',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).kconnect,
|
||||
style: const TextStyle(
|
||||
fontSize: 36,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFFFFFFFF),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
AppLocalizations.of(context).kccBankFull,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
color: Color(0xFFFFFFFF),
|
||||
letterSpacing: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 40,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFFFFFFFF)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,141 +0,0 @@
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
class WelcomeScreen extends StatefulWidget {
|
||||
final VoidCallback onContinue;
|
||||
|
||||
const WelcomeScreen({super.key, required this.onContinue});
|
||||
|
||||
@override
|
||||
State<WelcomeScreen> createState() => _WelcomeScreenState();
|
||||
}
|
||||
|
||||
class _WelcomeScreenState extends State<WelcomeScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Automatically go to logizn after 4 seconds
|
||||
Timer(const Duration(seconds: 4), () {
|
||||
|
||||
widget.onContinue();
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
/// 🔹 Background Image
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/kconnect2.webp',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
||||
/// 🔹 Centered Text Overlay
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).kconnect,
|
||||
style: TextStyle(
|
||||
fontSize: 36,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
letterSpacing: 1.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
AppLocalizations.of(context).kccBankFull,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
letterSpacing: 1.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
/// 🔹 Loading Spinner at Bottom
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(color: Theme.of(context).scaffoldBackgroundColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*import 'package:flutter/material.dart';
|
||||
|
||||
class WelcomeScreen extends StatelessWidget {
|
||||
final VoidCallback onContinue;
|
||||
|
||||
const WelcomeScreen({super.key, required this.onContinue});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Spacer(),
|
||||
const Text(
|
||||
'Welcome to',
|
||||
style: TextStyle(fontSize: 28, color: Colors.black87),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'KCCB',
|
||||
style: TextStyle(
|
||||
fontSize: 42,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.indigo,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 150,
|
||||
height: 150,
|
||||
),
|
||||
const Spacer(),
|
||||
ElevatedButton(
|
||||
onPressed: onContinue,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.indigo,
|
||||
foregroundColor: Colors.white,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 28, vertical: 20),
|
||||
),
|
||||
child: const Text('Proceed to Login'),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
@@ -1,22 +1,20 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:kmobile/data/models/ifsc.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
import 'package:kmobile/data/models/user.dart';
|
||||
import 'beneficiary_result_page.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'beneficiary_result_page.dart';
|
||||
import '../../../di/injection.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||
|
||||
class AddBeneficiaryScreen extends StatefulWidget {
|
||||
final List<User>? users;
|
||||
final int? selectedIndex;
|
||||
final String customerName;
|
||||
|
||||
const AddBeneficiaryScreen({
|
||||
super.key,
|
||||
this.users,
|
||||
this.selectedIndex,
|
||||
required this.customerName,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -25,8 +23,9 @@ class AddBeneficiaryScreen extends StatefulWidget {
|
||||
|
||||
class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
late User selectedUser = (widget.users ?? [])[widget.selectedIndex!];
|
||||
final _accountNumberFieldKey = GlobalKey<FormFieldState>();
|
||||
final _confirmAccountNumberFieldKey = GlobalKey<FormFieldState>();
|
||||
final _ifscFieldKey = GlobalKey<FormFieldState>();
|
||||
final TextEditingController accountNumberController = TextEditingController();
|
||||
final TextEditingController confirmAccountNumberController =
|
||||
TextEditingController();
|
||||
@@ -35,12 +34,12 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
final TextEditingController branchNameController = TextEditingController();
|
||||
final TextEditingController ifscController = TextEditingController();
|
||||
final TextEditingController phoneController = TextEditingController();
|
||||
|
||||
String? _beneficiaryName;
|
||||
final service = getIt<BeneficiaryService>();
|
||||
|
||||
bool _isValidating = false;
|
||||
bool _isBeneficiaryValidated = false;
|
||||
// ignore: unused_field
|
||||
String? _validationError;
|
||||
|
||||
late String accountType;
|
||||
|
||||
@override
|
||||
@@ -48,203 +47,184 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
accountType = AppLocalizations.of(context).savings;
|
||||
accountType = 'Savings';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
ifsc? _ifscData;
|
||||
bool _isLoading = false; //for validateIFSC()
|
||||
|
||||
void _validateIFSC() async {
|
||||
var beneficiaryService = getIt<BeneficiaryService>();
|
||||
final ifsc = ifscController.text.trim().toUpperCase();
|
||||
if (ifsc.isEmpty) return;
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_ifscData = null;
|
||||
});
|
||||
void _validateIFSC() async {
|
||||
var beneficiaryService = getIt<BeneficiaryService>();
|
||||
final ifsc = ifscController.text.trim().toUpperCase();
|
||||
if (ifsc.isEmpty) return;
|
||||
|
||||
final result = await beneficiaryService.validateIFSC(ifsc);
|
||||
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_ifscData = result;
|
||||
});
|
||||
|
||||
if (result == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||
);
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
} else {
|
||||
print("${AppLocalizations.of(context).validIfsc}: ${result.bankName}, ${result.branchName}");
|
||||
bankNameController.text = result.bankName;
|
||||
branchNameController.text = result.branchName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _validateBeneficiary() async {
|
||||
// start spinner / disable button
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
_validationError = null;
|
||||
_isBeneficiaryValidated = false;
|
||||
nameController.text = ''; // clear previous name
|
||||
});
|
||||
|
||||
final String accountNo = accountNumberController.text.trim();
|
||||
final String ifsc = ifscController.text.trim();
|
||||
final String remitter = selectedUser.name ?? '';
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
// Step 1: call validate API -> get refNo
|
||||
final String? refNo = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
|
||||
if (refNo == null || refNo.isEmpty) {
|
||||
setState(() {
|
||||
_validationError = 'Validation request failed. Please check details.';
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
return;
|
||||
if (mounted) {
|
||||
if (result.bankName == '') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||
);
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
} else {
|
||||
bankNameController.text = result.bankName;
|
||||
branchNameController.text = result.branchName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: poll checkValidationStatus for up to 30 seconds
|
||||
const int timeoutSeconds = 30;
|
||||
const int intervalSeconds = 2;
|
||||
int elapsed = 0;
|
||||
String? foundName;
|
||||
void _validateBeneficiary() async {
|
||||
FocusScope.of(context).unfocus();
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
_validationError = null;
|
||||
_isBeneficiaryValidated = false;
|
||||
nameController.text = ''; // clear previous name
|
||||
});
|
||||
|
||||
while (elapsed < timeoutSeconds) {
|
||||
final String? name = await service.checkValidationStatus(refNo);
|
||||
final String accountNo = accountNumberController.text.trim();
|
||||
final String ifsc = ifscController.text.trim();
|
||||
final String remitter = widget.customerName;
|
||||
|
||||
if (name != null && name.trim().isNotEmpty) {
|
||||
foundName = name.trim();
|
||||
break;
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
String beneficiaryName;
|
||||
if (ifsc.toLowerCase().contains('kace')) {
|
||||
beneficiaryName =
|
||||
await service.validateBeneficiaryWithinBank(accountNo);
|
||||
} else {
|
||||
beneficiaryName = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
}
|
||||
|
||||
await Future.delayed(const Duration(seconds: intervalSeconds));
|
||||
elapsed += intervalSeconds;
|
||||
}
|
||||
|
||||
if (foundName != null) {
|
||||
setState(() {
|
||||
nameController.text = foundName!;
|
||||
nameController.text = beneficiaryName;
|
||||
_isBeneficiaryValidated = true;
|
||||
_validationError = null;
|
||||
});
|
||||
} else {
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_validationError = 'Beneficiary not found within timeout.';
|
||||
_validationError = e.toString();
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
}
|
||||
} catch (e, st) {
|
||||
// handle unexpected errors
|
||||
// print or log if you want
|
||||
debugPrint('Error validating beneficiary: $e\n$st');
|
||||
setState(() {
|
||||
_validationError = 'Something went wrong. Please try again.';
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isValidating = false;
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isValidating = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String _selectedAccountType = 'Savings'; // default value
|
||||
|
||||
void validateAndAddBeneficiary() async {
|
||||
// Show spinner and disable UI
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // Prevent dismiss on tap outside
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false, // Disable back button
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
final beneficiary = Beneficiary(
|
||||
accountNo: accountNumberController.text.trim(),
|
||||
accountType: _selectedAccountType,
|
||||
name: nameController.text.trim(),
|
||||
ifscCode: ifscController.text.trim(),
|
||||
);
|
||||
|
||||
var service = getIt<BeneficiaryService>();
|
||||
|
||||
try {
|
||||
await service.sendForValidation(beneficiary);
|
||||
bool isFound = await service.checkIfFound(beneficiary.accountNo);
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context); // Close the spinner
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BeneficiaryResultPage(isSuccess: isFound),
|
||||
),
|
||||
);
|
||||
void validateAndAddBeneficiary() async {
|
||||
// First, validate the form fields (account number, confirm account, ifsc, etc.)
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
Navigator.pop(context); // Close the spinner
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).somethingWentWrong)),
|
||||
|
||||
// Ensure beneficiary is validated before proceeding to TPIN
|
||||
if (!_isBeneficiaryValidated) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.pleaseValidateBeneficiaryDetailsFirst)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the beneficiary object without TPIN for now
|
||||
final beneficiaryWithoutTpin = Beneficiary(
|
||||
accountNo: accountNumberController.text.trim(),
|
||||
accountType: accountType,
|
||||
name: nameController.text.trim(),
|
||||
ifscCode: ifscController.text.trim(),
|
||||
bankName: bankNameController.text.trim(),
|
||||
branchName: branchNameController.text.trim(),
|
||||
);
|
||||
|
||||
// Navigate to TPIN screen
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
// Show loading spinner while processing
|
||||
showDialog(
|
||||
context: pinScreenContext,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext ctx) {
|
||||
// ignore: deprecated_member_use
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// Create a new Beneficiary object with the TPIN
|
||||
final beneficiaryWithTpin = Beneficiary(
|
||||
accountNo: beneficiaryWithoutTpin.accountNo,
|
||||
accountType: beneficiaryWithoutTpin.accountType,
|
||||
name: beneficiaryWithoutTpin.name,
|
||||
ifscCode: beneficiaryWithoutTpin.ifscCode,
|
||||
bankName: beneficiaryWithoutTpin.bankName,
|
||||
branchName: beneficiaryWithoutTpin.branchName,
|
||||
tpin: tpin,
|
||||
);
|
||||
|
||||
try {
|
||||
final isSuccess =
|
||||
await service.sendForValidation(beneficiaryWithTpin);
|
||||
|
||||
if (pinScreenContext.mounted) {
|
||||
Navigator.pop(pinScreenContext); // Close the spinner
|
||||
Navigator.pushReplacement(
|
||||
pinScreenContext,
|
||||
MaterialPageRoute(
|
||||
builder: (ctx) =>
|
||||
BeneficiaryResultPage(isSuccess: isSuccess),
|
||||
),
|
||||
);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
if (pinScreenContext.mounted) {
|
||||
Navigator.pop(pinScreenContext); // Close the spinner
|
||||
ScaffoldMessenger.of(pinScreenContext).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(e.response?.statusCode == 409
|
||||
? 'Beneficiary already exists'
|
||||
: 'Something went Wrong')),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (pinScreenContext.mounted) {
|
||||
Navigator.pop(pinScreenContext); // Close the spinner
|
||||
ScaffoldMessenger.of(pinScreenContext).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
AppLocalizations.of(context).somethingWentWrong)),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).addBeneficiary,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Form(
|
||||
@@ -259,29 +239,25 @@ void validateAndAddBeneficiary() async {
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
key: _accountNumberFieldKey,
|
||||
controller: accountNumberController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(
|
||||
context,
|
||||
).accountNumber,
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
obscureText: true,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onChanged: (value) {
|
||||
nameController.clear();
|
||||
setState(() {
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.length < 10) {
|
||||
return AppLocalizations.of(
|
||||
@@ -294,25 +270,15 @@ void validateAndAddBeneficiary() async {
|
||||
const SizedBox(height: 24),
|
||||
// Confirm Account Number
|
||||
TextFormField(
|
||||
key: _confirmAccountNumberFieldKey,
|
||||
controller: confirmAccountNumberController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(
|
||||
context,
|
||||
).confirmAccountNumber,
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
@@ -323,32 +289,23 @@ void validateAndAddBeneficiary() async {
|
||||
).reenterAccountNumber;
|
||||
}
|
||||
if (value != accountNumberController.text) {
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).accountMismatch;
|
||||
return AppLocalizations.of(context,).accountMismatch;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 IFSC Code Field
|
||||
TextFormField(
|
||||
key: _ifscFieldKey,
|
||||
controller: ifscController,
|
||||
maxLength: 11,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(11),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).ifscCode,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
textCapitalization: TextCapitalization.characters,
|
||||
textInputAction: TextInputAction.next,
|
||||
@@ -377,7 +334,6 @@ void validateAndAddBeneficiary() async {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 Bank Name (Disabled)
|
||||
TextFormField(
|
||||
@@ -387,20 +343,8 @@ void validateAndAddBeneficiary() async {
|
||||
labelText: AppLocalizations.of(context).bankName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor, // disabled color
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 Branch Name (Disabled)
|
||||
TextFormField(
|
||||
@@ -410,73 +354,72 @@ void validateAndAddBeneficiary() async {
|
||||
labelText: AppLocalizations.of(context).branchName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
if (_isBeneficiaryValidated)
|
||||
Column(
|
||||
children: [
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: nameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: _isBeneficiaryValidated
|
||||
? const Icon(
|
||||
Symbols.verified,
|
||||
size: 25,
|
||||
fill: 1,
|
||||
)
|
||||
: null,
|
||||
suffixIconColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
labelText: AppLocalizations.of(context)
|
||||
.beneficiaryName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) => value == null ||
|
||||
value.isEmpty
|
||||
? AppLocalizations.of(context).nameRequired
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!_isBeneficiaryValidated)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isValidating
|
||||
? null
|
||||
: () {
|
||||
final isAccountValid =
|
||||
_accountNumberFieldKey.currentState!.validate();
|
||||
final isConfirmAccountValid =
|
||||
_confirmAccountNumberFieldKey.currentState!.validate();
|
||||
final isIfscValid = _ifscFieldKey.currentState!.validate();
|
||||
|
||||
if (isAccountValid && isConfirmAccountValid && isIfscValid) {
|
||||
_validateBeneficiary();
|
||||
}
|
||||
},
|
||||
|
||||
child: _isValidating
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2),
|
||||
)
|
||||
: Text(AppLocalizations.of(context)
|
||||
.validateBeneficiary),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
//Validate Beneficiary Name
|
||||
if (!_isBeneficiaryValidated)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isValidating
|
||||
? null
|
||||
: () {
|
||||
if (
|
||||
confirmAccountNumberController.text ==
|
||||
accountNumberController.text) {
|
||||
_validateBeneficiary();
|
||||
} else {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Please enter a valid and matching account number.';
|
||||
});
|
||||
}
|
||||
},
|
||||
child: _isValidating
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Text('Validate Beneficiary'),
|
||||
),
|
||||
),
|
||||
),
|
||||
//Beneficiary Name (Disabled)
|
||||
TextFormField(
|
||||
controller: nameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).beneficiaryName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? AppLocalizations.of(context).nameRequired
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 Account Type Dropdown
|
||||
DropdownButtonFormField<String>(
|
||||
value: accountType,
|
||||
@@ -484,30 +427,18 @@ if (!_isBeneficiaryValidated)
|
||||
labelText: AppLocalizations.of(context).accountType,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
items:
|
||||
[
|
||||
AppLocalizations.of(context).savings,
|
||||
AppLocalizations.of(context).current,
|
||||
]
|
||||
.map(
|
||||
(type) => DropdownMenuItem(
|
||||
value: type,
|
||||
child: Text(type),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
items: [
|
||||
'Savings',
|
||||
'Current',
|
||||
]
|
||||
.map(
|
||||
(type) => DropdownMenuItem(
|
||||
value: type,
|
||||
child: Text(type),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
accountType = value!;
|
||||
@@ -524,23 +455,12 @@ if (!_isBeneficiaryValidated)
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.done,
|
||||
validator: (value) =>
|
||||
value == null || value.length != 10
|
||||
? AppLocalizations.of(context).enterValidPhone
|
||||
: null,
|
||||
? AppLocalizations.of(context).enterValidPhone
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 35),
|
||||
],
|
||||
@@ -549,19 +469,22 @@ if (!_isBeneficiaryValidated)
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: SizedBox(
|
||||
width: 250,
|
||||
child: ElevatedButton(
|
||||
onPressed:
|
||||
validateAndAddBeneficiary,
|
||||
onPressed: validateAndAddBeneficiary,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primaryContainer,
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onPrimaryContainer),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).validateAndAdd,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).validateAndAdd),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@@ -0,0 +1,163 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/widgets/bank_logos.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class BeneficiaryDetailsScreen extends StatelessWidget {
|
||||
final Beneficiary beneficiary;
|
||||
|
||||
BeneficiaryDetailsScreen({super.key, required this.beneficiary});
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
|
||||
void _deleteBeneficiary(BuildContext context) async {
|
||||
try {
|
||||
await service.deleteBeneficiary(beneficiary.accountNo);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
_showSuccessDialog(context);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to delete beneficiary: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _showSuccessDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Success'),
|
||||
content: const Text('Beneficiary deleted successfully.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteConfirmationDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Delete Beneficiary'),
|
||||
content:
|
||||
const Text('Are you sure you want to delete this beneficiary?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () {
|
||||
//Navigator.of(context).pop();
|
||||
_deleteBeneficiary(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context).beneficiarydetails),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Colors.transparent,
|
||||
child: getBankLogo(beneficiary.bankName, context),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
beneficiary.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_buildDetailRow('${AppLocalizations.of(context).bankName} ',
|
||||
beneficiary.bankName ?? 'N/A'),
|
||||
_buildDetailRow('${AppLocalizations.of(context).accountNumber} ',
|
||||
beneficiary.accountNo),
|
||||
_buildDetailRow('${AppLocalizations.of(context).accountType} ',
|
||||
beneficiary.accountType),
|
||||
_buildDetailRow('${AppLocalizations.of(context).ifscCode} ',
|
||||
beneficiary.ifscCode),
|
||||
_buildDetailRow('${AppLocalizations.of(context).branchName} ',
|
||||
beneficiary.branchName ?? 'N/A'),
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
// ElevatedButton.icon(
|
||||
// onPressed: () {
|
||||
// // Set Transaction Limit for this beneficiary
|
||||
// },
|
||||
// icon: const Icon(Icons.currency_rupee),
|
||||
// label: const Text('Set Limit'),
|
||||
// ),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
// Delete beneficiary option
|
||||
_showDeleteConfirmationDialog(context);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
label: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(label, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(width: 16),
|
||||
Flexible(
|
||||
child: Text(
|
||||
value,
|
||||
textAlign: TextAlign.end,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -35,8 +35,8 @@ class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final successAnimation = 'assets/animations/done.json';
|
||||
final errorAnimation = 'assets/animations/error.json';
|
||||
const successAnimation = 'assets/animations/done.json';
|
||||
const errorAnimation = 'assets/animations/error.json';
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: widget.isSuccess ? Colors.green[50] : Colors.red[50],
|
||||
@@ -66,34 +66,35 @@ class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 20, // keep it slightly above the very bottom
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: SizedBox(
|
||||
height: 56, // larger button height
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement( // ensures back goes to ScaffoldScreen
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NavigationScaffold(),
|
||||
Positioned(
|
||||
bottom: 20, // keep it slightly above the very bottom
|
||||
left: 16,
|
||||
right: 16,
|
||||
child: SizedBox(
|
||||
height: 56, // larger button height
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pushReplacement(
|
||||
// ensures back goes to ScaffoldScreen
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NavigationScaffold(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).done,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onPrimaryContainer), // slightly bigger text
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).done,
|
||||
style: const TextStyle(fontSize: 18), // slightly bigger text
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.isSuccess)
|
||||
Align(
|
||||
alignment: Alignment.topCenter,
|
||||
@@ -112,4 +113,4 @@ Positioned(
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||
import '../../../data/models/user.dart';
|
||||
import 'package:kmobile/features/beneficiaries/screens/beneficiary_details_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../../di/injection.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
//import 'package:kmobile/data/models/user.dart';
|
||||
import 'package:kmobile/widgets/bank_logos.dart';
|
||||
|
||||
class ManageBeneficiariesScreen extends StatefulWidget {
|
||||
// final List<User> users;
|
||||
// final int selectedIndex;
|
||||
|
||||
const ManageBeneficiariesScreen({super.key});
|
||||
final String customerName;
|
||||
const ManageBeneficiariesScreen({super.key, required this.customerName});
|
||||
|
||||
@override
|
||||
State<ManageBeneficiariesScreen> createState() =>
|
||||
@@ -21,12 +19,8 @@ class ManageBeneficiariesScreen extends StatefulWidget {
|
||||
|
||||
class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
var service = getIt<BeneficiaryService>();
|
||||
// late User selectedUser = widget.users[widget.selectedIndex];
|
||||
//final BeneficiaryService _service = BeneficiaryService();
|
||||
bool _isLoading = true;
|
||||
int selectedAccountIndex = 0;
|
||||
List<Beneficiary> _beneficiaries = [];
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -37,7 +31,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
Future<void> _loadBeneficiaries() async {
|
||||
final data = await service.fetchBeneficiaryList();
|
||||
setState(() {
|
||||
_beneficiaries = data ;
|
||||
_beneficiaries = data;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -70,7 +64,8 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
|
||||
Widget _buildBeneficiaryList() {
|
||||
if (_beneficiaries.isEmpty) {
|
||||
return Center(child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
return Center(
|
||||
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: _beneficiaries.length,
|
||||
@@ -79,16 +74,29 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
||||
child: Text(
|
||||
item.name.isNotEmpty
|
||||
? item.name[0].toUpperCase()
|
||||
: '?',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
child: getBankLogo(item.bankName, context),
|
||||
),
|
||||
title: Text(item.name ?? 'Unknown'),
|
||||
subtitle: Text(item.accountNo ?? 'No account number'),
|
||||
title: Text(item.name),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.accountNo),
|
||||
if (item.bankName != null && item.bankName!.isNotEmpty)
|
||||
Text(
|
||||
item.bankName!,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BeneficiaryDetailsScreen(beneficiary: item),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -96,6 +104,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String customerName = widget.customerName;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context).beneficiaries),
|
||||
@@ -108,16 +117,15 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AddBeneficiaryScreen(),
|
||||
builder: (context) =>
|
||||
AddBeneficiaryScreen(customerName: customerName),
|
||||
),
|
||||
);
|
||||
},
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: Theme.of(context).primaryColor,
|
||||
elevation: 5,
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
class BlockCardScreen extends StatefulWidget {
|
||||
const BlockCardScreen({super.key});
|
||||
@@ -56,32 +54,12 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).blockCard,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
@@ -94,14 +72,14 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
controller: _cardController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).cardNumber,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -119,14 +97,14 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
controller: _cvvController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).cvv,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -146,15 +124,15 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
onTap: _pickExpiryDate,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).expiryDate,
|
||||
suffixIcon: Icon(Icons.calendar_today),
|
||||
border: OutlineInputBorder(),
|
||||
suffixIcon: const Icon(Icons.calendar_today),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -170,15 +148,15 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
controller: _phoneController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).phone,
|
||||
prefixIcon: Icon(Icons.phone),
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -199,7 +177,8 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).block),
|
||||
),
|
||||
|
164
lib/features/card/screens/card_details_screen.dart
Normal file
@@ -0,0 +1,164 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CardDetailsScreen extends StatelessWidget {
|
||||
const CardDetailsScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("My Cards"),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: ListView(
|
||||
children: const [
|
||||
CardTile(
|
||||
cardNumber: "**** **** **** 1234",
|
||||
cardNetwork: "VISA",
|
||||
cardType: "Debit Card",
|
||||
validFrom: "01/22",
|
||||
validTo: "01/27",
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
CardTile(
|
||||
cardNumber: "**** **** **** 5678",
|
||||
cardNetwork: "Mastercard",
|
||||
cardType: "Debit Card",
|
||||
validFrom: "07/21",
|
||||
validTo: "07/26",
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CardTile extends StatelessWidget {
|
||||
final String cardNumber;
|
||||
final String cardNetwork;
|
||||
final String cardType;
|
||||
final String validFrom;
|
||||
final String validTo;
|
||||
|
||||
const CardTile({
|
||||
super.key,
|
||||
required this.cardNumber,
|
||||
required this.cardNetwork,
|
||||
required this.cardType,
|
||||
required this.validFrom,
|
||||
required this.validTo,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
gradient: const LinearGradient(
|
||||
colors: [Colors.blue, Colors.indigo],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
blurRadius: 8,
|
||||
spreadRadius: 2,
|
||||
offset: Offset(2, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Top row: Logo + Bank name
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
"Kangra Central Co-operative Bank",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Card number (masked)
|
||||
Text(
|
||||
cardNumber,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 22,
|
||||
letterSpacing: 3,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Validity
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("VALID FROM",
|
||||
style: TextStyle(color: Colors.white70, fontSize: 10)),
|
||||
Text(
|
||||
validFrom,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("VALID UPTO",
|
||||
style: TextStyle(color: Colors.white70, fontSize: 10)),
|
||||
Text(
|
||||
validTo,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
cardNetwork,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
cardType,
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
// ignore_for_file: unused_import
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/features/card/screens/block_card_screen.dart';
|
||||
import 'package:kmobile/features/card/screens/card_details_screen.dart';
|
||||
import 'package:kmobile/features/card/screens/card_pin_change_details_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
@@ -20,24 +22,8 @@ class _CardManagementScreen extends State<CardManagementScreen> {
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text(
|
||||
AppLocalizations.of(context).cardManagement,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
@@ -51,12 +37,12 @@ class _CardManagementScreen extends State<CardManagementScreen> {
|
||||
icon: Symbols.remove_moderator,
|
||||
label: AppLocalizations.of(context).blockUnblockCard,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const BlockCardScreen(),
|
||||
),
|
||||
);
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => const BlockCardScreen(),
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
@@ -73,6 +59,19 @@ class _CardManagementScreen extends State<CardManagementScreen> {
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
CardManagementTile(
|
||||
icon: Symbols.payment_card,
|
||||
label: AppLocalizations.of(context).viewCardDeatils,
|
||||
onTap: () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => const CardDetailsScreen(),
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:kmobile/features/card/screens/card_pin_set_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class CardPinChangeDetailsScreen extends StatefulWidget {
|
||||
@@ -46,32 +44,12 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).cardDetails,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
@@ -84,14 +62,14 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
controller: _cardController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).cardNumber,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -109,14 +87,14 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
controller: _cvvController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).cvv,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -136,15 +114,15 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
onTap: _pickExpiryDate,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).expiryDate,
|
||||
suffixIcon: Icon(Icons.calendar_today),
|
||||
border: OutlineInputBorder(),
|
||||
suffixIcon: const Icon(Icons.calendar_today),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -160,15 +138,15 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
controller: _phoneController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).phone,
|
||||
prefixIcon: Icon(Icons.phone),
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -189,7 +167,8 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).next),
|
||||
),
|
||||
|
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class CardPinSetScreen extends StatefulWidget {
|
||||
@@ -46,32 +44,12 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).cardPin,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -84,14 +62,14 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).enterNewPin,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -113,14 +91,14 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).enterAgain,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -144,7 +122,8 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).submit),
|
||||
),
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
@@ -16,32 +15,12 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).chequeManagement,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/data/models/user.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class CustomerInfoScreen extends StatefulWidget {
|
||||
@@ -16,33 +15,14 @@ class _CustomerInfoScreenState extends State<CustomerInfoScreen> {
|
||||
late final User user = widget.user;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).kMobile,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
AppLocalizations.of(context)
|
||||
.customerInfo
|
||||
.replaceFirst(RegExp('\n'), ''),
|
||||
),
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 100,
|
||||
height: 100,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
@@ -54,7 +34,6 @@ class _CustomerInfoScreenState extends State<CustomerInfoScreen> {
|
||||
children: [
|
||||
const SizedBox(height: 30),
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 50,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
@@ -67,18 +46,20 @@ class _CustomerInfoScreenState extends State<CustomerInfoScreen> {
|
||||
padding: const EdgeInsets.only(top: 10.0),
|
||||
child: Text(
|
||||
user.name ?? '',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
color: theme.colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${AppLocalizations.of(context).cif}: ${user.cifNumber ?? 'N/A'}',
|
||||
style: const TextStyle(fontSize: 16, color: Colors.grey),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: theme.colorScheme.onSurfaceVariant),
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
const SizedBox(height: 30),
|
||||
InfoField(
|
||||
label: AppLocalizations.of(context).activeAccounts,
|
||||
value: user.activeAccounts?.toString() ?? '6',
|
||||
@@ -89,8 +70,7 @@ class _CustomerInfoScreenState extends State<CustomerInfoScreen> {
|
||||
),
|
||||
InfoField(
|
||||
label: AppLocalizations.of(context).dateOfBirth,
|
||||
value:
|
||||
(user.dateOfBirth != null &&
|
||||
value: (user.dateOfBirth != null &&
|
||||
user.dateOfBirth!.length == 8)
|
||||
? '${user.dateOfBirth!.substring(0, 2)}-${user.dateOfBirth!.substring(2, 4)}-${user.dateOfBirth!.substring(4, 8)}'
|
||||
: 'N/A',
|
||||
@@ -125,6 +105,7 @@ class InfoField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||
@@ -133,16 +114,16 @@ class InfoField extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(fontSize: 16, color: Colors.black),
|
||||
style: TextStyle(fontSize: 16, color: theme.colorScheme.onSurface),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@@ -6,12 +6,13 @@ import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||
import 'package:kmobile/di/injection.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/accounts/screens/transaction_details_screen.dart';
|
||||
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
|
||||
import 'package:kmobile/features/auth/controllers/auth_state.dart';
|
||||
import 'package:kmobile/features/customer_info/screens/customer_info_screen.dart';
|
||||
import 'package:kmobile/features/beneficiaries/screens/manage_beneficiaries_screen.dart';
|
||||
import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_screen.dart';
|
||||
import 'package:kmobile/features/profile/profile_screen.dart';
|
||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
||||
import 'package:kmobile/security/secure_storage.dart';
|
||||
@@ -80,8 +81,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
// Call your AuthCubit or repository to refresh user/accounts data
|
||||
await context.read<AuthCubit>().refreshUserData();
|
||||
} catch (e) {
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
/*const*/ SnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).failedToRefresh),
|
||||
),
|
||||
);
|
||||
@@ -92,10 +96,12 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
}
|
||||
|
||||
Widget _buildBalanceShimmer() {
|
||||
final theme = Theme.of(context);
|
||||
return Shimmer.fromColors(
|
||||
baseColor: Theme.of(context).dialogBackgroundColor,
|
||||
highlightColor: Theme.of(context).dialogBackgroundColor,
|
||||
child: Container(width: 100, height: 32, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
baseColor: theme.colorScheme.primary,
|
||||
highlightColor: theme.colorScheme.onPrimary,
|
||||
child: Container(
|
||||
width: 200, height: 42, color: theme.scaffoldBackgroundColor),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,6 +170,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
onPressed: () async {
|
||||
final auth = LocalAuthentication();
|
||||
final canCheck = await auth.canCheckBiometrics;
|
||||
if (!mounted) return;
|
||||
bool ok = false;
|
||||
if (canCheck) {
|
||||
ok = await auth.authenticate(
|
||||
@@ -174,6 +181,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
await storage.write('biometric_enabled', 'true');
|
||||
}
|
||||
await storage.write('biometric_prompt_shown', 'true');
|
||||
if (!mounted) return;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(AppLocalizations.of(context).enable),
|
||||
@@ -185,6 +193,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return BlocListener<AuthCubit, AuthState>(
|
||||
listener: (context, state) async {
|
||||
if (state is Authenticated && !_biometricPromptShown) {
|
||||
@@ -197,15 +206,15 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
backgroundColor: theme.scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor:Theme.of(context).scaffoldBackgroundColor,
|
||||
backgroundColor: theme.scaffoldBackgroundColor,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text(
|
||||
AppLocalizations.of(context).kconnect,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
@@ -263,10 +272,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Text(
|
||||
"${AppLocalizations.of(context).hi} $firstName",
|
||||
style: GoogleFonts.montserrat().copyWith(
|
||||
fontSize: 25,
|
||||
color: Theme.of(context).primaryColor,
|
||||
"${AppLocalizations.of(context).hi} $firstName!",
|
||||
style: GoogleFonts.baumans().copyWith(
|
||||
fontSize: 20,
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
@@ -280,7 +289,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).primaryColor,
|
||||
color: Color(0xFF01A04C),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
@@ -289,21 +298,22 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"${AppLocalizations.of(context).accountNumber}: ",
|
||||
"${getFullAccountType(currAccount.accountType)}: ",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 12,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
DropdownButton<int>(
|
||||
value: selectedAccountIndex,
|
||||
dropdownColor: Theme.of(context).primaryColor,
|
||||
dropdownColor: theme.colorScheme.primary,
|
||||
underline: const SizedBox(),
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
iconEnabledColor:Theme.of(context).dialogBackgroundColor,
|
||||
iconEnabledColor: theme.colorScheme.onPrimary,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 14,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 18,
|
||||
),
|
||||
items: List.generate(users.length, (index) {
|
||||
return DropdownMenuItem<int>(
|
||||
@@ -311,8 +321,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
child: Text(
|
||||
users[index].accountNo ?? 'N/A',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 14,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -351,13 +362,13 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
Icons.refresh,
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
: Icon(
|
||||
Symbols.refresh,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
),
|
||||
onPressed: isRefreshing
|
||||
? null
|
||||
@@ -366,21 +377,14 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
getFullAccountType(currAccount.accountType),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"₹ ",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -391,9 +395,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
isVisible
|
||||
? currAccount.currentBalance ??
|
||||
'0.00'
|
||||
: '********',
|
||||
: '*****',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: theme.colorScheme.onPrimary,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -419,11 +423,15 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Icon(
|
||||
isVisible
|
||||
? Symbols.visibility_lock
|
||||
: Symbols.visibility,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Icon(
|
||||
isVisible
|
||||
? Symbols.visibility_lock
|
||||
: Symbols.visibility,
|
||||
color: theme.scaffoldBackgroundColor,
|
||||
weight: 800,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -473,21 +481,26 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildQuickLink(Symbols.send_money,
|
||||
AppLocalizations.of(context).fundTransfer, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FundTransferScreen(
|
||||
creditAccountNo:
|
||||
users[selectedAccountIndex]
|
||||
.accountNo!,
|
||||
remitterName:
|
||||
users[selectedAccountIndex]
|
||||
.name!)));
|
||||
}, disable: false),
|
||||
_buildQuickLink(
|
||||
Symbols.send_money,
|
||||
AppLocalizations.of(context).fundTransfer,
|
||||
Symbols.server_person,
|
||||
AppLocalizations.of(context).accountInfo,
|
||||
() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const FundTransferBeneficiaryScreen()));
|
||||
}, disable: true),
|
||||
_buildQuickLink(Symbols.server_person,
|
||||
AppLocalizations.of(context).accountInfo, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AccountInfoScreen(
|
||||
users: users,
|
||||
selectedIndex: selectedAccountIndex,
|
||||
@@ -496,39 +509,46 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildQuickLink(
|
||||
Symbols.receipt_long,
|
||||
AppLocalizations.of(context).accountStatement,
|
||||
() {
|
||||
Navigator.push(
|
||||
_buildQuickLink(Symbols.receipt_long,
|
||||
AppLocalizations.of(context).accountStatement,
|
||||
() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AccountStatementScreen(
|
||||
accountNo: users[selectedAccountIndex]
|
||||
.accountNo!,
|
||||
)));
|
||||
}),
|
||||
_buildQuickLink(Symbols.checkbook,
|
||||
AppLocalizations.of(context).handleCheque, () {},
|
||||
disable: true),
|
||||
_buildQuickLink(Icons.group,
|
||||
AppLocalizations.of(context).manageBeneficiary, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const ManageBeneficiariesScreen()));
|
||||
}, disable: false),
|
||||
_buildQuickLink(Symbols.support_agent,
|
||||
AppLocalizations.of(context).contactUs, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const EnquiryScreen()));
|
||||
}),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
builder: (context) =>
|
||||
AccountStatementScreen(
|
||||
accountNo: users[selectedAccountIndex]
|
||||
.accountNo!,
|
||||
balance: users[selectedAccountIndex]
|
||||
.availableBalance!,
|
||||
accountType: users[selectedAccountIndex]
|
||||
.accountType!,
|
||||
)));
|
||||
}),
|
||||
_buildQuickLink(Symbols.checkbook,
|
||||
AppLocalizations.of(context).handleCheque, () {},
|
||||
disable: true),
|
||||
_buildQuickLink(Icons.group,
|
||||
AppLocalizations.of(context).manageBeneficiary,
|
||||
() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ManageBeneficiariesScreen(
|
||||
customerName: currAccount.name!)));
|
||||
}, disable: false),
|
||||
_buildQuickLink(Symbols.support_agent,
|
||||
AppLocalizations.of(context).contactUs, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const EnquiryScreen()));
|
||||
}),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
|
||||
// Recent Transactions
|
||||
Text(
|
||||
@@ -545,25 +565,35 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
tx.type == 'CR'
|
||||
? Symbols.call_received
|
||||
: Symbols.call_made,
|
||||
color:
|
||||
tx.type == 'CR' ? Colors.green : Colors.red,
|
||||
color: tx.type == 'CR'
|
||||
? const Color(0xFF10BB10)
|
||||
: theme.colorScheme.error,
|
||||
),
|
||||
title: Text(
|
||||
tx.name != null
|
||||
? (tx.name!.length > 18
|
||||
? tx.name!.substring(0, 20)
|
||||
: tx.name!)
|
||||
: '',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
tx.date ?? '',
|
||||
style: const TextStyle(fontSize: 15),
|
||||
),
|
||||
subtitle: Text(
|
||||
tx.date ?? '',
|
||||
tx.name != null
|
||||
? (tx.name!.length > 18
|
||||
? tx.name!.substring(0, 22)
|
||||
: tx.name!)
|
||||
: '',
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
trailing: Text(
|
||||
"₹${tx.amount}",
|
||||
style: const TextStyle(fontSize: 16),
|
||||
style: const TextStyle(fontSize: 17),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
TransactionDetailsScreen(transaction: tx),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
else
|
||||
@@ -574,7 +604,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
AppLocalizations.of(context).noTransactions,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[600],
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -594,22 +624,26 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
}
|
||||
|
||||
List<Widget> _buildTransactionShimmer() {
|
||||
final theme = Theme.of(context);
|
||||
return List.generate(3, (i) {
|
||||
return ListTile(
|
||||
leading: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: CircleAvatar(radius: 12, backgroundColor: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: CircleAvatar(
|
||||
radius: 12, backgroundColor: theme.scaffoldBackgroundColor),
|
||||
),
|
||||
title: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(height: 10, width: 100, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: Container(
|
||||
height: 10, width: 100, color: theme.scaffoldBackgroundColor),
|
||||
),
|
||||
subtitle: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(height: 8, width: 60, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: Container(
|
||||
height: 8, width: 60, color: theme.scaffoldBackgroundColor),
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -621,6 +655,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
VoidCallback onTap, {
|
||||
bool disable = false,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
return InkWell(
|
||||
onTap: disable ? null : onTap,
|
||||
child: Column(
|
||||
@@ -629,7 +664,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Icon(
|
||||
icon,
|
||||
size: 30,
|
||||
color: disable ? Colors.grey : Theme.of(context).primaryColor,
|
||||
color: disable
|
||||
? theme.colorScheme.onSurface.withOpacity(0.3)
|
||||
: theme.colorScheme.primary,
|
||||
grade: 200,
|
||||
weight: 700,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
|
@@ -13,14 +13,7 @@ class AccountCard extends StatelessWidget {
|
||||
width: 300,
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Theme.of(context).primaryColor,
|
||||
Theme.of(context).primaryColor.withBlue(200),
|
||||
],
|
||||
),
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
@@ -40,7 +33,7 @@ class AccountCard extends StatelessWidget {
|
||||
Text(
|
||||
account.accountType,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -49,20 +42,21 @@ class AccountCard extends StatelessWidget {
|
||||
account.accountType == 'Savings'
|
||||
? Icons.savings
|
||||
: Icons.account_balance,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
account.accountNumber,
|
||||
style: TextStyle(color: Theme.of(context).dialogBackgroundColor, fontSize: 16),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onPrimary, fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
'${account.currency} ${account.balance.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
@@ -70,10 +64,12 @@ class AccountCard extends StatelessWidget {
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
AppLocalizations.of(context).availableBalance,
|
||||
style: TextStyle(color: Theme.of(context).dialogBackgroundColor, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onPrimary, fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import '../../transactions/models/transaction.dart';
|
||||
|
||||
class TransactionListItem extends StatelessWidget {
|
||||
final Transaction transaction;
|
||||
|
||||
|
||||
const TransactionListItem({
|
||||
super.key,
|
||||
required this.transaction,
|
||||
@@ -13,7 +13,7 @@ class TransactionListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final bool isIncome = transaction.amount > 0;
|
||||
|
||||
|
||||
return Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||
@@ -25,7 +25,8 @@ class TransactionListItem extends StatelessWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: _getCategoryColor(transaction.category).withAlpha((0.1 * 255).toInt()),
|
||||
color: _getCategoryColor(transaction.category)
|
||||
.withAlpha((0.1 * 255).toInt()),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(
|
||||
@@ -34,7 +35,7 @@ class TransactionListItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
||||
|
||||
// Transaction details
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -48,7 +49,8 @@ class TransactionListItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
DateFormat('MMM dd, yyyy • h:mm a').format(transaction.date),
|
||||
DateFormat('MMM dd, yyyy • h:mm a')
|
||||
.format(transaction.date),
|
||||
style: TextStyle(
|
||||
color: Colors.grey[600],
|
||||
fontSize: 12,
|
||||
@@ -57,7 +59,7 @@ class TransactionListItem extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// Amount
|
||||
Text(
|
||||
'${isIncome ? '+' : ''}${transaction.amount.toStringAsFixed(2)} USD',
|
||||
@@ -106,4 +108,4 @@ class TransactionListItem extends StatelessWidget {
|
||||
return Icons.category;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
@@ -34,16 +34,20 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(role, style: const TextStyle(color: Colors.grey)),
|
||||
Text(role,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onSurface)),
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: () => _launchEmailAddress(email),
|
||||
child: Text(email, style: TextStyle(color: Theme.of(context).primaryColor)),
|
||||
child: Text(email,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.primary)),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: () => _launchPhoneNumber(phone),
|
||||
child: Text(phone, style: TextStyle(color: Theme.of(context).scaffoldBackgroundColor)),
|
||||
child: Text(phone,
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).scaffoldBackgroundColor)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -53,32 +57,8 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).enquiry,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
title: Text(AppLocalizations.of(context).enquiry),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -89,24 +69,23 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context).writeToUs,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
"complaint@kccb.in",
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
|
||||
SizedBox(height: 20),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context).keyContacts,
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
color: Theme.of(context).primaryColor,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
// horizontal line
|
||||
),
|
||||
Divider(color: Colors.grey[300]),
|
||||
Divider(color: Theme.of(context).colorScheme.outline),
|
||||
const SizedBox(height: 16),
|
||||
_buildContactItem(
|
||||
AppLocalizations.of(context).chairman,
|
||||
|
@@ -0,0 +1,440 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/neft_service.dart';
|
||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||
import 'package:kmobile/api/services/imps_service.dart';
|
||||
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||
import 'package:kmobile/widgets/bank_logos.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
|
||||
enum TransactionMode { neft, rtgs, imps }
|
||||
|
||||
class FundTransferAmountScreen extends StatefulWidget {
|
||||
final String debitAccountNo;
|
||||
final Beneficiary creditBeneficiary;
|
||||
final String remitterName;
|
||||
final bool isOwnBank;
|
||||
|
||||
const FundTransferAmountScreen({
|
||||
super.key,
|
||||
required this.debitAccountNo,
|
||||
required this.creditBeneficiary,
|
||||
required this.remitterName,
|
||||
this.isOwnBank = false,
|
||||
});
|
||||
|
||||
@override
|
||||
State<FundTransferAmountScreen> createState() =>
|
||||
_FundTransferAmountScreenState();
|
||||
}
|
||||
|
||||
class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
||||
final _amountController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
TransactionMode _selectedMode = TransactionMode.neft;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_amountController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onProceed() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
final amount = double.tryParse(_amountController.text) ?? 0;
|
||||
if (widget.isOwnBank) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
final transfer = Transfer(
|
||||
fromAccount: widget.debitAccountNo,
|
||||
toAccount: widget.creditBeneficiary.accountNo,
|
||||
toAccountType: 'Savings', // Assuming 'SB' for savings
|
||||
amount: _amountController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
|
||||
final paymentService = getIt<PaymentService>();
|
||||
final paymentResponseFuture =
|
||||
paymentService.processQuickPayWithinBank(transfer);
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: paymentResponseFuture),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
if (_selectedMode == TransactionMode.rtgs && amount < 200000) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).invalidRtgs),
|
||||
content: Text(AppLocalizations.of(context).invalidRtgsPopUp),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: Text(AppLocalizations.of(context).ok),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return; // Stop further execution
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
if (_selectedMode == TransactionMode.neft) {
|
||||
final neftTx = NeftTransaction(
|
||||
fromAccount: widget.debitAccountNo,
|
||||
toAccount: widget.creditBeneficiary.accountNo,
|
||||
amount: _amountController.text,
|
||||
ifscCode: widget.creditBeneficiary.ifscCode,
|
||||
remitterName: widget.remitterName,
|
||||
beneficiaryName: widget.creditBeneficiary.name,
|
||||
tpin: tpin,
|
||||
);
|
||||
final neftService = getIt<NeftService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final neftResponse =
|
||||
await neftService.processNeftTransaction(neftTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess:
|
||||
neftResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: neftTx.toAccount,
|
||||
amount: neftTx.amount,
|
||||
currency: 'INR',
|
||||
utr: neftResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} on DioException catch (e) {
|
||||
String errorMessage;
|
||||
if (e.response != null && e.response!.data != null) {
|
||||
try {
|
||||
// final error = jsonDecode(e.response!.toString())['error'];
|
||||
final error = e.response?.data['error'];
|
||||
errorMessage = {
|
||||
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||
"INSUFFICIENT_FUNDS":
|
||||
"Your account does not have sufficient balance"
|
||||
}[error] ??
|
||||
"Something Went Wrong";
|
||||
} catch (_) {
|
||||
errorMessage = "Something Went Wrong";
|
||||
}
|
||||
} else {
|
||||
errorMessage = "Something Went Wrong";
|
||||
}
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
if (!pinScreenContext.mounted) return;
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: AppLocalizations.of(pinScreenContext)
|
||||
.somethingWentWrong,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
//IMPS transaction
|
||||
else if (_selectedMode == TransactionMode.imps) {
|
||||
final impsTx = ImpsTransaction(
|
||||
fromAccount: widget.debitAccountNo,
|
||||
toAccount: widget.creditBeneficiary.accountNo,
|
||||
amount: _amountController.text,
|
||||
ifscCode: widget.creditBeneficiary.ifscCode,
|
||||
remitterName: widget.remitterName,
|
||||
beneficiaryName: widget.creditBeneficiary.name,
|
||||
tpin: tpin,
|
||||
);
|
||||
final impsService = getIt<ImpsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final impsResponse =
|
||||
await impsService.processImpsTransaction(impsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess:
|
||||
impsResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: impsTx.toAccount,
|
||||
amount: impsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: impsResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} on DioException catch (e) {
|
||||
final error = jsonDecode(e.response.toString())['error'];
|
||||
var errorMessage = {
|
||||
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||
"INSUFFICIENT_FUNDS":
|
||||
"Your account does not have sufficient balance"
|
||||
}[error] ??
|
||||
"Something Went Wrong";
|
||||
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: "Something went Wrong",
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
//RTGS
|
||||
else {
|
||||
final rtgsTx = RtgsTransaction(
|
||||
fromAccount: widget.debitAccountNo,
|
||||
toAccount: widget.creditBeneficiary.accountNo,
|
||||
amount: _amountController.text,
|
||||
ifscCode: widget.creditBeneficiary.ifscCode,
|
||||
remitterName: widget.remitterName,
|
||||
beneficiaryName: widget.creditBeneficiary.name,
|
||||
tpin: tpin,
|
||||
);
|
||||
final rtgsService = getIt<RtgsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final rtgsResponse =
|
||||
await rtgsService.processRtgsTransaction(rtgsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess:
|
||||
rtgsResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: rtgsTx.toAccount,
|
||||
amount: rtgsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: rtgsResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} on DioException catch (e) {
|
||||
final error = jsonDecode(e.response.toString())['error'];
|
||||
var errorMessage = {
|
||||
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||
"INSUFFICIENT_FUNDS":
|
||||
"Your account does not have sufficient balance"
|
||||
// ignore: use_build_context_synchronously
|
||||
}[error] ??
|
||||
"Something Went Wrong";
|
||||
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: "Something Went Wrong",
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(loc.fundTransfer.replaceFirst(RegExp('\n'), '')),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Debit Account (User)
|
||||
Text(
|
||||
loc.debitFrom,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ListTile(
|
||||
leading: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
title: Text(widget.remitterName),
|
||||
subtitle: Text(widget.debitAccountNo),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Credit Account (Beneficiary)
|
||||
Text(
|
||||
AppLocalizations.of(context).creditedTo,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ListTile(
|
||||
leading:
|
||||
getBankLogo(widget.creditBeneficiary.bankName, context),
|
||||
title: Text(widget.creditBeneficiary.name),
|
||||
subtitle: Text(widget.creditBeneficiary.accountNo),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
if (!widget.isOwnBank) ...[
|
||||
// Transaction Mode Selection
|
||||
Text(
|
||||
AppLocalizations.of(context).selectTransactionType,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
),
|
||||
child: ToggleButtons(
|
||||
isSelected: [
|
||||
_selectedMode == TransactionMode.neft,
|
||||
_selectedMode == TransactionMode.rtgs,
|
||||
_selectedMode == TransactionMode.imps,
|
||||
],
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
_selectedMode = TransactionMode.values[index];
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
selectedColor: Theme.of(context).colorScheme.onPrimary,
|
||||
fillColor: Theme.of(context).colorScheme.primary,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
borderColor: Colors.transparent,
|
||||
selectedBorderColor: Colors.transparent,
|
||||
splashColor: Theme.of(context).colorScheme.primary,
|
||||
highlightColor: Theme.of(context).colorScheme.primary,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0, vertical: 12.0),
|
||||
child: Text(AppLocalizations.of(context).neft),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0, vertical: 12.0),
|
||||
child: Text(AppLocalizations.of(context).rtgs),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0, vertical: 12.0),
|
||||
child: Text(AppLocalizations.of(context).imps),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
// Amount
|
||||
TextFormField(
|
||||
controller: _amountController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.amount,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.currency_rupee),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return loc.amountRequired;
|
||||
}
|
||||
if (double.tryParse(value) == null ||
|
||||
double.parse(value) <= 0) {
|
||||
return loc.validAmount;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
|
||||
// Proceed Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _onProceed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).proceed),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,113 +1,30 @@
|
||||
/*import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
// import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class FundTransferBeneficiaryScreen extends StatefulWidget {
|
||||
const FundTransferBeneficiaryScreen({super.key});
|
||||
|
||||
@override
|
||||
State<FundTransferBeneficiaryScreen> createState() =>
|
||||
_FundTransferBeneficiaryScreen();
|
||||
}
|
||||
|
||||
class _FundTransferBeneficiaryScreen
|
||||
extends State<FundTransferBeneficiaryScreen> {
|
||||
final List<Map<String, String>> beneficiaries = [
|
||||
{'bank': 'State Bank Of India', 'name': 'Trina Bakshi'},
|
||||
{'bank': 'State Bank Of India', 'name': 'Sheetal Rao'},
|
||||
{'bank': 'Punjab National Bank', 'name': 'Manoj Kumar'},
|
||||
{'bank': 'State Bank Of India', 'name': 'Rohit Mehra'},
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).fundTransferBeneficiary,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView.builder(
|
||||
itemCount: beneficiaries.length,
|
||||
itemBuilder: (context, index) {
|
||||
final beneficiary = beneficiaries[index];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
child: Text('A'),
|
||||
),
|
||||
title: Text(beneficiary['name']!),
|
||||
subtitle: Text(beneficiary['bank']!),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Symbols.arrow_right, size: 20),
|
||||
onPressed: () {
|
||||
// Delete action
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const FundTransferScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/widgets/bank_logos.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
//import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_amount_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../../di/injection.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
|
||||
class FundTransferBeneficiaryScreen extends StatefulWidget {
|
||||
const FundTransferBeneficiaryScreen({super.key});
|
||||
final String creditAccountNo;
|
||||
final String remitterName;
|
||||
final bool isOwnBank;
|
||||
const FundTransferBeneficiaryScreen(
|
||||
{super.key,
|
||||
required this.creditAccountNo,
|
||||
required this.remitterName,
|
||||
required this.isOwnBank});
|
||||
|
||||
@override
|
||||
State<FundTransferBeneficiaryScreen> createState() =>
|
||||
_ManageBeneficiariesScreen();
|
||||
_FundTransferBeneficiaryScreenState();
|
||||
}
|
||||
|
||||
class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
class _FundTransferBeneficiaryScreenState
|
||||
extends State<FundTransferBeneficiaryScreen> {
|
||||
var service = getIt<BeneficiaryService>();
|
||||
//final BeneficiaryService _service = BeneficiaryService();
|
||||
bool _isLoading = true;
|
||||
List<Beneficiary> _beneficiaries = [];
|
||||
|
||||
@@ -120,7 +37,12 @@ class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
Future<void> _loadBeneficiaries() async {
|
||||
final data = await service.fetchBeneficiaryList();
|
||||
setState(() {
|
||||
_beneficiaries = data ;
|
||||
_beneficiaries = data
|
||||
.where((b) => widget.isOwnBank
|
||||
? b.bankName ==
|
||||
'THE KANGRA CENTRAL CO-OP BANK LIMITED' // Assuming 'KCCB' is your bank's name
|
||||
: b.bankName != 'THE KANGRA CENTRAL CO-OP BANK LIMITED')
|
||||
.toList();
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -132,7 +54,7 @@ class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
baseColor: Colors.grey.shade300,
|
||||
highlightColor: Colors.grey.shade100,
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
leading: const CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
@@ -153,25 +75,45 @@ class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
|
||||
Widget _buildBeneficiaryList() {
|
||||
if (_beneficiaries.isEmpty) {
|
||||
return Center(child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
return Center(
|
||||
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: _beneficiaries.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _beneficiaries[index];
|
||||
final beneficiary = _beneficiaries[index];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
||||
child: Text(
|
||||
item.name.isNotEmpty
|
||||
? item.name[0].toUpperCase()
|
||||
: '?',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
child: getBankLogo(beneficiary.bankName, context),
|
||||
),
|
||||
title: Text(item.name ?? 'Unknown'),
|
||||
subtitle: Text(item.accountNo ?? 'No account number'),
|
||||
title: Text(beneficiary.name),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(beneficiary.accountNo),
|
||||
if (beneficiary.bankName != null &&
|
||||
beneficiary.bankName!.isNotEmpty)
|
||||
Text(
|
||||
beneficiary.bankName!,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FundTransferAmountScreen(
|
||||
debitAccountNo: widget.creditAccountNo,
|
||||
creditBeneficiary: beneficiary,
|
||||
remitterName: widget.remitterName,
|
||||
isOwnBank: widget.isOwnBank,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@@ -1,152 +1,90 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class FundTransferScreen extends StatefulWidget {
|
||||
const FundTransferScreen({super.key});
|
||||
class FundTransferScreen extends StatelessWidget {
|
||||
final String creditAccountNo;
|
||||
final String remitterName;
|
||||
|
||||
@override
|
||||
State<FundTransferScreen> createState() => _FundTransferScreen();
|
||||
}
|
||||
|
||||
class _FundTransferScreen extends State<FundTransferScreen> {
|
||||
String amount = "";
|
||||
|
||||
void onKeyTap(String key) {
|
||||
setState(() {
|
||||
if (key == 'back') {
|
||||
if (amount.isNotEmpty) {
|
||||
amount = amount.substring(0, amount.length - 1);
|
||||
}
|
||||
} else if (key == 'done') {
|
||||
if (kDebugMode) {
|
||||
print('${AppLocalizations.of(context).amountEntered} $amount');
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => const TransactionPinScreen(
|
||||
// transactionData: {},
|
||||
// transactionCode: 'TRANSFER'
|
||||
// )));
|
||||
}
|
||||
} else {
|
||||
amount += key;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildKey(String value) {
|
||||
if (value == 'done') {
|
||||
return GestureDetector(
|
||||
onTap: () => onKeyTap(value),
|
||||
child: const Icon(Symbols.check, size: 30),
|
||||
);
|
||||
} else if (value == 'back') {
|
||||
return GestureDetector(
|
||||
onTap: () => onKeyTap(value),
|
||||
child: const Icon(Symbols.backspace, size: 30),
|
||||
);
|
||||
} else {
|
||||
return GestureDetector(
|
||||
onTap: () => onKeyTap(value),
|
||||
child: Center(
|
||||
child: Text(
|
||||
value,
|
||||
style: const TextStyle(fontSize: 24, color: Colors.black),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final keys = [
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'done',
|
||||
'0',
|
||||
'back',
|
||||
];
|
||||
const FundTransferScreen({
|
||||
super.key,
|
||||
required this.creditAccountNo,
|
||||
required this.remitterName,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).fundTransfer,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundImage: AssetImage('assets/images/avatar.jpg'),
|
||||
// Replace with your image
|
||||
radius: 20,
|
||||
),
|
||||
),
|
||||
],
|
||||
title: Text(AppLocalizations.of(context)
|
||||
.fundTransfer
|
||||
.replaceFirst(RegExp('\n'), '')),
|
||||
),
|
||||
body: Column(
|
||||
body: ListView(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).debitFrom),
|
||||
Text(
|
||||
'0300015678903456',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
FundTransferManagementTile(
|
||||
icon: Symbols.input_circle,
|
||||
label: AppLocalizations.of(context).ownBank,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FundTransferBeneficiaryScreen(
|
||||
creditAccountNo: creditAccountNo,
|
||||
remitterName: remitterName,
|
||||
isOwnBank: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context).enterAmount,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade200,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
amount.isEmpty ? "0" : amount,
|
||||
style: const TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: GridView.count(
|
||||
crossAxisCount: 3,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
mainAxisSpacing: 12,
|
||||
crossAxisSpacing: 12,
|
||||
childAspectRatio: 1.2,
|
||||
children: keys.map((key) => buildKey(key)).toList(),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
FundTransferManagementTile(
|
||||
icon: Symbols.output_circle,
|
||||
label: AppLocalizations.of(context).outsideBank,
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FundTransferBeneficiaryScreen(
|
||||
creditAccountNo: creditAccountNo,
|
||||
remitterName: remitterName,
|
||||
isOwnBank: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FundTransferManagementTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
final bool disable;
|
||||
|
||||
const FundTransferManagementTile({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
this.disable = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: Icon(icon),
|
||||
title: Text(label),
|
||||
trailing: const Icon(Symbols.arrow_right, size: 20),
|
||||
onTap: onTap,
|
||||
enabled: !disable,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
@@ -10,222 +11,6 @@ import 'package:path_provider/path_provider.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:confetti/confetti.dart';
|
||||
|
||||
/*class PaymentAnimationScreen extends StatefulWidget {
|
||||
final Future<PaymentResponse> paymentResponse;
|
||||
|
||||
const PaymentAnimationScreen({super.key, required this.paymentResponse});
|
||||
|
||||
@override
|
||||
State<PaymentAnimationScreen> createState() => _PaymentAnimationScreenState();
|
||||
}
|
||||
|
||||
class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
final GlobalKey _shareKey = GlobalKey();
|
||||
|
||||
Future<void> _shareScreenshot() async {
|
||||
try {
|
||||
RenderRepaintBoundary boundary =
|
||||
_shareKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
|
||||
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
|
||||
ByteData? byteData = await image.toByteData(
|
||||
format: ui.ImageByteFormat.png,
|
||||
);
|
||||
Uint8List pngBytes = byteData!.buffer.asUint8List();
|
||||
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
final file = await File('${tempDir.path}/payment_result.png').create();
|
||||
await file.writeAsBytes(pngBytes);
|
||||
|
||||
await Share.shareXFiles([
|
||||
XFile(file.path),
|
||||
], text: '${AppLocalizations.of(context).paymentResult}');
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'${AppLocalizations.of(context).failedToShareScreenshot}: $e',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: FutureBuilder<PaymentResponse>(
|
||||
future: widget.paymentResponse,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(
|
||||
child: Lottie.asset(
|
||||
'assets/animations/rupee.json',
|
||||
width: 200,
|
||||
height: 200,
|
||||
repeat: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final response = snapshot.data!;
|
||||
final isSuccess = response.isSuccess;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: RepaintBoundary(
|
||||
key: _shareKey,
|
||||
child: Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 80),
|
||||
Lottie.asset(
|
||||
isSuccess
|
||||
? 'assets/animations/done.json'
|
||||
: 'assets/animations/error.json',
|
||||
width: 200,
|
||||
height: 200,
|
||||
repeat: false,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
isSuccess
|
||||
? Column(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(
|
||||
context,
|
||||
).paymentSuccessful,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (response.amount != null)
|
||||
Text(
|
||||
'${AppLocalizations.of(context).amount}: ${response.amount} ${response.currency ?? ''}',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontFamily: 'Rubik',
|
||||
),
|
||||
),
|
||||
if (response.creditedAccount != null)
|
||||
Text(
|
||||
'${AppLocalizations.of(context).creditedAccount}: ${response.creditedAccount}',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: 'Rubik',
|
||||
),
|
||||
),
|
||||
if (response.date != null)
|
||||
Text(
|
||||
'Date: ${response.date!.toLocal().toIso8601String()}',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).paymentFailed,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (response.errorMessage != null)
|
||||
Text(
|
||||
response.errorMessage!,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Buttons at the bottom
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 80,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton.icon(
|
||||
onPressed: _shareScreenshot,
|
||||
icon: Icon(
|
||||
Icons.share_rounded,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
label: Text(
|
||||
AppLocalizations.of(context).share,
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).scaffoldBackgroundColor,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32,
|
||||
vertical: 12,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(
|
||||
color: Theme.of(context).primaryColor,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(
|
||||
context,
|
||||
).popUntil((route) => route.isFirst);
|
||||
},
|
||||
label: Text(AppLocalizations.of(context).done),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 45,
|
||||
vertical: 12,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
class PaymentAnimationScreen extends StatefulWidget {
|
||||
final Future<PaymentResponse> paymentResponse;
|
||||
|
||||
@@ -242,7 +27,8 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_confettiController = ConfettiController(duration: const Duration(seconds: 2));
|
||||
_confettiController =
|
||||
ConfettiController(duration: const Duration(seconds: 2));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -256,7 +42,8 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
RenderRepaintBoundary boundary =
|
||||
_shareKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
|
||||
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
|
||||
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
ByteData? byteData =
|
||||
await image.toByteData(format: ui.ImageByteFormat.png);
|
||||
Uint8List pngBytes = byteData!.buffer.asUint8List();
|
||||
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
@@ -344,7 +131,8 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
? Column(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).paymentSuccessful,
|
||||
AppLocalizations.of(context)
|
||||
.paymentSuccessful,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -375,6 +163,15 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
"Date: ${response.date!.toLocal().toIso8601String()}",
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
if (response.utr != null &&
|
||||
response.utr!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
'UTR: ${response.utr}',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
@@ -390,7 +187,7 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
const SizedBox(height: 16),
|
||||
if (response.errorMessage != null)
|
||||
Text(
|
||||
response.errorMessage!,
|
||||
response.errorMessage ?? '',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
],
|
||||
@@ -412,34 +209,34 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
onPressed: _shareScreenshot,
|
||||
icon: Icon(
|
||||
Icons.share_rounded,
|
||||
color: Theme.of(context).primaryColor,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
label: Text(
|
||||
AppLocalizations.of(context).share,
|
||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 45, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: Theme.of(context).primaryColor, width: 1),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
Navigator.of(context)
|
||||
.popUntil((route) => route.isFirst);
|
||||
},
|
||||
icon: const Icon(Icons.check),
|
||||
label: Text(AppLocalizations.of(context).done),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 45, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 45, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
|
||||
|
||||
@@ -132,7 +131,8 @@ class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
||||
icon: const Icon(Icons.verified_user_rounded),
|
||||
label: Text(
|
||||
AppLocalizations.of(context).verifyOtp,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_otp_screen.dart';
|
||||
|
||||
@@ -42,7 +41,8 @@ class TpinSetupPromptScreen extends StatelessWidget {
|
||||
icon: const Icon(Icons.arrow_forward_rounded),
|
||||
label: Text(
|
||||
AppLocalizations.of(context).setTpin,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
style:
|
||||
const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.colorScheme.primary,
|
||||
|
@@ -55,6 +55,7 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
||||
await authService.setTpin(pin);
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
// ignore: unnecessary_string_interpolations
|
||||
_errorText = "${AppLocalizations.of(context).tpinFailed}";
|
||||
_tpin.clear();
|
||||
});
|
||||
@@ -71,11 +72,11 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
||||
),
|
||||
title: Column(
|
||||
children: [
|
||||
Icon(Icons.check_circle, color: Colors.green, size: 60),
|
||||
SizedBox(height: 12),
|
||||
const Icon(Icons.check_circle, color: Colors.green, size: 60),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
AppLocalizations.of(context).success,
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -90,7 +91,7 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
||||
},
|
||||
child: Text(
|
||||
AppLocalizations.of(context).ok,
|
||||
style: TextStyle(fontSize: 16),
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -172,7 +173,9 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
||||
key == '<' ? '⌫' : key,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: key == 'Enter' ? Theme.of(context).primaryColor : Colors.black,
|
||||
color: key == 'Enter'
|
||||
? Theme.of(context).primaryColor
|
||||
: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -201,7 +204,8 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Icon(Icons.lock_outline, size: 60, color: Theme.of(context).primaryColor),
|
||||
Icon(Icons.lock_outline,
|
||||
size: 60, color: Theme.of(context).primaryColor),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
getTitle(),
|
||||
|
@@ -1,32 +1,54 @@
|
||||
// ignore_for_file: unused_field
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:kmobile/api/services/auth_service.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_prompt_screen.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/auth_service.dart';
|
||||
import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_prompt_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
class TransactionPinScreen extends StatefulWidget {
|
||||
final Transfer transactionData;
|
||||
const TransactionPinScreen({super.key, required this.transactionData});
|
||||
final Future<void> Function(BuildContext, String) onPinCompleted;
|
||||
|
||||
const TransactionPinScreen({super.key, required this.onPinCompleted});
|
||||
|
||||
@override
|
||||
State<TransactionPinScreen> createState() => _TransactionPinScreen();
|
||||
State<TransactionPinScreen> createState() => _TransactionPinScreenState();
|
||||
}
|
||||
|
||||
class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
class _TransactionPinScreenState extends State<TransactionPinScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final List<String> _pin = [];
|
||||
bool _loading = true;
|
||||
bool _isSubmitting = false;
|
||||
|
||||
late final AnimationController _bounceController;
|
||||
late final Animation<double> _bounceAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkIfTpinIsSet();
|
||||
|
||||
_bounceController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 150),
|
||||
);
|
||||
_bounceAnimation = Tween<double>(begin: 1.0, end: 1.1).animate(
|
||||
CurvedAnimation(
|
||||
parent: _bounceController,
|
||||
curve: Curves.elasticIn,
|
||||
reverseCurve: Curves.elasticOut),
|
||||
)..addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
_bounceController.reverse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_bounceController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _checkIfTpinIsSet() async {
|
||||
@@ -55,60 +77,87 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
}
|
||||
|
||||
void _onKeyPressed(String value) {
|
||||
if (_isSubmitting) return;
|
||||
setState(() {
|
||||
if (value == 'back') {
|
||||
if (_pin.isNotEmpty) _pin.removeLast();
|
||||
} else if (_pin.length < 6) {
|
||||
_pin.add(value);
|
||||
_bounceController.forward(from: 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _submitPin() async {
|
||||
if (_isSubmitting) return;
|
||||
|
||||
if (_pin.length == 6) {
|
||||
setState(() => _isSubmitting = true);
|
||||
try {
|
||||
await widget.onPinCompleted(context, _pin.join());
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isSubmitting = false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).enter6DigitTpin),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildPinIndicators() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(6, (index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
|
||||
color: index < _pin.length ? Theme.of(context).primaryColor : Colors.transparent,
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
return AnimatedBuilder(
|
||||
animation: _bounceAnimation,
|
||||
builder: (context, child) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(6, (index) {
|
||||
final isAnimating =
|
||||
index == _pin.length - 1 && _bounceController.isAnimating;
|
||||
return Transform.scale(
|
||||
scale: isAnimating ? _bounceAnimation.value : 1.0,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
width: 30,
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: index < _pin.length
|
||||
? Theme.of(context).colorScheme.onSurfaceVariant
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.surfaceContainerHighest),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildKey(String label, {IconData? icon}) {
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
if (label == 'back') {
|
||||
_onKeyPressed('back');
|
||||
} else if (label == 'done') {
|
||||
// Handle submit if needed
|
||||
if (_pin.length == 6) {
|
||||
await sendTransaction();
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).enter6DigitTpin),
|
||||
),
|
||||
);
|
||||
}
|
||||
onTap: () {
|
||||
HapticFeedback.lightImpact();
|
||||
if (label == 'done') {
|
||||
_submitPin();
|
||||
} else {
|
||||
_onKeyPressed(label);
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.circular(48),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: Center(
|
||||
child: icon != null
|
||||
? Icon(icon, size: 28)
|
||||
: Text(label, style: const TextStyle(fontSize: 24)),
|
||||
child: _isSubmitting && label == 'done'
|
||||
? const CircularProgressIndicator()
|
||||
: icon != null
|
||||
? Icon(icon, size: 28)
|
||||
: Text(label, style: const TextStyle(fontSize: 24)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -133,62 +182,34 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> sendTransaction() async {
|
||||
final paymentService = getIt<PaymentService>();
|
||||
final transfer = widget.transactionData;
|
||||
transfer.tpin = _pin.join();
|
||||
try {
|
||||
final paymentResponse = paymentService.processQuickPayWithinBank(
|
||||
transfer,
|
||||
);
|
||||
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
PaymentAnimationScreen(paymentResponse: paymentResponse),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).tpin,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
title: Text(AppLocalizations.of(context).tpin),
|
||||
centerTitle: false,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
AppLocalizations.of(context).enterTpin,
|
||||
style: TextStyle(fontSize: 18),
|
||||
body: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
AppLocalizations.of(context).enterTpin,
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 50),
|
||||
_buildPinIndicators(),
|
||||
const Spacer(),
|
||||
_buildKeypad(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPinIndicators(),
|
||||
const Spacer(),
|
||||
_buildKeypad(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,8 +36,8 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String transactionDate = DateTime.now().toLocal().toString().split(
|
||||
' ',
|
||||
)[0];
|
||||
' ',
|
||||
)[0];
|
||||
final String creditAccount = widget.creditAccount;
|
||||
|
||||
return Scaffold(
|
||||
@@ -53,24 +53,27 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
child: Icon(Icons.check, color: Theme.of(context).scaffoldBackgroundColor, size: 60),
|
||||
child: Icon(Icons.check,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
size: 60),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
AppLocalizations.of(context).transactionSuccess,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w600),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
"On $transactionDate",
|
||||
style: const TextStyle(fontSize: 14, color: Colors.black54),
|
||||
style: TextStyle(fontSize: 14, color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"${AppLocalizations.of(context).toAccountNumber}: $creditAccount",
|
||||
style: const TextStyle(fontSize: 12, color: Colors.black87),
|
||||
style: TextStyle(fontSize: 12, color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8)),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
@@ -88,14 +91,15 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: _shareScreenshot,
|
||||
icon: const Icon(Icons.share, size: 18),
|
||||
label: Text(AppLocalizations.of(context).share),
|
||||
label: Text(AppLocalizations.of(context).share,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.onPrimaryContainer),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor: Theme.of(context).primaryColorLight,
|
||||
side: const BorderSide(color: Colors.black, width: 1),
|
||||
elevation: 0,
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
foregroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -115,7 +119,8 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).done),
|
||||
),
|
||||
|
@@ -0,0 +1,84 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChangePasswordOTPScreen extends StatefulWidget {
|
||||
final String currentPassword;
|
||||
final String newPassword;
|
||||
final String confirmPassword;
|
||||
|
||||
// ignore: use_key_in_widget_constructors
|
||||
const ChangePasswordOTPScreen({
|
||||
required this.currentPassword,
|
||||
required this.newPassword,
|
||||
required this.confirmPassword,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ChangePasswordOTPScreen> createState() => _ChangePasswordOTPScreenState();
|
||||
}
|
||||
|
||||
class _ChangePasswordOTPScreenState extends State<ChangePasswordOTPScreen> {
|
||||
bool _isLoading = true;
|
||||
final TextEditingController otpController = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Simulate OTP sending delay
|
||||
Future.delayed(const Duration(seconds: 2), () {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _validateOTP() {
|
||||
// TODO: Add validation logic later
|
||||
print("Validating OTP...");
|
||||
print('Current Password: ${widget.currentPassword}');
|
||||
print('New Password: ${widget.newPassword}');
|
||||
print('Confirm Password: ${widget.confirmPassword}');
|
||||
print('Entered OTP: ${otpController.text}');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('OTP Verification')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'An OTP has been sent to your registered mobile number.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
controller: otpController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Enter OTP',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _validateOTP,
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
child: const Text('Validate OTP'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
140
lib/features/profile/change_password/change_password_screen.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
// ignore_for_file: use_key_in_widget_constructors
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'change_password_otp_screen.dart';
|
||||
|
||||
class ChangePasswordScreen extends StatefulWidget {
|
||||
const ChangePasswordScreen();
|
||||
|
||||
@override
|
||||
State<ChangePasswordScreen> createState() => _ChangePasswordScreenState();
|
||||
}
|
||||
|
||||
class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final currentPasswordController = TextEditingController();
|
||||
final newPasswordController = TextEditingController();
|
||||
final confirmPasswordController = TextEditingController();
|
||||
|
||||
bool _showCurrentPassword = false;
|
||||
bool _showNewPassword = false;
|
||||
bool _showConfirmPassword = false;
|
||||
|
||||
final passwordRegex =
|
||||
RegExp(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).{8,}$');
|
||||
|
||||
String? validateCurrentPassword(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Current password is required';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? validateNewPassword(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'New password is required';
|
||||
}
|
||||
if (!passwordRegex.hasMatch(value)) {
|
||||
return 'At least 8 chars, upper & lower case, digit, special char';
|
||||
}
|
||||
if (value == currentPasswordController.text) {
|
||||
return 'New password must differ from current';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? validateConfirmPassword(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Confirm new password is required';
|
||||
}
|
||||
if (value != newPasswordController.text) {
|
||||
return 'Passwords do not match';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void _proceed() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ChangePasswordOTPScreen(
|
||||
currentPassword: currentPasswordController.text,
|
||||
newPassword: newPasswordController.text,
|
||||
confirmPassword: confirmPasswordController.text,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(AppLocalizations.of(context).changePassword)),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: currentPasswordController,
|
||||
obscureText: !_showCurrentPassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Current Password',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showCurrentPassword
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () =>
|
||||
setState(() => _showCurrentPassword = !_showCurrentPassword),
|
||||
),
|
||||
),
|
||||
validator: validateCurrentPassword,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: newPasswordController,
|
||||
obscureText: !_showNewPassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'New Password',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showNewPassword
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () =>
|
||||
setState(() => _showNewPassword = !_showNewPassword),
|
||||
),
|
||||
),
|
||||
validator: validateNewPassword,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: confirmPasswordController,
|
||||
obscureText: !_showConfirmPassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Confirm New Password',
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showConfirmPassword
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () =>
|
||||
setState(() => _showConfirmPassword = !_showConfirmPassword),
|
||||
),
|
||||
),
|
||||
validator: validateConfirmPassword,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: _proceed,
|
||||
child: Text(AppLocalizations.of(context).proceed),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
25
lib/features/profile/logout_dialog.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../l10n/app_localizations.dart';
|
||||
|
||||
class LogoutDialog extends StatelessWidget {
|
||||
const LogoutDialog({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).logout),
|
||||
content: Text(AppLocalizations.of(context).logoutCheck),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false), // dismiss
|
||||
child: Text(AppLocalizations.of(context).no),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true), // confirm
|
||||
child: Text(AppLocalizations.of(context).yes),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@@ -20,22 +20,22 @@ class ColorThemeDialog extends StatelessWidget {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
// ListTile(
|
||||
// leading: const CircleAvatar(backgroundColor: Colors.green),
|
||||
// title: const Text('Green'),
|
||||
// onTap: () {
|
||||
// context.read<ThemeCubit>().changeTheme(ThemeType.green);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
// ListTile(
|
||||
// leading: const CircleAvatar(backgroundColor: Colors.orange),
|
||||
// title: const Text('Orange'),
|
||||
// onTap: () {
|
||||
// context.read<ThemeCubit>().changeTheme(ThemeType.orange);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
ListTile(
|
||||
leading: const CircleAvatar(backgroundColor: Colors.green),
|
||||
title: Text(AppLocalizations.of(context).green),
|
||||
onTap: () {
|
||||
context.read<ThemeCubit>().changeTheme(ThemeType.green);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const CircleAvatar(backgroundColor: Colors.orange),
|
||||
title: Text(AppLocalizations.of(context).orange),
|
||||
onTap: () {
|
||||
context.read<ThemeCubit>().changeTheme(ThemeType.orange);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const CircleAvatar(backgroundColor: Colors.blue),
|
||||
title: Text(AppLocalizations.of(context).blue),
|
||||
@@ -48,4 +48,3 @@ class ColorThemeDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,12 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:kmobile/app.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class LanguageDialog extends StatelessWidget {
|
||||
// ignore: use_super_parameters
|
||||
const LanguageDialog({Key? key}) : super(key: key);
|
||||
|
||||
Future<void> _setLocale(BuildContext context, String langCode) async {
|
||||
@@ -34,4 +37,4 @@ class LanguageDialog extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/features/profile/preferences/theme_mode_dialog.dart';
|
||||
import 'language_dialog.dart';
|
||||
import 'color_theme_dialog.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
@@ -21,28 +22,6 @@ class PreferenceScreen extends StatelessWidget {
|
||||
builder: (context, state) {
|
||||
return ListView(
|
||||
children: [
|
||||
// Theme Mode Switch (Light/Dark)
|
||||
// ListTile(
|
||||
// leading: const Icon(Icons.brightness_6),
|
||||
// title: const Text("Theme Mode"),
|
||||
// trailing: Switch(
|
||||
// value: state.isDarkMode,
|
||||
// onChanged: (val) {
|
||||
// context.read<ThemeCubit>().toggleDarkMode(val);
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
//Color_Theme_Selection
|
||||
ListTile(
|
||||
leading: const Icon(Icons.color_lens),
|
||||
title: Text(AppLocalizations.of(context).themeColor),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => const ColorThemeDialog(),
|
||||
);
|
||||
}
|
||||
),
|
||||
// Language Selection
|
||||
ListTile(
|
||||
leading: const Icon(Icons.language),
|
||||
@@ -50,14 +29,32 @@ class PreferenceScreen extends StatelessWidget {
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => const LanguageDialog(), // your custom language dialog
|
||||
builder: (_) => const LanguageDialog(),
|
||||
);
|
||||
},
|
||||
),
|
||||
//Theme Mode Switch (Light/Dark)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.brightness_6),
|
||||
title: Text(AppLocalizations.of(context).themeMode),
|
||||
onTap: () {
|
||||
showThemeModeDialog(context);
|
||||
},
|
||||
),
|
||||
//Color_Theme_Selection
|
||||
ListTile(
|
||||
leading: const Icon(Icons.color_lens),
|
||||
title: Text(AppLocalizations.of(context).themeColor),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => const ColorThemeDialog(),
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
lib/features/profile/preferences/theme_mode_dialog.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||
|
||||
Future<void> showThemeModeDialog(BuildContext context) async {
|
||||
final cubit = context.read<ThemeModeCubit>();
|
||||
final currentMode = context.read<ThemeModeCubit>().state.mode;
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Select Theme Mode"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: ThemeMode.values.map((mode) {
|
||||
return RadioListTile<ThemeMode>(
|
||||
title: Text(mode.toString().split('.').last.toUpperCase()),
|
||||
value: mode,
|
||||
groupValue: currentMode,
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
cubit.changeThemeMode(value);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
@@ -1,9 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/repositories/auth_repository.dart';
|
||||
import 'package:kmobile/features/profile/change_password/change_password_screen.dart';
|
||||
import 'package:kmobile/features/profile/logout_dialog.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../di/injection.dart';
|
||||
import '../../l10n/app_localizations.dart';
|
||||
import 'package:kmobile/features/profile/preferences/preference_screen.dart';
|
||||
|
||||
class ProfileScreen extends StatelessWidget {
|
||||
const ProfileScreen({super.key});
|
||||
|
||||
|
||||
Future<void> _handleLogout(BuildContext context) async {
|
||||
final auth = getIt<AuthRepository>();
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.clear(); // clear saved session/token
|
||||
await auth.clearAuthTokens();
|
||||
// Navigate to login and remove all previous routes
|
||||
Navigator.pushNamedAndRemoveUntil(context, '/login', (route) => false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -17,14 +32,39 @@ class ProfileScreen extends StatelessWidget {
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(loc.preferences), // Localized "Preferences"
|
||||
title: Text(loc.preferences),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const PreferenceScreen()),
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const PreferenceScreen()),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.password),
|
||||
title: Text(loc.changePassword),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const ChangePasswordScreen()),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout),
|
||||
title: Text(AppLocalizations.of(context).logout),
|
||||
onTap: () async {
|
||||
final shouldLogout = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => const LogoutDialog(),
|
||||
);
|
||||
|
||||
if (shouldLogout == true) {
|
||||
await _handleLogout(context);
|
||||
}
|
||||
},
|
||||
),
|
||||
// You can add more profile options here later
|
||||
],
|
||||
),
|
||||
|
@@ -1,9 +1,21 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:kmobile/api/services/imps_service.dart';
|
||||
import 'package:kmobile/api/services/neft_service.dart';
|
||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../../di/injection.dart';
|
||||
import '../../../../api/services/beneficiary_service.dart';
|
||||
|
||||
class QuickPayOutsideBankScreen extends StatefulWidget {
|
||||
final String debitAccount;
|
||||
@@ -26,21 +38,83 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
final ifscController = TextEditingController();
|
||||
final phoneController = TextEditingController();
|
||||
final amountController = TextEditingController();
|
||||
final service = getIt<BeneficiaryService>();
|
||||
|
||||
//String accountType = 'Savings';
|
||||
late String accountType;
|
||||
bool _isValidating = false;
|
||||
bool _isBeneficiaryValidated = false;
|
||||
String? _validationError;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
accountType = AppLocalizations.of(context).savings;
|
||||
accountType = 'Savings';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//final List<String> transactionModes = ['NEFT', 'RTGS', 'IMPS'];
|
||||
void _validateIFSC() async {
|
||||
final ifsc = ifscController.text.trim().toUpperCase();
|
||||
if (ifsc.isEmpty) return;
|
||||
|
||||
final result = await service.validateIFSC(ifsc);
|
||||
|
||||
if (mounted) {
|
||||
if (result.bankName == '') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||
);
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
} else {
|
||||
bankNameController.text = result.bankName;
|
||||
branchNameController.text = result.branchName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _validateBeneficiary() async {
|
||||
FocusScope.of(context).unfocus();
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
_validationError = null;
|
||||
_isBeneficiaryValidated = false;
|
||||
nameController.text = ''; // clear previous name
|
||||
});
|
||||
|
||||
final String accountNo = accountNumberController.text.trim();
|
||||
final String ifsc = ifscController.text.trim();
|
||||
final String remitter = "Unknown";
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
final String beneficiaryName = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
nameController.text = beneficiaryName;
|
||||
_isBeneficiaryValidated = true;
|
||||
_validationError = null;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_validationError = e.toString();
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isValidating = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> transactionModes(BuildContext context) {
|
||||
return [
|
||||
AppLocalizations.of(context).neft,
|
||||
@@ -65,36 +139,243 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onProceedToPay() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
if (!_isBeneficiaryValidated) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content:
|
||||
Text(AppLocalizations.of(context).plsValidateBeneficiary)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final amount = double.tryParse(amountController.text) ?? 0;
|
||||
final selectedMode = transactionModes(context)[selectedTransactionIndex];
|
||||
final isRtgs = selectedMode == AppLocalizations.of(context).rtgs;
|
||||
final isNeft = selectedMode == AppLocalizations.of(context).neft;
|
||||
final isImps = selectedMode == AppLocalizations.of(context).imps;
|
||||
|
||||
if (isRtgs && amount < 200000) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).invalidRtgs),
|
||||
content: Text(AppLocalizations.of(context).invalidRtgsPopUp),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: Text(AppLocalizations.of(context).ok),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
if (isNeft) {
|
||||
// NEFT
|
||||
final neftTx = NeftTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown",
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
final neftService = getIt<NeftService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final neftResponse =
|
||||
await neftService.processNeftTransaction(neftTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: neftTx.toAccount,
|
||||
amount: neftTx.amount,
|
||||
currency: 'INR',
|
||||
utr: neftResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} on DioException catch (e) {
|
||||
String errorMessage;
|
||||
if (e.response != null && e.response!.data != null) {
|
||||
try {
|
||||
// final error = jsonDecode(e.response!.toString())['error'];
|
||||
final error = e.response?.data['error'];
|
||||
errorMessage = {
|
||||
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||
"INSUFFICIENT_FUNDS":
|
||||
"Your account does not have sufficient balance"
|
||||
}[error] ??
|
||||
"Something Went Wrong";
|
||||
} catch (_) {
|
||||
errorMessage = "Something Went Wrong";
|
||||
}
|
||||
} else {
|
||||
errorMessage = "Something Went Wrong";
|
||||
}
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
|
||||
if (isImps) {
|
||||
// IMPS
|
||||
final impsTx = ImpsTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown",
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
final impsService = getIt<ImpsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
if (!pinScreenContext.mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final impsResponse =
|
||||
await impsService.processImpsTransaction(impsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: impsResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: impsTx.toAccount,
|
||||
amount: impsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: impsResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} on DioException catch (e) {
|
||||
final error = e.response?.data['error'];
|
||||
var errorMessage = {
|
||||
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||
"INSUFFICIENT_FUNDS":
|
||||
"Your account does not have sufficient balance"
|
||||
}[error] ??
|
||||
"Something Went Wrong";
|
||||
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
|
||||
if (isRtgs) {
|
||||
// RTGS
|
||||
final rtgsTx = RtgsTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown",
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
final rtgsService = getIt<RtgsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
if (!pinScreenContext.mounted) {
|
||||
return;
|
||||
}
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final rtgsResponse =
|
||||
await rtgsService.processRtgsTransaction(rtgsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: rtgsResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: rtgsTx.toAccount,
|
||||
amount: rtgsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: rtgsResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} on DioException catch (e) {
|
||||
log('dio exception');
|
||||
|
||||
final error = e.response?.data['error'];
|
||||
var errorMessage = {
|
||||
"INCORRECT_TPIN": "Please Enter the correct TPIN",
|
||||
"INSUFFICIENT_FUNDS":
|
||||
"Your account does not have sufficient balance"
|
||||
}[error] ??
|
||||
"Something Went Wrong";
|
||||
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: errorMessage,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).quickPayOutsideBank,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
@@ -103,42 +384,55 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
child: ListView(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).debitFrom),
|
||||
Text(
|
||||
widget.debitAccount,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
AppLocalizations.of(context).debitFrom,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ListTile(
|
||||
leading: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
title: Text(widget.debitAccount),
|
||||
subtitle: Text(AppLocalizations.of(context).ownBank),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).accountNumber,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
controller: accountNumberController,
|
||||
keyboardType: TextInputType.number,
|
||||
obscureText: true,
|
||||
textInputAction: TextInputAction.next,
|
||||
onChanged: (value) {
|
||||
nameController.clear();
|
||||
setState(() {
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).accountNumberRequired;
|
||||
} else if (value.length != 11) {
|
||||
return AppLocalizations.of(context).validAccountNumber;
|
||||
} else if (value.length < 7 || value.length > 20) {
|
||||
return AppLocalizations.of(context).accno7to20;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -149,15 +443,17 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).confirmAccountNumber,
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
@@ -173,133 +469,89 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).name,
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: nameController,
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).nameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).bankName,
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: bankNameController,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).bankNameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).branchName,
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: branchNameController,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).branchNameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
maxLength: 11,
|
||||
inputFormatters: [
|
||||
LengthLimitingTextInputFormatter(11),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).ifscCode,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2),
|
||||
),
|
||||
),
|
||||
controller: ifscController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
_validateIFSC();
|
||||
},
|
||||
onChanged: (value) {
|
||||
final trimmed = value.trim().toUpperCase();
|
||||
if (trimmed.length < 11) {
|
||||
// clear bank/branch if backspace or changed
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).ifscRequired;
|
||||
final pattern = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$');
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return AppLocalizations.of(context).enterIfsc;
|
||||
} else if (!pattern.hasMatch(
|
||||
value.trim().toUpperCase(),
|
||||
)) {
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).invalidIfscFormat;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Expanded(
|
||||
child: DropdownButtonFormField<String>(
|
||||
value: accountType,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).accountType,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2),
|
||||
),
|
||||
),
|
||||
items:
|
||||
[
|
||||
AppLocalizations.of(context).savings,
|
||||
AppLocalizations.of(context).current,
|
||||
]
|
||||
.map(
|
||||
(e) =>
|
||||
DropdownMenuItem(value: e, child: Text(e)),
|
||||
)
|
||||
.toList(),
|
||||
items: [
|
||||
'Savings',
|
||||
'Current',
|
||||
]
|
||||
.map(
|
||||
(e) => DropdownMenuItem(value: e, child: Text(e)),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) => setState(() {
|
||||
accountType = value!;
|
||||
}),
|
||||
@@ -308,6 +560,114 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
controller: bankNameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).bankName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
controller: branchNameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).branchName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!_isBeneficiaryValidated)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isValidating
|
||||
? null
|
||||
: () {
|
||||
if (confirmAccountNumberController.text ==
|
||||
accountNumberController.text) {
|
||||
_validateBeneficiary();
|
||||
} else {
|
||||
setState(() {
|
||||
_validationError =
|
||||
AppLocalizations.of(context)
|
||||
.accountMismatch;
|
||||
});
|
||||
}
|
||||
},
|
||||
child: _isValidating
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: Text(
|
||||
AppLocalizations.of(context).validateBeneficiary),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_validationError != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: Text(
|
||||
_validationError!,
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
controller: nameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).name,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).nameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -316,16 +676,19 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
keyboardType: TextInputType.phone,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).phone,
|
||||
prefixIcon: Icon(Icons.phone),
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.phone),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2),
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
@@ -339,15 +702,18 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).amount,
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
width: 2),
|
||||
),
|
||||
),
|
||||
controller: amountController,
|
||||
@@ -372,7 +738,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).transactionMode,
|
||||
style: TextStyle(fontWeight: FontWeight.w500),
|
||||
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: buildTransactionModeSelector()),
|
||||
@@ -382,38 +748,19 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: SwipeButton.expand(
|
||||
thumb: Icon(Icons.arrow_forward, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
activeThumbColor: Theme.of(context).primaryColorDark,
|
||||
activeTrackColor: Theme.of(context).primaryColorLight,
|
||||
thumb: Icon(Icons.arrow_forward,
|
||||
color: Theme.of(context).dialogBackgroundColor),
|
||||
activeThumbColor: Theme.of(context).colorScheme.primary,
|
||||
activeTrackColor:
|
||||
Theme.of(context).colorScheme.secondary.withAlpha(100),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
height: 56,
|
||||
onSwipe: _onProceedToPay,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).swipeToPay,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
onSwipe: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Perform payment logic
|
||||
final selectedMode = transactionModes(
|
||||
context,
|
||||
)[selectedTransactionIndex];
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'${AppLocalizations.of(context).payingVia} $selectedMode...',
|
||||
),
|
||||
),
|
||||
);
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// const TransactionPinScreen(
|
||||
// transactionData: {},
|
||||
// transactionCode: 'PAYMENT',
|
||||
// )));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -438,17 +785,22 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Theme.of(context).primaryColor : Theme.of(context).scaffoldBackgroundColor,
|
||||
color: isSelected
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: isSelected ? Theme.of(context).primaryColor : Theme.of(context).scaffoldBackgroundColor,
|
||||
color: isSelected
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).scaffoldBackgroundColor,
|
||||
width: isSelected ? 0 : 1.2,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
transactionModes(context)[index],
|
||||
style: const TextStyle(color: Colors.black),
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).colorScheme.onSurface),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_outside_bank_screen.dart';
|
||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_within_bank_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
@@ -18,33 +17,9 @@ class _QuickPayScreen extends State<QuickPayScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).quickPay.replaceAll('\n', ' '),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
AppLocalizations.of(context).quickPay.replaceAll('\n', ''),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
@@ -64,7 +39,6 @@ class _QuickPayScreen extends State<QuickPayScreen> {
|
||||
),
|
||||
const Divider(height: 1),
|
||||
QuickPayManagementTile(
|
||||
disable: true,
|
||||
icon: Symbols.output_circle,
|
||||
label: AppLocalizations.of(context).outsideBank,
|
||||
onTap: () {
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../fund_transfer/screens/transaction_pin_screen.dart';
|
||||
//import 'package:flutter_neumorphic/flutter_neumorphic.dart';
|
||||
|
||||
class QuickPayWithinBankScreen extends StatefulWidget {
|
||||
final String debitAccount;
|
||||
@@ -88,33 +88,13 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).quickPayOwnBank,
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Colors.grey[200],
|
||||
radius: 20,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/avatar_male.svg',
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -145,11 +125,13 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
controller: accountNumberController,
|
||||
@@ -165,15 +147,6 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
// const Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(left: 15.0, top: 5),
|
||||
// child: Text(
|
||||
// 'Beneficiary Account Number',
|
||||
// style: TextStyle(color: Colors.black54),
|
||||
// ),
|
||||
// )),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
controller: confirmAccountNumberController,
|
||||
@@ -184,11 +157,13 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
@@ -219,7 +194,8 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
} else {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Please enter a valid and matching account number.';
|
||||
AppLocalizations.of(context)
|
||||
.accountMismatch;
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -229,7 +205,8 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Text('Validate Beneficiary'),
|
||||
: Text(
|
||||
AppLocalizations.of(context).validateBeneficiary),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -241,7 +218,7 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
const Icon(Icons.check_circle, color: Colors.green),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Beneficiary: $_beneficiaryName',
|
||||
'${AppLocalizations.of(context).beneficiaryName}: $_beneficiaryName',
|
||||
style: const TextStyle(
|
||||
color: Colors.green, fontWeight: FontWeight.bold),
|
||||
),
|
||||
@@ -266,11 +243,13 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
value: _selectedAccountType,
|
||||
@@ -296,15 +275,6 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
// const Align(
|
||||
// alignment: Alignment.topLeft,
|
||||
// child: Padding(
|
||||
// padding: EdgeInsets.only(left: 15.0, top: 5),
|
||||
// child: Text(
|
||||
// 'Beneficiary Account Type',
|
||||
// style: TextStyle(color: Colors.black54),
|
||||
// ),
|
||||
// )),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
@@ -313,11 +283,13 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
controller: amountController,
|
||||
@@ -338,8 +310,9 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: SwipeButton.expand(
|
||||
thumb: Icon(Icons.arrow_forward, color: Theme.of(context).dialogBackgroundColor),
|
||||
activeThumbColor: Theme.of(context).primaryColor,
|
||||
thumb: Icon(Icons.arrow_forward,
|
||||
color: Theme.of(context).dialogBackgroundColor),
|
||||
activeThumbColor: Theme.of(context).colorScheme.primary,
|
||||
activeTrackColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.secondary.withAlpha(100),
|
||||
@@ -353,8 +326,8 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
if (!_isBeneficiaryValidated) {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Please validate beneficiary before proceeding.';
|
||||
_validationError = AppLocalizations.of(context)
|
||||
.validateBeneficiaryproceeding;
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -363,12 +336,26 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
transactionData: Transfer(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
toAccountType: _selectedAccountType!,
|
||||
amount: amountController.text,
|
||||
),
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
final transfer = Transfer(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
toAccountType: _selectedAccountType!,
|
||||
amount: amountController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
|
||||
final paymentService = getIt<PaymentService>();
|
||||
final paymentResponseFuture = paymentService
|
||||
.processQuickPayWithinBank(transfer);
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: paymentResponseFuture),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -376,69 +363,6 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
},
|
||||
),
|
||||
),
|
||||
/*Align(
|
||||
alignment: Alignment.center,
|
||||
child: NeumorphicButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
if (!_isBeneficiaryValidated) {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Please validate beneficiary before proceeding.';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform payment logic
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
transactionData: Transfer(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
toAccountType: _selectedAccountType!,
|
||||
amount: amountController.text,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
style: NeumorphicStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
depth: 4,
|
||||
intensity: 0.8,
|
||||
boxShape: NeumorphicBoxShape.roundRect(BorderRadius.circular(30)),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).swipeToPay,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),*/
|
||||
// SliderButton(
|
||||
// action: () async {
|
||||
// ///Do something here OnSlide
|
||||
// return true;
|
||||
// },
|
||||
// label: const Text(
|
||||
// "Slide to pay",
|
||||
// style: TextStyle(
|
||||
// color: Color(0xff4a4a4a),
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontSize: 17),
|
||||
// ),
|
||||
// icon: Icon(Symbols.arrow_forward,
|
||||
// color: Theme.of(context).primaryColor, weight: 200),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -462,11 +386,12 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).colorScheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
35
lib/features/security/security_error_screen.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
|
||||
class SecurityErrorScreen extends StatelessWidget {
|
||||
final String message;
|
||||
|
||||
const SecurityErrorScreen({Key? key, required this.message}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Lottie.asset('assets/animations/error.json', height: 200),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
ElevatedButton(
|
||||
onPressed: () => SystemChannels.platform.invokeMethod('SystemNavigator.pop'),
|
||||
child: const Text('Okay'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
124
lib/features/service/screens/branch_locator_screen.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Branch {
|
||||
final String name;
|
||||
final String code;
|
||||
final String ifsc;
|
||||
final String address;
|
||||
|
||||
Branch({
|
||||
required this.name,
|
||||
required this.code,
|
||||
required this.ifsc,
|
||||
required this.address,
|
||||
});
|
||||
}
|
||||
|
||||
class BranchLocatorScreen extends StatefulWidget {
|
||||
const BranchLocatorScreen({super.key});
|
||||
|
||||
@override
|
||||
State<BranchLocatorScreen> createState() => _BranchLocatorScreenState();
|
||||
}
|
||||
|
||||
class _BranchLocatorScreenState extends State<BranchLocatorScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
|
||||
// Static list of 2 branches
|
||||
final List<Branch> _branches = [
|
||||
Branch(
|
||||
name: "Dharamsala - Head Office",
|
||||
code: "002",
|
||||
ifsc: "KACE0000002",
|
||||
address: "Civil Lines Dharmashala, Kangra, HP - 176215"),
|
||||
Branch(
|
||||
name: "Kangra",
|
||||
code: "033",
|
||||
ifsc: "KACE0000033",
|
||||
address: "Rajput Bhawankangrapo, Kangra, HP "),
|
||||
];
|
||||
|
||||
List<Branch> _filteredBranches = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_filteredBranches = _branches; // Initially show all branches
|
||||
}
|
||||
|
||||
void _filterBranches(String query) {
|
||||
setState(() {
|
||||
if (query.isEmpty) {
|
||||
_filteredBranches = _branches;
|
||||
} else {
|
||||
_filteredBranches = _branches.where((branch) {
|
||||
final lowerQuery = query.toLowerCase();
|
||||
return branch.name.toLowerCase().contains(lowerQuery) ||
|
||||
branch.code.toLowerCase().contains(lowerQuery) ||
|
||||
branch.ifsc.toLowerCase().contains(lowerQuery) ||
|
||||
branch.address.toLowerCase().contains(lowerQuery);
|
||||
}).toList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context).branchLocator),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// Search bar
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
onChanged: _filterBranches,
|
||||
decoration: InputDecoration(
|
||||
hintText: AppLocalizations.of(context).searchbranchby,
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// List of branches
|
||||
Expanded(
|
||||
child: _filteredBranches.isEmpty
|
||||
? const Center(child: Text("No matching branches found"))
|
||||
: ListView.builder(
|
||||
itemCount: _filteredBranches.length,
|
||||
itemBuilder: (context, index) {
|
||||
final branch = _filteredBranches[index];
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 6),
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.location_city,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
title: Text(branch.name,
|
||||
style:
|
||||
const TextStyle(fontWeight: FontWeight.bold)),
|
||||
subtitle: Text(
|
||||
"Code: ${branch.code} | IFSC: ${branch.ifsc} \nBranch Address: ${branch.address}"),
|
||||
onTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Selected ${branch.name}")),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,3 +1,5 @@
|
||||
import 'package:kmobile/features/service/screens/branch_locator_screen.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -18,33 +20,8 @@ class _ServiceScreen extends State<ServiceScreen> {
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text(
|
||||
AppLocalizations.of(context).services,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
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: ListView(
|
||||
children: [
|
||||
@@ -69,7 +46,12 @@ class _ServiceScreen extends State<ServiceScreen> {
|
||||
ServiceManagementTile(
|
||||
icon: Symbols.missing_controller,
|
||||
label: AppLocalizations.of(context).branchLocator,
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const BranchLocatorScreen()));
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
],
|
||||
|
@@ -4,7 +4,7 @@ class Transaction {
|
||||
final double amount;
|
||||
final DateTime date;
|
||||
final String category;
|
||||
|
||||
|
||||
Transaction({
|
||||
required this.id,
|
||||
required this.description,
|
||||
@@ -12,4 +12,4 @@ class Transaction {
|
||||
required this.date,
|
||||
required this.category,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -25,10 +25,10 @@
|
||||
"hi": "Hi",
|
||||
"kMobile": "kMobile",
|
||||
"scanBiometric": "Scan to enable Biometric login",
|
||||
"savingsAccount": "Savings Account",
|
||||
"loanAccount": "Loan Account",
|
||||
"termDeposit": "Term Deposit Account",
|
||||
"recurringDeposit": "Recurring Deposit Account",
|
||||
"savingsAccount": "Savings",
|
||||
"loanAccount": "Loan",
|
||||
"termDeposit": "Term Deposit",
|
||||
"recurringDeposit": "Recurring Deposit",
|
||||
"unknownAccount": "Unknown Account Type",
|
||||
"customerInfo": "Customer \n Info",
|
||||
"fundTransfer": "Fund \n Transfer",
|
||||
@@ -109,9 +109,8 @@
|
||||
"gmNorth": "General Manager (North)",
|
||||
"enquiry": "Enquiry",
|
||||
"fundTransferBeneficiary": "Fund Transfer - Beneficiary",
|
||||
"fundTransfer": "Fund Transfer",
|
||||
"enterAmount": "Enter Amount",
|
||||
"accountInfo": "Account Info",
|
||||
"accountInfo": "Account \n Info",
|
||||
"customerNumber": "Customer Number",
|
||||
"productName": "Product Name",
|
||||
"accountStatus": "Account Status",
|
||||
@@ -229,6 +228,69 @@
|
||||
"beneficiaryAddedSuccess": "Beneficiary Added Successfully",
|
||||
"beneficiaryAdditionFailed": "Beneficiary Addition Failed",
|
||||
"noBeneficiaryFound": "No beneficiaries found",
|
||||
"beneficiaryName": "Beneficiary Name"
|
||||
"beneficiaryName": "Beneficiary Name",
|
||||
"validateBeneficiary": "Validate Beneficiary",
|
||||
"themeMode": "Theme Mode",
|
||||
"transactionDetails": "Transaction Details",
|
||||
"transactionType": "Transaction Type",
|
||||
"transferType": "Transfer Type",
|
||||
"utrNo": "UTR No.",
|
||||
"beneficiaryAccountNo": "Beneficiary Account No.",
|
||||
"invalidRtgs": "Invalid Amount for RTGS",
|
||||
"invalidRtgsPopUp": "RTGS transactions require a minimum amount of 200,000. Please enter a higher amount or select NEFT as the transaction mode.",
|
||||
"correctTpin": "Please Enter the correct TPIN",
|
||||
"insufficientFund": "Your account does not have sufficient balance",
|
||||
"creditedTo": "Credit To",
|
||||
"selectTransactionType": "Select transaction Type",
|
||||
"proceed": "Proceed",
|
||||
"plsValidateBeneficiary": "Please validate beneficiary details first",
|
||||
"accno7to20": "Account number must be between 7 and 20 digits",
|
||||
"validateBeneficiaryproceeding": "Please validate beneficiary before proceeding",
|
||||
"findnearbybranched": "Find nearby branches",
|
||||
"searchbranch": "Search Branch",
|
||||
"searchbranchby": "Search by Branch Name / Code / IFSC",
|
||||
"branchsearchsoon": "Branch search coming soon...",
|
||||
"loginFailed": "Login failed",
|
||||
"invalidCredentials": "Invalid credentials",
|
||||
"networkErrorDuringLogin": "Network error during login",
|
||||
"unexpectedErrorDuringLogin": "Unexpected error during login",
|
||||
"tokenRefreshFailed": "Token refresh failed",
|
||||
"failedToRefreshToken": "Failed to refresh token",
|
||||
"failedToCheckTpinStatus": "Failed to check TPIN status",
|
||||
"networkErrorDuringTpinCheck": "Network error during TPIN check",
|
||||
"unexpectedErrorDuringTpinCheck": "Unexpected error during TPIN check",
|
||||
"failedToSetTpin": "Failed to set TPIN",
|
||||
"networkErrorDuringTpinSetup": "Network error during TPIN setup",
|
||||
"unexpectedErrorDuringTpinSetup": "Unexpected error during TPIN setup",
|
||||
"failedToValidateBeneficiary": "Failed to validate beneficiary",
|
||||
"networkError": "Network error",
|
||||
"unexpectedError": "Unexpected error: ",
|
||||
"invalidIfscCode": "INVALID IFSC CODE",
|
||||
"invalidBeneficiaryDetails": "Invalid Beneficiary Details",
|
||||
"failedToFetchBeneficiaries": "Failed to fetch beneficiaries",
|
||||
"failedToDeleteBeneficiary": "Failed to delete beneficiary",
|
||||
"impsTransactionFailedWithStatusCode": "IMPS transaction failed with status code: ",
|
||||
"anUnexpectedErrorOccurred": "An unexpected error occurred: ",
|
||||
"neftTransactionFailedWithStatusCode": "NEFT transaction failed with status code: ",
|
||||
"unknownError": "Unknown error",
|
||||
"failedToProcessQuickPayWithinBank": "Failed to process quick pay within bank: ",
|
||||
"rtgsTransactionFailedWithStatusCode": "RTGS transaction failed with status code: ",
|
||||
"failedToLoadCustomerDetails": "Failed to load customer details",
|
||||
"routeNotFound": "Route not found!",
|
||||
"pleaseValidateBeneficiaryDetailsFirst": "Please validate beneficiary details first.",
|
||||
"beneficiaryAlreadyExists": "Beneficiary already exists",
|
||||
"pleaseEnterAValidAndMatchingAccountNumber": "Please enter a valid and matching account number.",
|
||||
"beneficiaryDeletedSuccessfully": "Beneficiary deleted successfully",
|
||||
"areYouSureYouWantToDeleteThisBeneficiary": "Are you sure you want to delete this beneficiary?",
|
||||
"yourAccountDoesNotHaveSufficientBalance": "Your account does not have sufficient balance",
|
||||
"green": "Green",
|
||||
"orange": "Orange",
|
||||
"deleteBeneficiary": "Delete Beneficiary",
|
||||
"beneficiarydetails": "Beneficiary Details",
|
||||
"delete": "Delete",
|
||||
"search": "Search",
|
||||
"viewCardDeatils": "View Card Details",
|
||||
"logout": "Logout",
|
||||
"logoutCheck": "Are you sure you want to logout?",
|
||||
"changePassword": "Change Password"
|
||||
}
|
||||
|
||||
|
@@ -229,5 +229,69 @@
|
||||
"beneficiaryAddedSuccess": "लाभार्थी सफलतापूर्वक जोड़ा गया",
|
||||
"beneficiaryAdditionFailed": "लाभार्थी जोड़ने में विफल",
|
||||
"noBeneficiaryFound": "कोई लाभार्थी नहीं मिला",
|
||||
"beneficiaryName": "लाभार्थी नाम"
|
||||
"beneficiaryName": "लाभार्थी नाम",
|
||||
"validateBeneficiary": "लाभार्थी को सत्यापित करें",
|
||||
"themeMode": "थीम मोड",
|
||||
"transactionDetails": "लेन-देन विवरण",
|
||||
"transactionType": "लेनदेन प्रकार",
|
||||
"transferType": "स्थानांतरण प्रकार",
|
||||
"utrNo": "यूटीआर नंबर",
|
||||
"beneficiaryAccountNo": "लाभार्थी खाता संख्या",
|
||||
"invalidRtgs": "RTGS के लिए अमान्य राशि",
|
||||
"invalidRtgsPopUp": "RTGS लेनदेन के लिए न्यूनतम 2,00,000 रुपये की राशि की आवश्यकता होती है। कृपया अधिक राशि दर्ज करें या लेनदेन मोड के रूप में NEFT चुनें",
|
||||
"correctTpin": "कृपया सही टी-पिन दर्ज करें",
|
||||
"insufficientFund": "आपके खाते में पर्याप्त शेष राशि नहीं है",
|
||||
"creditedTo": "को श्रेय",
|
||||
"selectTransactionType": "लेन-देन का प्रकार चुनें",
|
||||
"proceed": "आगे बढ़ना",
|
||||
"plsValidateBeneficiary": "कृपया पहले लाभार्थी विवरण सत्यापित करें",
|
||||
"accno7to20": "खाता संख्या सात से बीस अंकों के बीच होनी चाहिए",
|
||||
"validateBeneficiaryproceeding": "कृपया आगे बढ़ने से पहले लाभार्थी को पट्टे पर मान्य करें",
|
||||
"findnearbybranched": "आस-पास की शाखाएँ खोजें",
|
||||
"searchbranch": "शाखा खोजें",
|
||||
"searchbranchby": "शाखा खोजें नाम / बैंक कोड / आईएफएससी द्वारा",
|
||||
"branchsearchsoon": "शाखा खोज सुविधा जल्द ही आ रही है...",
|
||||
"loginFailed": "लॉगिन विफल",
|
||||
"invalidCredentials": "अवैध प्रत्यय पत्र",
|
||||
"networkErrorDuringLogin": "लॉगिन के दौरान नेटवर्क त्रुटि",
|
||||
"unexpectedErrorDuringLogin": "लॉगिन के दौरान अप्रत्याशित त्रुटि",
|
||||
"tokenRefreshFailed": "टोकन ताज़ा विफल रहा",
|
||||
"failedToRefreshToken": "टोकन रीफ़्रेश करने में विफल",
|
||||
"failedToCheckTpinStatus": "टी-पिन स्थिति की जाँच करने में विफल",
|
||||
"networkErrorDuringTpinCheck": "टी-पिन जाँच के दौरान नेटवर्क त्रुटि",
|
||||
"unexpectedErrorDuringTpinCheck": "TPIN जाँच के दौरान अप्रत्याशित त्रुटि",
|
||||
"failedToSetTpin": "Tpin सेट करने में विफल",
|
||||
"networkErrorDuringTpinSetup": "Tpin सेटअप के दौरान नेटवर्क त्रुटि",
|
||||
"unexpectedErrorDuringTpinSetup": "TPIN सेटअप के दौरान अप्रत्याशित त्रुटि",
|
||||
"failedToValidateBeneficiary": "लाभार्थी को सत्यापित करने में विफल",
|
||||
"networkError": "नेटवर्क त्रुटि",
|
||||
"unexpectedError": "अप्रत्याशित त्रुटि:",
|
||||
"invalidIfscCode": "अमान्य IFSC कोड",
|
||||
"invalidBeneficiaryDetails": "अमान्य लाभार्थी विवरण",
|
||||
"failedToFetchBeneficiaries": "लाभार्थियों को प्राप्त करने में विफल",
|
||||
"failedToDeleteBeneficiary": "लाभार्थी को हटाने में विफल",
|
||||
"impsTransactionFailedWithStatusCode": "IMPS लेन-देन स्थिति कोड के साथ विफल:",
|
||||
"anUnexpectedErrorOccurred": "एक अप्रत्याशित त्रुटि हुई:",
|
||||
"neftTransactionFailedWithStatusCode": "NEFT लेन-देन स्थिति कोड के साथ विफल:",
|
||||
"unknownError": "अज्ञात त्रुटि",
|
||||
"failedToProcessQuickPayWithinBank": "बैंक के भीतर क्विक पे संसाधित करने में विफल:",
|
||||
"rtgsTransactionFailedWithStatusCode": "RTGS लेन-देन स्थिति कोड के साथ विफल:",
|
||||
"failedToLoadCustomerDetails": "ग्राहक विवरण लोड करने में विफल",
|
||||
"routeNotFound": "रूट नहीं मिला!",
|
||||
"pleaseValidateBeneficiaryDetailsFirst": "कृपया पहले लाभार्थी विवरण सत्यापित करें।",
|
||||
"beneficiaryAlreadyExists": "लाभार्थी पहले से मौजूद है",
|
||||
"pleaseEnterAValidAndMatchingAccountNumber": "कृपया एक मान्य और मिलान करने वाला खाता संख्या दर्ज करें।",
|
||||
"beneficiaryDeletedSuccessfully": "लाभार्थी सफलतापूर्वक हटाया गया।",
|
||||
"areYouSureYouWantToDeleteThisBeneficiary": "क्या आप वाकई इस लाभार्थी को हटाना चाहते हैं?",
|
||||
"yourAccountDoesNotHaveSufficientBalance": "आपके खाते में पर्याप्त शेष राशि नहीं है",
|
||||
"green": "हरा",
|
||||
"orange": "नारंगी",
|
||||
"deleteBeneficiary": "लाभार्थी हटाएं",
|
||||
"beneficiarydetails": "लाभार्थी विवरण",
|
||||
"delete": "मिटाओ",
|
||||
"search": "खोजें",
|
||||
"viewCardDeatils": "कार्ड विवरण देखें",
|
||||
"logout": "लॉग आउट",
|
||||
"logoutCheck": "क्या आप लॉग आउट करना चाहते हैं?",
|
||||
"changePassword": "पासवर्ड बदलें"
|
||||
}
|
||||
|