Compare commits
94 Commits
d4de89a91f
...
sim-bindin
| Author | SHA1 | Date | |
|---|---|---|---|
| f9fd74ea53 | |||
| 852f708633 | |||
| 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 | ||
| 3024ddef15 | |||
| 83609fb778 | |||
| dbc61abf00 | |||
| 763c101f58 | |||
| 117e2d5786 | |||
| ae40f61c01 | |||
| a1365b19d5 | |||
| 2dd7f4079b | |||
| 99e23bf21d | |||
| c4d4261afc | |||
|
|
2fdef7c850 | ||
|
|
618bd4a9b9 | ||
| ee3961215a | |||
| 787fcdc2e2 | |||
|
|
20791432dd | ||
|
|
23d742ace9 |
3
.gitignore
vendored
@@ -41,3 +41,6 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/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,
|
# The following line activates a set of recommended lints for Flutter apps,
|
||||||
# packages, and plugins designed to encourage good coding practices.
|
# packages, and plugins designed to encourage good coding practices.
|
||||||
|
analyzer:
|
||||||
|
errors:
|
||||||
|
dead_code: ignore
|
||||||
include: package:flutter_lints/flutter.yaml
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if (flutterVersionName == null) {
|
|||||||
android {
|
android {
|
||||||
namespace "com.example.kmobile"
|
namespace "com.example.kmobile"
|
||||||
compileSdk flutter.compileSdkVersion
|
compileSdk flutter.compileSdkVersion
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion "27.0.12077973"
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
@@ -53,9 +53,13 @@ android {
|
|||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
signingConfig signingConfigs.debug
|
||||||
|
minifyEnabled true
|
||||||
|
shrinkResources true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
|
||||||
|
'proguard-rules.pro'
|
||||||
// TODO: Add your own signing config for the release build.
|
// TODO: Add your own signing config for the release build.
|
||||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
signingConfig signingConfigs.debug
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
77
android/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# Keep Flutter embedding and plugin registrant (important)
|
||||||
|
-keep class io.flutter.embedding.** { *; }
|
||||||
|
-keep class io.flutter.plugins.** { *; }
|
||||||
|
-keep class io.flutter.plugin.** { *; }
|
||||||
|
-keep class io.flutter.app.** { *; }
|
||||||
|
|
||||||
|
# Keep Application / Activity if you customized them (replace with your package name)
|
||||||
|
# -keep class com.yourcompany.yourapp.MainActivity { *; }
|
||||||
|
# -keep class com.yourcompany.yourapp.** { *; }
|
||||||
|
|
||||||
|
# Keep classes referenced from AndroidManifest via reflection or lifecycle
|
||||||
|
-keepclassmembers class * {
|
||||||
|
@android.webkit.JavascriptInterface <methods>;
|
||||||
|
public <init>(android.content.Context, ...);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep native entry points (JNI) if any (example)
|
||||||
|
-keepclasseswithmembernames class * {
|
||||||
|
native <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep classes that use reflection heavily (OKHttp/Retrofit/Gson)
|
||||||
|
# Retrofit/OkHttp
|
||||||
|
-keep class okhttp3.** { *; }
|
||||||
|
-keep interface okhttp3.** { *; }
|
||||||
|
-keep class retrofit2.** { *; }
|
||||||
|
-keep interface retrofit2.** { *; }
|
||||||
|
|
||||||
|
# Gson (models accessed by reflection)
|
||||||
|
-keep class com.google.gson.** { *; }
|
||||||
|
-keepattributes Signature
|
||||||
|
-keepattributes *Annotation*
|
||||||
|
|
||||||
|
# Keep Firebase (if you use it)
|
||||||
|
-keep class com.google.firebase.** { *; }
|
||||||
|
-keep class com.google.android.gms.** { *; }
|
||||||
|
|
||||||
|
# WorkManager (if used)
|
||||||
|
-keep class androidx.work.impl.background.systemjob.SystemJobService { *; }
|
||||||
|
-keep class androidx.work.** { *; }
|
||||||
|
|
||||||
|
# Room/DB entities - if you use Room, keep annotations and entity classes
|
||||||
|
-keepclassmembers class * {
|
||||||
|
@androidx.room.* <fields>;
|
||||||
|
}
|
||||||
|
-keep class androidx.room.** { *; }
|
||||||
|
|
||||||
|
# Keep classes loaded by reflection (e.g. through Class.forName)
|
||||||
|
-keepclassmembers,includedescriptorclasses class * {
|
||||||
|
public static <fields>;
|
||||||
|
public <init>(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep Kotlin metadata (for Kotlin reflection)
|
||||||
|
-keep class kotlin.Metadata { *; }
|
||||||
|
|
||||||
|
# Keep names of classes annotated with @Keep
|
||||||
|
-keep @androidx.annotation.Keep class * { *; }
|
||||||
|
-keepclassmembers class * {
|
||||||
|
@androidx.annotation.Keep *;
|
||||||
|
}
|
||||||
|
|
||||||
|
# If using Gson TypeAdapterFactory via reflection
|
||||||
|
-keepclassmembers class * {
|
||||||
|
static ** typeAdapterFactory*(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Don't remove debug/logging if you want (optional)
|
||||||
|
#-keep class android.util.Log { *; }
|
||||||
|
|
||||||
|
# Keep any generated plugin registrant classes if present (older projects)
|
||||||
|
-keep class io.flutter.plugins.GeneratedPluginRegistrant { *; }
|
||||||
|
|
||||||
|
# (Optional) Keep parcelable implementations if those are serialized dynamically
|
||||||
|
-keep class * implements android.os.Parcelable {
|
||||||
|
public static final android.os.Parcelable$Creator *;
|
||||||
|
}
|
||||||
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 |
@@ -3,7 +3,7 @@ template-arb-file: app_en.arb
|
|||||||
output-localization-file: app_localizations.dart
|
output-localization-file: app_localizations.dart
|
||||||
output-class: AppLocalizations
|
output-class: AppLocalizations
|
||||||
use-deferred-loading: false
|
use-deferred-loading: false
|
||||||
|
synthetic-package: false
|
||||||
use-maybe-of: true
|
use-maybe-of: true
|
||||||
synthetic-package: true
|
|
||||||
nullable-getter : false
|
nullable-getter : false
|
||||||
untranslated-message-file: l10n_missing_translations.json
|
untranslated-message-file: l10n_missing_translations.json
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
|
// ignore_for_file: unused_local_variable
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import '../../data/repositories/auth_repository.dart';
|
import '../../data/repositories/auth_repository.dart';
|
||||||
|
|
||||||
class AuthInterceptor extends Interceptor {
|
class AuthInterceptor extends Interceptor {
|
||||||
final AuthRepository _authRepository;
|
final AuthRepository _authRepository;
|
||||||
final Dio _dio;
|
final Dio _dio;
|
||||||
|
|
||||||
AuthInterceptor(this._authRepository, this._dio);
|
AuthInterceptor(this._authRepository, this._dio);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onRequest(
|
Future<void> onRequest(
|
||||||
RequestOptions options,
|
RequestOptions options,
|
||||||
RequestInterceptorHandler handler,
|
RequestInterceptorHandler handler,
|
||||||
) async {
|
) async {
|
||||||
// Skip auth header for login and refresh endpoints
|
// Skip auth header for login and refresh endpoints
|
||||||
@@ -17,31 +19,38 @@ class AuthInterceptor extends Interceptor {
|
|||||||
options.path.contains('/auth/refresh')) {
|
options.path.contains('/auth/refresh')) {
|
||||||
return handler.next(options);
|
return handler.next(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get token and add to request
|
// Get token and add to request
|
||||||
final token = await _authRepository.getAccessToken();
|
final token = await _authRepository.getAccessToken();
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
options.headers['Authorization'] = 'Bearer $token';
|
options.headers['Authorization'] = 'Bearer $token';
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler.next(options);
|
return handler.next(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onError(
|
Future<void> onError(
|
||||||
DioException err,
|
DioException err,
|
||||||
ErrorInterceptorHandler handler,
|
ErrorInterceptorHandler handler,
|
||||||
) async {
|
) async {
|
||||||
// Handle 401 errors by refreshing token and retrying
|
// Handle 401 errors by refreshing token and retrying
|
||||||
if (err.response?.statusCode == 401) {
|
final response = err.response;
|
||||||
|
if (response?.statusCode == 401) {
|
||||||
|
final data = response?.data;
|
||||||
|
// Only refresh token if error is NOT INCORRECT_TPIN (or similar business error)
|
||||||
|
if (data is Map && data['error'] == 'INCORRECT_TPIN') {
|
||||||
|
// Pass the error through, do not retry
|
||||||
|
return handler.next(err);
|
||||||
|
}
|
||||||
// On 401, try to get a new token
|
// On 401, try to get a new token
|
||||||
final token = await _authRepository.getAccessToken();
|
final token = await _authRepository.getAccessToken();
|
||||||
|
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
// If we have a new token, retry the request
|
// If we have a new token, retry the request
|
||||||
final opts = err.requestOptions;
|
final opts = err.requestOptions;
|
||||||
opts.headers['Authorization'] = 'Bearer $token';
|
opts.headers['Authorization'] = 'Bearer $token';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await _dio.fetch(opts);
|
final response = await _dio.fetch(opts);
|
||||||
return handler.resolve(response);
|
return handler.resolve(response);
|
||||||
@@ -50,7 +59,7 @@ class AuthInterceptor extends Interceptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return handler.next(err);
|
return handler.next(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import '../../features/auth/models/auth_token.dart';
|
|||||||
import '../../features/auth/models/auth_credentials.dart';
|
import '../../features/auth/models/auth_credentials.dart';
|
||||||
import '../../core/errors/exceptions.dart';
|
import '../../core/errors/exceptions.dart';
|
||||||
|
|
||||||
|
|
||||||
class AuthService {
|
class AuthService {
|
||||||
final Dio _dio;
|
final Dio _dio;
|
||||||
AuthService(this._dio);
|
AuthService(this._dio);
|
||||||
@@ -15,7 +14,7 @@ class AuthService {
|
|||||||
'/api/auth/login',
|
'/api/auth/login',
|
||||||
data: credentials.toJson(),
|
data: credentials.toJson(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return AuthToken.fromJson(response.data);
|
return AuthToken.fromJson(response.data);
|
||||||
} else {
|
} else {
|
||||||
@@ -30,7 +29,8 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
throw NetworkException('Network error during login');
|
throw NetworkException('Network error during login');
|
||||||
} catch (e) {
|
} 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',
|
'/auth/refresh',
|
||||||
data: {'refresh_token': refreshToken},
|
data: {'refresh_token': refreshToken},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return AuthToken.fromJson(response.data);
|
return AuthToken.fromJson(response.data);
|
||||||
} else {
|
} else {
|
||||||
@@ -54,7 +54,7 @@ class AuthService {
|
|||||||
Future<bool> checkTpin() async {
|
Future<bool> checkTpin() async {
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get('/api/auth/tpin');
|
final response = await _dio.get('/api/auth/tpin');
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return response.data['tpinSet'] as bool;
|
return response.data['tpinSet'] as bool;
|
||||||
} else {
|
} else {
|
||||||
@@ -66,7 +66,8 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
throw NetworkException('Network error during TPIN check');
|
throw NetworkException('Network error during TPIN check');
|
||||||
} catch (e) {
|
} 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',
|
'/api/auth/tpin',
|
||||||
data: {'tpin': tpin},
|
data: {'tpin': tpin},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
throw AuthException('Failed to set TPIN');
|
throw AuthException('Failed to set TPIN');
|
||||||
}
|
}
|
||||||
@@ -86,8 +87,8 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
throw NetworkException('Network error during TPIN setup');
|
throw NetworkException('Network error during TPIN setup');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw UnexpectedException('Unexpected error during TPIN setup: ${e.toString()}');
|
throw UnexpectedException(
|
||||||
|
'Unexpected error during TPIN setup: ${e.toString()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
121
lib/api/services/beneficiary_service.dart
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:kmobile/data/models/ifsc.dart';
|
||||||
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
|
|
||||||
|
class BeneficiaryService {
|
||||||
|
final Dio _dio;
|
||||||
|
|
||||||
|
BeneficiaryService(this._dio);
|
||||||
|
|
||||||
|
Future<String> validateBeneficiaryWithinBank(String accountNumber) async {
|
||||||
|
try {
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
throw Exception('Network error: ${e.message}');
|
||||||
|
} catch (e) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
if (e.response?.statusCode == 404) {
|
||||||
|
throw Exception('INVALID IFSC CODE');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
return Ifsc.fromJson({});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> validateBeneficiary({
|
||||||
|
required String accountNo,
|
||||||
|
required String ifscCode,
|
||||||
|
required String remitterName,
|
||||||
|
}) async {
|
||||||
|
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<bool> sendForValidation(Beneficiary beneficiary) async {
|
||||||
|
try {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/beneficiary',
|
||||||
|
data: beneficiary.toJson(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Beneficiary>> fetchBeneficiaryList() async {
|
||||||
|
try {
|
||||||
|
final response = await _dio.get(
|
||||||
|
"/api/beneficiary",
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return Beneficiary.listFromJson(response.data);
|
||||||
|
} else {
|
||||||
|
throw Exception("Failed to fetch beneficiaries");
|
||||||
|
}
|
||||||
|
} catch (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()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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 'dart:developer';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:kmobile/data/models/payment_response.dart';
|
import 'package:kmobile/data/models/payment_response.dart';
|
||||||
import 'package:kmobile/data/models/transfer.dart';
|
import 'package:kmobile/data/models/transfer.dart';
|
||||||
@@ -11,8 +10,8 @@ class PaymentService {
|
|||||||
Future<PaymentResponse> processQuickPayWithinBank(Transfer transfer) async {
|
Future<PaymentResponse> processQuickPayWithinBank(Transfer transfer) async {
|
||||||
try {
|
try {
|
||||||
await Future.delayed(const Duration(seconds: 3)); // Simulate delay
|
await Future.delayed(const Duration(seconds: 3)); // Simulate delay
|
||||||
final response =
|
|
||||||
await _dio.post('/api/payment/transfer', data: transfer.toJson());
|
await _dio.post('/api/payment/transfer', data: transfer.toJson());
|
||||||
|
|
||||||
return PaymentResponse(
|
return PaymentResponse(
|
||||||
isSuccess: true,
|
isSuccess: true,
|
||||||
@@ -20,8 +19,6 @@ class PaymentService {
|
|||||||
creditedAccount: transfer.toAccount,
|
creditedAccount: transfer.toAccount,
|
||||||
amount: transfer.amount,
|
amount: transfer.amount,
|
||||||
currency: "INR",
|
currency: "INR",
|
||||||
errorMessage: response.data['errorMessage'],
|
|
||||||
errorCode: response.data['errorCode'],
|
|
||||||
);
|
);
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
log('DioException: ${e.toString()}');
|
log('DioException: ${e.toString()}');
|
||||||
|
|||||||
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()}');
|
throw Exception('Unexpected error: ${e.toString()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
364
lib/app.dart
@@ -4,19 +4,20 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import './l10n/app_localizations.dart';
|
||||||
import 'config/themes.dart';
|
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_state.dart';
|
||||||
import 'config/routes.dart';
|
import 'config/routes.dart';
|
||||||
import 'di/injection.dart';
|
import 'di/injection.dart';
|
||||||
import 'features/auth/controllers/auth_cubit.dart';
|
import 'features/auth/controllers/auth_cubit.dart';
|
||||||
import 'features/card/screens/card_management_screen.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/auth/screens/login_screen.dart';
|
||||||
import 'features/service/screens/service_screen.dart';
|
import 'features/service/screens/service_screen.dart';
|
||||||
import 'features/dashboard/screens/dashboard_screen.dart';
|
import 'features/dashboard/screens/dashboard_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
|
||||||
import 'features/auth/screens/mpin_screen.dart';
|
import 'features/auth/screens/mpin_screen.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class KMobile extends StatefulWidget {
|
class KMobile extends StatefulWidget {
|
||||||
const KMobile({super.key});
|
const KMobile({super.key});
|
||||||
@@ -32,20 +33,31 @@ class KMobile extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _KMobileState extends State<KMobile> {
|
class _KMobileState extends State<KMobile> {
|
||||||
bool _showSplash = false;
|
bool showSplash = true;
|
||||||
|
Locale? _locale;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
// Simulate a splash screen delay
|
loadPreferences();
|
||||||
Future.delayed(const Duration(seconds: 2), () {
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_showSplash = false;
|
showSplash = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Locale? _locale;
|
Future<void> loadPreferences() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
// Load Locale
|
||||||
|
final String? langCode = prefs.getString('locale');
|
||||||
|
if (langCode != null) {
|
||||||
|
setState(() {
|
||||||
|
_locale = Locale(langCode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setLocale(Locale locale) {
|
void setLocale(Locale locale) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -53,58 +65,8 @@ class _KMobileState extends State<KMobile> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Set status bar color
|
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
|
||||||
const SystemUiOverlayStyle(
|
|
||||||
statusBarColor: Colors.transparent,
|
|
||||||
statusBarIconBrightness: Brightness.dark,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (_showSplash) {
|
|
||||||
return MaterialApp(
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
locale: _locale,
|
|
||||||
supportedLocales: const [
|
|
||||||
Locale('en'),
|
|
||||||
Locale('hi'),
|
|
||||||
],
|
|
||||||
localizationsDelegates: const [
|
|
||||||
AppLocalizations.delegate,
|
|
||||||
GlobalMaterialLocalizations.delegate,
|
|
||||||
GlobalWidgetsLocalizations.delegate,
|
|
||||||
GlobalCupertinoLocalizations.delegate,
|
|
||||||
],
|
|
||||||
home: const SplashScreen(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return MultiBlocProvider(
|
|
||||||
providers: [
|
|
||||||
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
|
||||||
],
|
|
||||||
child: MaterialApp(
|
|
||||||
title: 'kMobile',
|
|
||||||
// debugShowCheckedModeBanner: false,
|
|
||||||
theme: AppThemes.lightTheme,
|
|
||||||
// darkTheme: AppThemes.darkTheme,
|
|
||||||
themeMode: ThemeMode.system, // Use system theme by default
|
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
|
||||||
initialRoute: AppRoutes.splash,
|
|
||||||
home: const AuthGate(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// Set status bar color
|
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(
|
||||||
const SystemUiOverlayStyle(
|
const SystemUiOverlayStyle(
|
||||||
statusBarColor: Colors.transparent,
|
statusBarColor: Colors.transparent,
|
||||||
@@ -115,27 +77,32 @@ class _KMobileState extends State<KMobile> {
|
|||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
||||||
|
BlocProvider<ThemeCubit>(create: (_) => ThemeCubit()),
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||||
debugShowCheckedModeBanner: false,
|
builder: (context, themeState) {
|
||||||
locale: _locale, // Use your existing locale variable
|
return MaterialApp(
|
||||||
supportedLocales: const [
|
debugShowCheckedModeBanner: false,
|
||||||
Locale('en'),
|
locale: _locale ?? const Locale('en'),
|
||||||
Locale('hi'),
|
supportedLocales: const [
|
||||||
],
|
Locale('en'),
|
||||||
localizationsDelegates: const [
|
Locale('hi'),
|
||||||
AppLocalizations.delegate,
|
],
|
||||||
GlobalMaterialLocalizations.delegate,
|
localizationsDelegates: const [
|
||||||
GlobalWidgetsLocalizations.delegate,
|
AppLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
],
|
GlobalWidgetsLocalizations.delegate,
|
||||||
title: 'kMobile',
|
GlobalCupertinoLocalizations.delegate,
|
||||||
theme: AppThemes.lightTheme,
|
],
|
||||||
// darkTheme: AppThemes.darkTheme,
|
title: 'kMobile',
|
||||||
themeMode: ThemeMode.system, // Use system theme by default
|
theme: themeState.getThemeData(),
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
//darkTheme: themeState.getThemeData(),
|
||||||
initialRoute: AppRoutes.splash,
|
themeMode: ThemeMode.light,
|
||||||
home: _showSplash ? const SplashScreen() : const AuthGate(),
|
onGenerateRoute: AppRoutes.generateRoute,
|
||||||
|
initialRoute: AppRoutes.splash,
|
||||||
|
home: showSplash ? const SplashScreen() : const AuthGate(),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -151,7 +118,6 @@ class AuthGate extends StatefulWidget {
|
|||||||
class _AuthGateState extends State<AuthGate> {
|
class _AuthGateState extends State<AuthGate> {
|
||||||
bool _checking = true;
|
bool _checking = true;
|
||||||
bool _isLoggedIn = false;
|
bool _isLoggedIn = false;
|
||||||
bool _showWelcome = true;
|
|
||||||
bool _hasMPin = false;
|
bool _hasMPin = false;
|
||||||
bool _biometricEnabled = false;
|
bool _biometricEnabled = false;
|
||||||
bool _biometricTried = false;
|
bool _biometricTried = false;
|
||||||
@@ -184,9 +150,13 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
final localAuth = LocalAuthentication();
|
final localAuth = LocalAuthentication();
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
final canCheck = await localAuth.canCheckBiometrics;
|
||||||
if (!canCheck) return false;
|
if (!canCheck) return false;
|
||||||
|
String localizedReason = "";
|
||||||
|
if (mounted) {
|
||||||
|
localizedReason = AppLocalizations.of(context).authenticateToAccess;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
final didAuth = await localAuth.authenticate(
|
final didAuth = await localAuth.authenticate(
|
||||||
localizedReason: AppLocalizations.of(context).authenticateToAccess,
|
localizedReason: localizedReason,
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
@@ -198,106 +168,6 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (_checking) {
|
|
||||||
return const SplashScreen();
|
|
||||||
}
|
|
||||||
if (_isLoggedIn) {
|
|
||||||
if (_hasMPin) {
|
|
||||||
if (_biometricEnabled) {
|
|
||||||
return FutureBuilder<bool>(
|
|
||||||
future: _tryBiometric(),
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
||||||
return const SplashScreen();
|
|
||||||
}
|
|
||||||
if (snapshot.data == true) {
|
|
||||||
// Authenticated with biometrics, go to dashboard
|
|
||||||
return const NavigationScaffold();
|
|
||||||
}
|
|
||||||
// If not authenticated or user dismissed, show mPIN screen
|
|
||||||
return MPinScreen(
|
|
||||||
mode: MPinMode.enter,
|
|
||||||
onCompleted: (_) {
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => const NavigationScaffold()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return MPinScreen(
|
|
||||||
mode: MPinMode.enter,
|
|
||||||
onCompleted: (_) {
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return MPinScreen(
|
|
||||||
mode: MPinMode.set,
|
|
||||||
onCompleted: (_) async {
|
|
||||||
final storage = getIt<SecureStorage>();
|
|
||||||
final localAuth = LocalAuthentication();
|
|
||||||
|
|
||||||
// 1) Prompt user to opt‐in for biometric
|
|
||||||
final optIn = await showDialog<bool>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false, // force choice
|
|
||||||
builder: (ctx) => AlertDialog(
|
|
||||||
title: const Text('Enable Fingerprint Login?'),
|
|
||||||
content: const Text(
|
|
||||||
'Would you like to enable fingerprint authentication for faster login?',
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(ctx).pop(false),
|
|
||||||
child: const Text('No'),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
|
||||||
child: const Text('Yes'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 2) If opted in, perform biometric auth
|
|
||||||
if (optIn == true) {
|
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
|
||||||
bool didAuth = false;
|
|
||||||
if (canCheck) {
|
|
||||||
didAuth = await localAuth.authenticate(
|
|
||||||
localizedReason: 'Authenticate to enable fingerprint login',
|
|
||||||
options: const AuthenticationOptions(
|
|
||||||
stickyAuth: true,
|
|
||||||
biometricOnly: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await storage.write(
|
|
||||||
'biometric_enabled', didAuth ? 'true' : 'false');
|
|
||||||
} else {
|
|
||||||
await storage.write('biometric_enabled', 'false');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3) Finally go to your main scaffold
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return const LoginScreen();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_checking) {
|
if (_checking) {
|
||||||
@@ -318,7 +188,6 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
return const NavigationScaffold(); // Authenticated
|
return const NavigationScaffold(); // Authenticated
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failed or dismissed biometric → Show MPIN
|
|
||||||
return MPinScreen(
|
return MPinScreen(
|
||||||
mode: MPinMode.enter,
|
mode: MPinMode.enter,
|
||||||
onCompleted: (_) {
|
onCompleted: (_) {
|
||||||
@@ -349,15 +218,15 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
onCompleted: (_) async {
|
onCompleted: (_) async {
|
||||||
final storage = getIt<SecureStorage>();
|
final storage = getIt<SecureStorage>();
|
||||||
final localAuth = LocalAuthentication();
|
final localAuth = LocalAuthentication();
|
||||||
final optin = await showDialog<bool>(
|
|
||||||
|
final optIn = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
title:
|
title:
|
||||||
Text(AppLocalizations.of(context).enableFingerprintLogin),
|
Text(AppLocalizations.of(context).enableFingerprintLogin),
|
||||||
content: Text(
|
content:
|
||||||
AppLocalizations.of(context).enableFingerprintMessage,
|
Text(AppLocalizations.of(context).enableFingerprintMessage),
|
||||||
),
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop(false),
|
onPressed: () => Navigator.of(ctx).pop(false),
|
||||||
@@ -371,49 +240,40 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (optin == true) {
|
if (optIn == true) {
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
final canCheck = await localAuth.canCheckBiometrics;
|
||||||
bool didAuth = false;
|
bool didAuth = false;
|
||||||
|
String authEnable = "";
|
||||||
|
if (context.mounted) {
|
||||||
|
authEnable = AppLocalizations.of(context).authenticateToEnable;
|
||||||
|
}
|
||||||
|
|
||||||
if (canCheck) {
|
if (canCheck) {
|
||||||
didAuth = await localAuth.authenticate(
|
didAuth = await localAuth.authenticate(
|
||||||
localizedReason:
|
localizedReason: authEnable,
|
||||||
AppLocalizations.of(context).authenticateToEnable,
|
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
await storage.write(
|
||||||
|
'biometric_enabled', didAuth ? 'true' : 'false');
|
||||||
|
} else {
|
||||||
|
await storage.write('biometric_enabled', 'false');
|
||||||
}
|
}
|
||||||
|
|
||||||
await storage.write(
|
|
||||||
'biometric_enabled',
|
|
||||||
didAuth ? 'true' : 'false',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await storage.write('biometric_enabled', 'false');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.of(context).pushReplacement(
|
if (context.mounted) {
|
||||||
MaterialPageRoute(
|
Navigator.of(context).pushReplacement(
|
||||||
builder: (_) => const NavigationScaffold(),
|
MaterialPageRoute(
|
||||||
),
|
builder: (_) => const NavigationScaffold(),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🔻 Show Welcome screen before login if not logged in
|
|
||||||
if (_showWelcome) {
|
|
||||||
return WelcomeScreen(
|
|
||||||
onContinue: () {
|
|
||||||
setState(() {
|
|
||||||
_showWelcome = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return const LoginScreen();
|
return const LoginScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,13 +295,6 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
|||||||
const ServiceScreen(),
|
const ServiceScreen(),
|
||||||
];
|
];
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = index;
|
|
||||||
});
|
|
||||||
_pageController.jumpToPage(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return PopScope(
|
return PopScope(
|
||||||
@@ -480,45 +333,31 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
|||||||
children: _pages,
|
children: _pages,
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
currentIndex: _selectedIndex,
|
currentIndex: _selectedIndex,
|
||||||
type: BottomNavigationBarType.fixed,
|
type: BottomNavigationBarType.fixed,
|
||||||
backgroundColor: const Color(0xFFE0F7FA), // Light blue background
|
backgroundColor: Theme.of(context)
|
||||||
selectedItemColor: Colors.blue[800],
|
.scaffoldBackgroundColor, // Light blue background
|
||||||
unselectedItemColor: Colors.black54,
|
selectedItemColor: Theme.of(context).primaryColor,
|
||||||
onTap: _onItemTapped,
|
unselectedItemColor: Colors.black54,
|
||||||
items: [
|
onTap: (index) {
|
||||||
BottomNavigationBarItem(
|
setState(() {
|
||||||
icon: const Icon(Icons.home_filled),
|
_selectedIndex = index;
|
||||||
label: AppLocalizations.of(context).home,
|
});
|
||||||
),
|
_pageController.jumpToPage(index);
|
||||||
BottomNavigationBarItem(
|
},
|
||||||
icon: const Icon(Icons.credit_card),
|
items: [
|
||||||
label: AppLocalizations.of(context).card,
|
BottomNavigationBarItem(
|
||||||
),
|
icon: const Icon(Icons.home_filled),
|
||||||
BottomNavigationBarItem(
|
label: AppLocalizations.of(context).home,
|
||||||
icon: const Icon(Icons.miscellaneous_services),
|
),
|
||||||
label: AppLocalizations.of(context).services,
|
BottomNavigationBarItem(
|
||||||
),
|
icon: const Icon(Icons.credit_card),
|
||||||
]),
|
label: AppLocalizations.of(context).card,
|
||||||
),
|
),
|
||||||
);
|
BottomNavigationBarItem(
|
||||||
}
|
icon: const Icon(Icons.miscellaneous_services),
|
||||||
}
|
label: AppLocalizations.of(context).services,
|
||||||
|
),
|
||||||
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),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -538,8 +377,12 @@ class BiometricPromptScreen extends StatelessWidget {
|
|||||||
onCompleted();
|
onCompleted();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String localizedReason = "";
|
||||||
|
if (context.mounted) {
|
||||||
|
localizedReason = AppLocalizations.of(context).enableFingerprintQuick;
|
||||||
|
}
|
||||||
final didAuth = await localAuth.authenticate(
|
final didAuth = await localAuth.authenticate(
|
||||||
localizedReason: AppLocalizations.of(context).enableFingerprintQuick,
|
localizedReason: localizedReason,
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
@@ -583,6 +426,9 @@ class BiometricPromptScreen extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (!context.mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
await _handleBiometric(context);
|
await _handleBiometric(context);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/features/auth/screens/mpin_screen.dart';
|
import 'package:kmobile/features/auth/screens/mpin_screen.dart';
|
||||||
|
import 'package:kmobile/features/auth/screens/splash_screen.dart';
|
||||||
import '../app.dart';
|
import '../app.dart';
|
||||||
import '../features/auth/screens/login_screen.dart';
|
import '../features/auth/screens/login_screen.dart';
|
||||||
// import '../features/auth/screens/forgot_password_screen.dart';
|
// import '../features/auth/screens/forgot_password_screen.dart';
|
||||||
@@ -13,7 +14,7 @@ import '../features/dashboard/screens/dashboard_screen.dart';
|
|||||||
class AppRoutes {
|
class AppRoutes {
|
||||||
// Private constructor to prevent instantiation
|
// Private constructor to prevent instantiation
|
||||||
AppRoutes._();
|
AppRoutes._();
|
||||||
|
|
||||||
// Route names
|
// Route names
|
||||||
static const String splash = '/';
|
static const String splash = '/';
|
||||||
static const String login = '/login';
|
static const String login = '/login';
|
||||||
@@ -25,7 +26,7 @@ class AppRoutes {
|
|||||||
static const String accounts = '/accounts';
|
static const String accounts = '/accounts';
|
||||||
static const String transactions = '/transactions';
|
static const String transactions = '/transactions';
|
||||||
static const String payments = '/payments';
|
static const String payments = '/payments';
|
||||||
|
|
||||||
// Route generator
|
// Route generator
|
||||||
static Route<dynamic> generateRoute(RouteSettings settings) {
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
@@ -35,13 +36,16 @@ class AppRoutes {
|
|||||||
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
||||||
|
|
||||||
case mPin:
|
case mPin:
|
||||||
return MaterialPageRoute(builder: (_) => const MPinScreen(mode: MPinMode.enter,));
|
return MaterialPageRoute(
|
||||||
|
builder: (_) => const MPinScreen(
|
||||||
|
mode: MPinMode.enter,
|
||||||
|
));
|
||||||
|
|
||||||
case register:
|
case register:
|
||||||
// Placeholder - create the RegisterScreen class and uncomment
|
// Placeholder - create the RegisterScreen class and uncomment
|
||||||
// return MaterialPageRoute(builder: (_) => const RegisterScreen());
|
// return MaterialPageRoute(builder: (_) => const RegisterScreen());
|
||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
|
|
||||||
case forgotPassword:
|
case forgotPassword:
|
||||||
// Placeholder - create the ForgotPasswordScreen class and uncomment
|
// Placeholder - create the ForgotPasswordScreen class and uncomment
|
||||||
// return MaterialPageRoute(builder: (_) => const ForgotPasswordScreen());
|
// return MaterialPageRoute(builder: (_) => const ForgotPasswordScreen());
|
||||||
@@ -49,31 +53,30 @@ class AppRoutes {
|
|||||||
|
|
||||||
case navigationScaffold:
|
case navigationScaffold:
|
||||||
return MaterialPageRoute(builder: (_) => const NavigationScaffold());
|
return MaterialPageRoute(builder: (_) => const NavigationScaffold());
|
||||||
|
|
||||||
case dashboard:
|
case dashboard:
|
||||||
return MaterialPageRoute(builder: (_) => const DashboardScreen());
|
return MaterialPageRoute(builder: (_) => const DashboardScreen());
|
||||||
|
|
||||||
case accounts:
|
case accounts:
|
||||||
// Placeholder - create the AccountsScreen class and uncomment
|
// Placeholder - create the AccountsScreen class and uncomment
|
||||||
// return MaterialPageRoute(builder: (_) => const AccountsScreen());
|
// return MaterialPageRoute(builder: (_) => const AccountsScreen());
|
||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
|
|
||||||
case transactions:
|
case transactions:
|
||||||
// Placeholder - create the TransactionsScreen class and uncomment
|
// Placeholder - create the TransactionsScreen class and uncomment
|
||||||
// return MaterialPageRoute(builder: (_) => const TransactionsScreen());
|
// return MaterialPageRoute(builder: (_) => const TransactionsScreen());
|
||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
|
|
||||||
case payments:
|
case payments:
|
||||||
// Placeholder - create the PaymentsScreen class and uncomment
|
// Placeholder - create the PaymentsScreen class and uncomment
|
||||||
// return MaterialPageRoute(builder: (_) => const PaymentsScreen());
|
// return MaterialPageRoute(builder: (_) => const PaymentsScreen());
|
||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error route
|
// Error route
|
||||||
static Route<dynamic> _errorRoute() {
|
static Route<dynamic> _errorRoute() {
|
||||||
return MaterialPageRoute(builder: (_) {
|
return MaterialPageRoute(builder: (_) {
|
||||||
@@ -87,4 +90,4 @@ class AppRoutes {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
lib/config/theme_type.dart
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
enum ThemeType {
|
||||||
|
violet,
|
||||||
|
green,
|
||||||
|
orange,
|
||||||
|
blue,
|
||||||
|
}
|
||||||
@@ -1,266 +1,39 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'theme_type.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
class AppThemes {
|
class AppThemes {
|
||||||
// Private constructor to prevent instantiation
|
static ThemeData getLightTheme(ThemeType type) {
|
||||||
AppThemes._();
|
final Color seedColor;
|
||||||
|
switch (type) {
|
||||||
|
case ThemeType.green:
|
||||||
|
seedColor = Colors.green;
|
||||||
|
break;
|
||||||
|
case ThemeType.orange:
|
||||||
|
seedColor = Colors.orange;
|
||||||
|
break;
|
||||||
|
case ThemeType.blue:
|
||||||
|
seedColor = Colors.blue;
|
||||||
|
break;
|
||||||
|
case ThemeType.violet:
|
||||||
|
seedColor = Colors.deepPurple;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Light theme colors
|
final colorScheme = ColorScheme.fromSeed(
|
||||||
static const Color _primaryColorLight = Color(0xFF1E88E5); // Blue 600
|
seedColor: seedColor,
|
||||||
static const Color _secondaryColorLight = Color(0xFF26A69A); // Teal 400
|
brightness: Brightness.light, // Explicitly set for a light theme
|
||||||
static const Color _errorColorLight = Color(0xFFE53935); // Red 600
|
);
|
||||||
static const Color _surfaceColorLight = Colors.white;
|
|
||||||
|
|
||||||
// Dark theme colors
|
return ThemeData.from(
|
||||||
static const Color _primaryColorDark = Color(0xFF42A5F5); // Blue 400
|
colorScheme: colorScheme,
|
||||||
static const Color _secondaryColorDark = Color(0xFF4DB6AC); // Teal 300
|
useMaterial3: true, // Recommended for modern Flutter apps
|
||||||
static const Color _errorColorDark = Color(0xFFEF5350); // Red 400
|
textTheme: GoogleFonts.rubikTextTheme())
|
||||||
static const Color _surfaceColorDark = Color(0xFF1E1E1E);
|
.copyWith(
|
||||||
|
scaffoldBackgroundColor: Colors.white,
|
||||||
// Text themes
|
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
||||||
static const TextTheme _textThemeLight = TextTheme(
|
backgroundColor: colorScheme.surface,
|
||||||
displayLarge: TextStyle(
|
|
||||||
fontSize: 96,
|
|
||||||
fontWeight: FontWeight.w300,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
displayMedium: TextStyle(
|
|
||||||
fontSize: 60,
|
|
||||||
fontWeight: FontWeight.w300,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
displaySmall: TextStyle(
|
|
||||||
fontSize: 48,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
headlineMedium: TextStyle(
|
|
||||||
fontSize: 34,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
headlineSmall: TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
titleLarge: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
bodyLarge: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
bodyMedium: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
bodySmall: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: Color(0xFF757575),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
labelLarge: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Color(0xFF212121),
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
static final TextTheme _textThemeDark = _textThemeLight.copyWith(
|
|
||||||
displayLarge: _textThemeLight.displayLarge?.copyWith(color: Colors.white),
|
|
||||||
displayMedium: _textThemeLight.displayMedium?.copyWith(color: Colors.white),
|
|
||||||
displaySmall: _textThemeLight.displaySmall?.copyWith(color: Colors.white),
|
|
||||||
headlineMedium:
|
|
||||||
_textThemeLight.headlineMedium?.copyWith(color: Colors.white),
|
|
||||||
headlineSmall: _textThemeLight.headlineSmall?.copyWith(color: Colors.white),
|
|
||||||
titleLarge: _textThemeLight.titleLarge?.copyWith(color: Colors.white),
|
|
||||||
bodyLarge: _textThemeLight.bodyLarge?.copyWith(color: Colors.white),
|
|
||||||
bodyMedium: _textThemeLight.bodyMedium?.copyWith(color: Colors.white),
|
|
||||||
bodySmall: _textThemeLight.bodySmall?.copyWith(color: Colors.white70),
|
|
||||||
labelLarge: _textThemeLight.labelLarge?.copyWith(color: Colors.white),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Light theme
|
|
||||||
static final ThemeData lightTheme = ThemeData(
|
|
||||||
useMaterial3: true,
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
colorScheme: const ColorScheme.light(
|
|
||||||
primary: _primaryColorLight,
|
|
||||||
secondary: _secondaryColorLight,
|
|
||||||
error: _errorColorLight,
|
|
||||||
surface: _surfaceColorLight,
|
|
||||||
onPrimary: Colors.white,
|
|
||||||
onSecondary: Colors.white,
|
|
||||||
onSurface: Colors.black87,
|
|
||||||
onError: Colors.white,
|
|
||||||
brightness: Brightness.light,
|
|
||||||
),
|
|
||||||
textTheme: _textThemeLight,
|
|
||||||
appBarTheme: const AppBarTheme(
|
|
||||||
elevation: 0,
|
|
||||||
backgroundColor: _surfaceColorLight,
|
|
||||||
foregroundColor: Color(0xFF212121),
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
cardTheme: CardTheme(
|
|
||||||
//Earlier CardThemeData
|
|
||||||
elevation: 2,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
}
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
backgroundColor: _primaryColorLight,
|
|
||||||
elevation: 2,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
foregroundColor: _primaryColorLight,
|
|
||||||
side: const BorderSide(color: _primaryColorLight),
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textButtonTheme: TextButtonThemeData(
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
foregroundColor: _primaryColorLight,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey[100],
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: BorderSide(color: Colors.grey[300]!),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: const BorderSide(color: _primaryColorLight, width: 2),
|
|
||||||
),
|
|
||||||
errorBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: const BorderSide(color: _errorColorLight, width: 2),
|
|
||||||
),
|
|
||||||
labelStyle: const TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
|
||||||
selectedItemColor: _primaryColorLight,
|
|
||||||
unselectedItemColor: Colors.grey,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Dark theme
|
|
||||||
static final ThemeData darkTheme = ThemeData(
|
|
||||||
fontFamily: 'Rubik',
|
|
||||||
useMaterial3: true,
|
|
||||||
colorScheme: const ColorScheme.dark(
|
|
||||||
primary: _primaryColorDark,
|
|
||||||
secondary: _secondaryColorDark,
|
|
||||||
error: _errorColorDark,
|
|
||||||
surface: _surfaceColorDark,
|
|
||||||
onPrimary: Colors.black,
|
|
||||||
onSecondary: Colors.black,
|
|
||||||
onSurface: Colors.white,
|
|
||||||
onError: Colors.black,
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
),
|
|
||||||
textTheme: _textThemeDark,
|
|
||||||
appBarTheme: const AppBarTheme(
|
|
||||||
elevation: 0,
|
|
||||||
backgroundColor: _surfaceColorDark,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
cardTheme: CardTheme(
|
|
||||||
//Earlier was CardThemeData
|
|
||||||
elevation: 2,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
color: const Color(0xFF2C2C2C),
|
|
||||||
),
|
|
||||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
foregroundColor: Colors.black,
|
|
||||||
backgroundColor: _primaryColorDark,
|
|
||||||
elevation: 2,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
foregroundColor: _primaryColorDark,
|
|
||||||
side: const BorderSide(color: _primaryColorDark),
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textButtonTheme: TextButtonThemeData(
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
foregroundColor: _primaryColorDark,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
fillColor: const Color(0xFF2A2A2A),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: const BorderSide(color: Color(0xFF3A3A3A)),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: const BorderSide(color: _primaryColorDark, width: 2),
|
|
||||||
),
|
|
||||||
errorBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: const BorderSide(color: _errorColorDark, width: 2),
|
|
||||||
),
|
|
||||||
labelStyle: const TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
|
||||||
selectedItemColor: _primaryColorDark,
|
|
||||||
unselectedItemColor: Colors.grey,
|
|
||||||
backgroundColor: _surfaceColorDark,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
class AppException implements Exception {
|
class AppException implements Exception {
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
AppException(this.message);
|
AppException(this.message);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => message;
|
String toString() => message;
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ class NetworkException extends AppException {
|
|||||||
NetworkException(super.message);
|
NetworkException(super.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthException implements Exception{
|
class AuthException implements Exception {
|
||||||
final String message;
|
final String message;
|
||||||
AuthException(this.message);
|
AuthException(this.message);
|
||||||
|
|
||||||
@@ -21,4 +21,4 @@ class AuthException implements Exception{
|
|||||||
|
|
||||||
class UnexpectedException extends AppException {
|
class UnexpectedException extends AppException {
|
||||||
UnexpectedException(super.message);
|
UnexpectedException(super.message);
|
||||||
}
|
}
|
||||||
|
|||||||
61
lib/data/models/beneficiary.dart
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
class Beneficiary {
|
||||||
|
final String accountNo;
|
||||||
|
final String accountType;
|
||||||
|
final String name;
|
||||||
|
final String ifscCode;
|
||||||
|
final String? bankName;
|
||||||
|
final String? branchName;
|
||||||
|
final String? tpin;
|
||||||
|
|
||||||
|
Beneficiary({
|
||||||
|
required this.accountNo,
|
||||||
|
required this.accountType,
|
||||||
|
required this.name,
|
||||||
|
required this.ifscCode,
|
||||||
|
this.bankName,
|
||||||
|
this.branchName,
|
||||||
|
this.tpin,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Beneficiary(
|
||||||
|
accountNo: json['account_no'] ?? json['accountNo'] ?? '',
|
||||||
|
accountType: json['account_type'] ?? json['accountType'] ?? '',
|
||||||
|
name: json['name'] ?? '',
|
||||||
|
ifscCode: json['ifsc_code'] ?? json['ifscCode'] ?? '',
|
||||||
|
bankName: json['bank_name'] ?? json['bankName'] ?? '',
|
||||||
|
branchName: json['branch_name'] ?? json['branchName'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> json = {
|
||||||
|
'accountNo': accountNo,
|
||||||
|
'accountType': accountType,
|
||||||
|
'name': name,
|
||||||
|
'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();
|
||||||
|
return beneficiaryList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)';
|
||||||
|
}
|
||||||
|
}
|
||||||
32
lib/data/models/ifsc.dart
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
class Ifsc {
|
||||||
|
final String ifscCode;
|
||||||
|
final String bankName;
|
||||||
|
final String branchName;
|
||||||
|
|
||||||
|
Ifsc({
|
||||||
|
required this.ifscCode,
|
||||||
|
required this.bankName,
|
||||||
|
required this.branchName,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Ifsc.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Ifsc(
|
||||||
|
ifscCode: json['ifsc_code'] ?? '',
|
||||||
|
bankName: json['bank_name'] ?? '',
|
||||||
|
branchName: json['branch_name'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'ifsc_code': ifscCode,
|
||||||
|
'bank_name': bankName,
|
||||||
|
'branch_name': branchName,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ class PaymentResponse {
|
|||||||
final String? currency;
|
final String? currency;
|
||||||
final String? errorMessage;
|
final String? errorMessage;
|
||||||
final String? errorCode;
|
final String? errorCode;
|
||||||
|
final String? utr;
|
||||||
|
|
||||||
PaymentResponse({
|
PaymentResponse({
|
||||||
required this.isSuccess,
|
required this.isSuccess,
|
||||||
@@ -15,5 +16,6 @@ class PaymentResponse {
|
|||||||
this.currency,
|
this.currency,
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
this.errorCode,
|
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({
|
TransferResponse({
|
||||||
required this.status,
|
required this.status,
|
||||||
required this.message,
|
required this.message,
|
||||||
required this.error,
|
required this.error,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory TransferResponse.fromJson(Map<String, dynamic> json) {
|
factory TransferResponse.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -42,4 +42,4 @@ class TransferResponse {
|
|||||||
error: json['error'] as String?,
|
error: json['error'] as String?,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class AuthRepository {
|
|||||||
final AuthService _authService;
|
final AuthService _authService;
|
||||||
final UserService _userService;
|
final UserService _userService;
|
||||||
final SecureStorage _secureStorage;
|
final SecureStorage _secureStorage;
|
||||||
|
|
||||||
static const _accessTokenKey = 'access_token';
|
static const _accessTokenKey = 'access_token';
|
||||||
static const _tokenExpiryKey = 'token_expiry';
|
static const _tokenExpiryKey = 'token_expiry';
|
||||||
|
|
||||||
@@ -18,35 +18,37 @@ class AuthRepository {
|
|||||||
|
|
||||||
Future<List<User>> login(String customerNo, String password) async {
|
Future<List<User>> login(String customerNo, String password) async {
|
||||||
// Create credentials and call service
|
// 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);
|
final authToken = await _authService.login(credentials);
|
||||||
|
|
||||||
// Save token securely
|
// Save token securely
|
||||||
await _saveAuthToken(authToken);
|
await _saveAuthToken(authToken);
|
||||||
|
|
||||||
// Get and save user profile
|
// Get and save user profile
|
||||||
final users = await _userService.getUserDetails();
|
final users = await _userService.getUserDetails();
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isLoggedIn() async {
|
Future<bool> isLoggedIn() async {
|
||||||
final token = await _getAuthToken();
|
final token = await _getAuthToken();
|
||||||
return token != null && !token.isExpired;
|
return token != null && !token.isExpired;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getAccessToken() async {
|
Future<String?> getAccessToken() async {
|
||||||
final token = await _getAuthToken();
|
final token = await _getAuthToken();
|
||||||
if (token == null) return null;
|
if (token == null) return null;
|
||||||
|
|
||||||
return token.accessToken;
|
return token.accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private helper methods
|
// Private helper methods
|
||||||
Future<void> _saveAuthToken(AuthToken token) async {
|
Future<void> _saveAuthToken(AuthToken token) async {
|
||||||
await _secureStorage.write(_accessTokenKey, token.accessToken);
|
await _secureStorage.write(_accessTokenKey, token.accessToken);
|
||||||
await _secureStorage.write(_tokenExpiryKey, token.expiresAt.toIso8601String());
|
await _secureStorage.write(
|
||||||
|
_tokenExpiryKey, token.expiresAt.toIso8601String());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AuthToken?> _getAuthToken() async {
|
Future<AuthToken?> _getAuthToken() async {
|
||||||
final accessToken = await _secureStorage.read(_accessTokenKey);
|
final accessToken = await _secureStorage.read(_accessTokenKey);
|
||||||
final expiryString = await _secureStorage.read(_tokenExpiryKey);
|
final expiryString = await _secureStorage.read(_tokenExpiryKey);
|
||||||
@@ -59,4 +61,4 @@ class AuthRepository {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:kmobile/data/models/transaction.dart';
|
import 'package:kmobile/data/models/transaction.dart';
|
||||||
|
|
||||||
abstract class TransactionRepository {
|
abstract class TransactionRepository {
|
||||||
Future<List<Transaction>> fetchTransactions(String accountNo);
|
Future<List<Transaction>> fetchTransactions(String accountNo,
|
||||||
|
{DateTime? fromDate, DateTime? toDate});
|
||||||
}
|
}
|
||||||
|
|
||||||
class TransactionRepositoryImpl implements TransactionRepository {
|
class TransactionRepositoryImpl implements TransactionRepository {
|
||||||
@@ -10,9 +14,23 @@ class TransactionRepositoryImpl implements TransactionRepository {
|
|||||||
TransactionRepositoryImpl(this._dio);
|
TransactionRepositoryImpl(this._dio);
|
||||||
|
|
||||||
@override
|
@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) {
|
if (resp.statusCode != 200) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
@@ -25,4 +43,4 @@ class TransactionRepositoryImpl implements TransactionRepository {
|
|||||||
.map((e) => Transaction.fromJson(e as Map<String, dynamic>))
|
.map((e) => Transaction.fromJson(e as Map<String, dynamic>))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:kmobile/data/models/transfer.dart';
|
import 'package:kmobile/data/models/transfer.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
|
||||||
abstract class TransferRepository {
|
abstract class TransferRepository {
|
||||||
Future<TransferResponse> transfer(Transfer transfer);
|
Future<TransferResponse> transfer(Transfer transfer);
|
||||||
}
|
}
|
||||||
@@ -25,4 +24,4 @@ class TransferRepositoryImpl implements TransferRepository {
|
|||||||
|
|
||||||
return TransferResponse.fromJson(resp.data as Map<String, dynamic>);
|
return TransferResponse.fromJson(resp.data as Map<String, dynamic>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
|
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:get_it/get_it.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
import 'package:kmobile/api/services/payment_service.dart';
|
import 'package:kmobile/api/services/payment_service.dart';
|
||||||
import 'package:kmobile/api/services/user_service.dart';
|
import 'package:kmobile/api/services/user_service.dart';
|
||||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||||
import '../api/services/auth_service.dart';
|
import '../api/services/auth_service.dart';
|
||||||
import '../api/interceptors/auth_interceptor.dart';
|
import '../api/interceptors/auth_interceptor.dart';
|
||||||
import '../data/repositories/auth_repository.dart';
|
import '../data/repositories/auth_repository.dart';
|
||||||
@@ -12,6 +17,10 @@ import '../security/secure_storage.dart';
|
|||||||
final getIt = GetIt.instance;
|
final getIt = GetIt.instance;
|
||||||
|
|
||||||
Future<void> setupDependencies() async {
|
Future<void> setupDependencies() async {
|
||||||
|
//getIt.registerLazySingleton<ThemeController>(() => ThemeController());
|
||||||
|
//getIt.registerLazySingleton<ThemeModeController>(() => ThemeModeController());
|
||||||
|
getIt.registerSingleton<ThemeCubit>(ThemeCubit());
|
||||||
|
|
||||||
// Register Dio client
|
// Register Dio client
|
||||||
getIt.registerSingleton<Dio>(_createDioClient());
|
getIt.registerSingleton<Dio>(_createDioClient());
|
||||||
|
|
||||||
@@ -33,6 +42,10 @@ Future<void> setupDependencies() async {
|
|||||||
TransactionRepositoryImpl(getIt<Dio>()));
|
TransactionRepositoryImpl(getIt<Dio>()));
|
||||||
|
|
||||||
getIt.registerSingleton<PaymentService>(PaymentService(getIt<Dio>()));
|
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
|
// Add auth interceptor after repository is available
|
||||||
getIt<Dio>().interceptors.add(
|
getIt<Dio>().interceptors.add(
|
||||||
@@ -49,8 +62,9 @@ Dio _createDioClient() {
|
|||||||
BaseOptions(
|
BaseOptions(
|
||||||
baseUrl:
|
baseUrl:
|
||||||
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
||||||
|
//'http://localhost:8081',
|
||||||
connectTimeout: const Duration(seconds: 5),
|
connectTimeout: const Duration(seconds: 5),
|
||||||
receiveTimeout: const Duration(seconds: 3),
|
receiveTimeout: const Duration(seconds: 10),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Account {
|
|||||||
final String accountType;
|
final String accountType;
|
||||||
final double balance;
|
final double balance;
|
||||||
final String currency;
|
final String currency;
|
||||||
|
|
||||||
Account({
|
Account({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.accountNumber,
|
required this.accountNumber,
|
||||||
@@ -12,4 +12,4 @@ class Account {
|
|||||||
required this.balance,
|
required this.balance,
|
||||||
required this.currency,
|
required this.currency,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,80 +1,91 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
import 'package:kmobile/data/models/user.dart';
|
import 'package:kmobile/data/models/user.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
class AccountInfoScreen extends StatefulWidget {
|
class AccountInfoScreen extends StatefulWidget {
|
||||||
final User user;
|
final List<User> users;
|
||||||
|
final int selectedIndex;
|
||||||
|
|
||||||
const AccountInfoScreen({super.key, required this.user});
|
const AccountInfoScreen({
|
||||||
|
super.key,
|
||||||
|
required this.users,
|
||||||
|
required this.selectedIndex,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AccountInfoScreen> createState() => _AccountInfoScreen();
|
State<AccountInfoScreen> createState() => _AccountInfoScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AccountInfoScreen extends State<AccountInfoScreen> {
|
class _AccountInfoScreen extends State<AccountInfoScreen> {
|
||||||
|
late User selectedUser;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
selectedUser = widget.users[widget.selectedIndex];
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final user = widget.user;
|
final users = widget.users;
|
||||||
|
int selectedIndex = widget.selectedIndex;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).accountInfo,
|
AppLocalizations.of(context).accountInfo,
|
||||||
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(
|
body: ListView(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
children: [
|
children: [
|
||||||
InfoRow(
|
Text(
|
||||||
title: AppLocalizations.of(context).accountNumber,
|
AppLocalizations.of(context).accountNumber,
|
||||||
value: user.accountNo ?? 'N/A'),
|
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14),
|
||||||
// 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: user.cifNumber ?? 'N/A'),
|
|
||||||
InfoRow(
|
|
||||||
title: AppLocalizations.of(context).productName,
|
|
||||||
value: user.productType ?? 'N/A'),
|
|
||||||
// InfoRow(title: 'Account Opening Date', value: user.accountOpeningDate ?? 'N/A'),
|
|
||||||
InfoRow(
|
|
||||||
title: AppLocalizations.of(context).accountStatus, value: 'OPEN'),
|
|
||||||
InfoRow(
|
|
||||||
title: AppLocalizations.of(context).availableBalance,
|
|
||||||
value: user.availableBalance ?? 'N/A'),
|
|
||||||
InfoRow(
|
|
||||||
title: AppLocalizations.of(context).currentBalance,
|
|
||||||
value: user.currentBalance ?? 'N/A'),
|
|
||||||
|
|
||||||
user.approvedAmount != null
|
DropdownButton<User>(
|
||||||
|
value: selectedUser,
|
||||||
|
onChanged: (User? newUser) {
|
||||||
|
if (newUser != null) {
|
||||||
|
setState(() {
|
||||||
|
selectedUser = newUser;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
items: widget.users.map((user) {
|
||||||
|
return DropdownMenuItem<User>(
|
||||||
|
value: user,
|
||||||
|
child: Text(user.accountNo.toString()),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
|
||||||
|
InfoRow(
|
||||||
|
title: AppLocalizations.of(context).customerNumber,
|
||||||
|
value: selectedUser.cifNumber ?? 'N/A',
|
||||||
|
),
|
||||||
|
InfoRow(
|
||||||
|
title: AppLocalizations.of(context).productName,
|
||||||
|
value: selectedUser.productType ?? 'N/A',
|
||||||
|
),
|
||||||
|
// InfoRow(title: 'Account Opening Date', value: users[selectedIndex].accountOpeningDate ?? 'N/A'),
|
||||||
|
InfoRow(
|
||||||
|
title: AppLocalizations.of(context).accountStatus,
|
||||||
|
value: 'OPEN',
|
||||||
|
),
|
||||||
|
InfoRow(
|
||||||
|
title: AppLocalizations.of(context).availableBalance,
|
||||||
|
value: selectedUser.availableBalance ?? 'N/A',
|
||||||
|
),
|
||||||
|
InfoRow(
|
||||||
|
title: AppLocalizations.of(context).currentBalance,
|
||||||
|
value: selectedUser.currentBalance ?? 'N/A',
|
||||||
|
),
|
||||||
|
|
||||||
|
users[selectedIndex].approvedAmount != null
|
||||||
? InfoRow(
|
? InfoRow(
|
||||||
title: AppLocalizations.of(context).approvedAmount,
|
title: AppLocalizations.of(context).approvedAmount,
|
||||||
value: user.approvedAmount ?? 'N/A')
|
value: selectedUser.approvedAmount ?? 'N/A',
|
||||||
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -90,6 +101,7 @@ class InfoRow extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||||
@@ -98,19 +110,16 @@ class InfoRow extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
title,
|
title,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.black87,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 3),
|
const SizedBox(height: 3),
|
||||||
Text(
|
Text(
|
||||||
value,
|
value,
|
||||||
style: const TextStyle(
|
style: TextStyle(fontSize: 16, color: theme.colorScheme.onSurface),
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -5,13 +5,16 @@ import 'package:shimmer/shimmer.dart';
|
|||||||
import 'package:kmobile/data/models/transaction.dart';
|
import 'package:kmobile/data/models/transaction.dart';
|
||||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'transaction_details_screen.dart';
|
||||||
|
|
||||||
class AccountStatementScreen extends StatefulWidget {
|
class AccountStatementScreen extends StatefulWidget {
|
||||||
final String accountNo;
|
final String accountNo;
|
||||||
|
final String balance;
|
||||||
const AccountStatementScreen({
|
const AccountStatementScreen({
|
||||||
super.key,
|
super.key,
|
||||||
required this.accountNo,
|
required this.accountNo,
|
||||||
|
required this.balance,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -39,14 +42,20 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
final repo = getIt<TransactionRepository>();
|
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);
|
setState(() => _transactions = txs);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
'${AppLocalizations.of(context).failedToLoadTransactions} $e')),
|
'${AppLocalizations.of(context).failedToLoadTransactions} $e',
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => _txLoading = false);
|
setState(() => _txLoading = false);
|
||||||
@@ -73,7 +82,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
if (fromDate == null) {
|
if (fromDate == null) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(AppLocalizations.of(context).pleaseSelectDateFirst)),
|
content: Text(AppLocalizations.of(context).pleaseSelectDateFirst),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -115,7 +125,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).accountStatement,
|
AppLocalizations.of(context).accountStatement,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -139,8 +150,36 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(AppLocalizations.of(context).filters,
|
Row(
|
||||||
style: TextStyle(fontSize: 17)),
|
children: [
|
||||||
|
Text(
|
||||||
|
"${AppLocalizations.of(context).accountNumber}: ",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(widget.accountNo, style: const TextStyle(fontSize: 17)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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),
|
||||||
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -148,7 +187,9 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => _selectFromDate(context),
|
onTap: () => _selectFromDate(context),
|
||||||
child: buildDateBox(
|
child: buildDateBox(
|
||||||
AppLocalizations.of(context).fromDate, fromDate),
|
AppLocalizations.of(context).fromDate,
|
||||||
|
fromDate,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
@@ -156,62 +197,36 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => _selectToDate(context),
|
onTap: () => _selectToDate(context),
|
||||||
child: buildDateBox(
|
child: buildDateBox(
|
||||||
AppLocalizations.of(context).toDate, toDate),
|
AppLocalizations.of(context).toDate,
|
||||||
|
toDate,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Row(
|
SizedBox(
|
||||||
children: [
|
width: double.infinity,
|
||||||
Expanded(
|
child: ElevatedButton(
|
||||||
child: TextFormField(
|
onPressed: _loadTransactions,
|
||||||
controller: _minAmountController,
|
style: ElevatedButton.styleFrom(
|
||||||
decoration: InputDecoration(
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
labelText: AppLocalizations.of(context).minAmount,
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
border: OutlineInputBorder(),
|
),
|
||||||
isDense: true,
|
child: Text(
|
||||||
filled: true,
|
AppLocalizations.of(context).search,
|
||||||
fillColor: Colors.white,
|
style: TextStyle(
|
||||||
),
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
keyboardType: TextInputType.number,
|
fontSize: 16,
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
),
|
||||||
Expanded(
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _maxAmountController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: AppLocalizations.of(context).maxAmount,
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
isDense: true,
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.white,
|
|
||||||
),
|
|
||||||
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: const Icon(
|
|
||||||
Symbols.arrow_forward,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 30,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 35),
|
const SizedBox(height: 35),
|
||||||
if (!_txLoading && _transactions.isNotEmpty)
|
if (!_txLoading &&
|
||||||
|
_transactions.isNotEmpty &&
|
||||||
|
fromDate == null &&
|
||||||
|
toDate == null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 12.0),
|
padding: const EdgeInsets.only(bottom: 12.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -231,20 +246,29 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
leading: Shimmer.fromColors(
|
leading: Shimmer.fromColors(
|
||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: const CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: 12, backgroundColor: Colors.white),
|
radius: 12,
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
title: Shimmer.fromColors(
|
title: Shimmer.fromColors(
|
||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 10, width: 100, color: Colors.white),
|
height: 10,
|
||||||
|
width: 100,
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
subtitle: Shimmer.fromColors(
|
subtitle: Shimmer.fromColors(
|
||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 8, width: 60, color: Colors.white),
|
height: 8,
|
||||||
|
width: 60,
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -253,46 +277,51 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).noTransactions,
|
AppLocalizations.of(context).noTransactions,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16, color: Colors.grey[600]),
|
||||||
color: Colors.grey[600],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.separated(
|
||||||
itemCount: _transactions.length,
|
itemCount: _transactions.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final txn = _transactions[index];
|
final tx = _transactions[index];
|
||||||
final isCredit = txn.type == 'CR';
|
return ListTile(
|
||||||
return Column(
|
leading: Icon(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
tx.type == 'CR'
|
||||||
children: [
|
? Symbols.call_received
|
||||||
Text(txn.date ?? '',
|
: Symbols.call_made,
|
||||||
style: const TextStyle(color: Colors.grey)),
|
color:
|
||||||
const SizedBox(height: 4),
|
tx.type == 'CR' ? Colors.green : Colors.red,
|
||||||
Row(
|
),
|
||||||
mainAxisAlignment:
|
title: Text(
|
||||||
MainAxisAlignment.spaceBetween,
|
tx.date ?? '',
|
||||||
children: [
|
style: const TextStyle(fontSize: 15),
|
||||||
Expanded(
|
),
|
||||||
child: Text(txn.name ?? '',
|
subtitle: Text(
|
||||||
style: const TextStyle(fontSize: 16)),
|
tx.name != null
|
||||||
),
|
? (tx.name!.length > 18
|
||||||
Text(
|
? tx.name!.substring(0, 22)
|
||||||
"${isCredit ? '+' : '-'}₹${txn.amount}",
|
: tx.name!)
|
||||||
style: TextStyle(
|
: '',
|
||||||
color: isCredit
|
style: const TextStyle(fontSize: 12),
|
||||||
? Colors.green
|
),
|
||||||
: Colors.red,
|
trailing: Text(
|
||||||
// fontWeight: FontWeight.bold,
|
"₹${tx.amount}",
|
||||||
fontSize: 16,
|
style: const TextStyle(fontSize: 17),
|
||||||
),
|
),
|
||||||
),
|
onTap: () {
|
||||||
],
|
Navigator.push(
|
||||||
),
|
context,
|
||||||
const SizedBox(height: 25),
|
MaterialPageRoute(
|
||||||
],
|
builder: (_) => TransactionDetailsScreen(
|
||||||
|
transaction: tx),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return const Divider();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
lib/features/auth/controllers/theme_cubit.dart
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.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(const ThemeState(themeType: ThemeType.violet)) {
|
||||||
|
loadTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadTheme() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final themeIndex = prefs.getInt('theme_type') ?? 0;
|
||||||
|
final type = ThemeType.values[themeIndex];
|
||||||
|
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);
|
||||||
|
emit(ThemeState(themeType: type));
|
||||||
|
}
|
||||||
|
}
|
||||||
17
lib/features/auth/controllers/theme_state.dart
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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 getThemeData() {
|
||||||
|
return AppThemes.getLightTheme(themeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [themeType];
|
||||||
|
}
|
||||||
@@ -6,12 +6,12 @@ import 'package:equatable/equatable.dart';
|
|||||||
class AuthToken extends Equatable {
|
class AuthToken extends Equatable {
|
||||||
final String accessToken;
|
final String accessToken;
|
||||||
final DateTime expiresAt;
|
final DateTime expiresAt;
|
||||||
|
|
||||||
const AuthToken({
|
const AuthToken({
|
||||||
required this.accessToken,
|
required this.accessToken,
|
||||||
required this.expiresAt,
|
required this.expiresAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory AuthToken.fromJson(Map<String, dynamic> json) {
|
factory AuthToken.fromJson(Map<String, dynamic> json) {
|
||||||
return AuthToken(
|
return AuthToken(
|
||||||
accessToken: json['token'],
|
accessToken: json['token'],
|
||||||
@@ -29,7 +29,8 @@ class AuthToken extends Equatable {
|
|||||||
// Pad the payload if necessary
|
// Pad the payload if necessary
|
||||||
String normalized = base64Url.normalize(payload);
|
String normalized = base64Url.normalize(payload);
|
||||||
final payloadMap = json.decode(utf8.decode(base64Url.decode(normalized)));
|
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');
|
throw Exception('Invalid payload');
|
||||||
}
|
}
|
||||||
final exp = payloadMap['exp'];
|
final exp = payloadMap['exp'];
|
||||||
@@ -40,9 +41,9 @@ class AuthToken extends Equatable {
|
|||||||
return DateTime.now().add(const Duration(hours: 1));
|
return DateTime.now().add(const Duration(hours: 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [accessToken, expiresAt];
|
List<Object> get props => [accessToken, expiresAt];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@@ -23,23 +23,9 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
final _passwordController = TextEditingController();
|
final _passwordController = TextEditingController();
|
||||||
bool _obscurePassword = true;
|
bool _obscurePassword = true;
|
||||||
//bool _showWelcome = 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
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_logoController.dispose();
|
|
||||||
_customerNumberController.dispose();
|
_customerNumberController.dispose();
|
||||||
_passwordController.dispose();
|
_passwordController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -63,16 +49,20 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
if (state is Authenticated) {
|
if (state is Authenticated) {
|
||||||
final storage = getIt<SecureStorage>();
|
final storage = getIt<SecureStorage>();
|
||||||
final mpin = await storage.read('mpin');
|
final mpin = await storage.read('mpin');
|
||||||
|
if (!context.mounted) return;
|
||||||
if (mpin == null) {
|
if (mpin == null) {
|
||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => MPinScreen(
|
builder: (_) => MPinScreen(
|
||||||
mode: MPinMode.set,
|
mode: MPinMode.set,
|
||||||
onCompleted: (_) {
|
onCompleted: (_) {
|
||||||
Navigator.of(context, rootNavigator: true)
|
Navigator.of(
|
||||||
.pushReplacement(
|
context,
|
||||||
|
rootNavigator: true,
|
||||||
|
).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => const NavigationScaffold()),
|
builder: (_) => const NavigationScaffold(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -84,9 +74,9 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (state is AuthError) {
|
} else if (state is AuthError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(
|
||||||
SnackBar(content: Text(state.message)),
|
context,
|
||||||
);
|
).showSnackBar(SnackBar(content: Text(state.message)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@@ -97,27 +87,27 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
// 🔁 Animated Blinking Logo
|
Image.asset(
|
||||||
FadeTransition(
|
'assets/images/logo.png',
|
||||||
opacity: _logoAnimation,
|
width: 150,
|
||||||
child: Image.asset(
|
height: 150,
|
||||||
'assets/images/logo.png',
|
errorBuilder: (context, error, stackTrace) {
|
||||||
width: 150,
|
return Icon(
|
||||||
height: 150,
|
Icons.account_balance,
|
||||||
errorBuilder: (context, error, stackTrace) {
|
size: 100,
|
||||||
return const Icon(Icons.account_balance,
|
color: Theme.of(context).primaryColor,
|
||||||
size: 100, color: Colors.blue);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Title
|
// Title
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).kccb,
|
AppLocalizations.of(context).kccb,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 32,
|
fontSize: 32,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.blue),
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 48),
|
const SizedBox(height: 48),
|
||||||
|
|
||||||
@@ -126,14 +116,14 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).customerNumber,
|
labelText: AppLocalizations.of(context).customerNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -147,19 +137,18 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// Password
|
// Password
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
obscureText: _obscurePassword,
|
obscureText: _obscurePassword,
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
onFieldSubmitted: (_) =>
|
onFieldSubmitted: (_) => _submitForm(),
|
||||||
_submitForm(), // ⌨️ Enter key submits
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).password,
|
labelText: AppLocalizations.of(context).password,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: const OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
@@ -195,8 +184,9 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor:
|
||||||
foregroundColor: Colors.blueAccent,
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
foregroundColor: Theme.of(context).primaryColorDark,
|
||||||
side: const BorderSide(color: Colors.black, width: 1),
|
side: const BorderSide(color: Colors.black, width: 1),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
@@ -204,22 +194,22 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
? const CircularProgressIndicator()
|
? const CircularProgressIndicator()
|
||||||
: Text(
|
: Text(
|
||||||
AppLocalizations.of(context).login,
|
AppLocalizations.of(context).login,
|
||||||
style: TextStyle(fontSize: 16),
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: Divider()),
|
const Expanded(child: Divider()),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: Text(AppLocalizations.of(context).or),
|
child: Text(AppLocalizations.of(context).or),
|
||||||
),
|
),
|
||||||
Expanded(child: Divider()),
|
const Expanded(child: Divider()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -233,10 +223,11 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
//disable until registration is implemented
|
//disable until registration is implemented
|
||||||
onPressed: null,
|
onPressed: null,
|
||||||
style: OutlinedButton.styleFrom(
|
style: OutlinedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.lightBlue[100],
|
backgroundColor: Theme.of(context).primaryColorLight,
|
||||||
foregroundColor: Colors.black),
|
foregroundColor: Colors.black,
|
||||||
|
),
|
||||||
child: Text(AppLocalizations.of(context).register),
|
child: Text(AppLocalizations.of(context).register),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -249,228 +240,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,4 +1,4 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
final auth = LocalAuthentication();
|
final auth = LocalAuthentication();
|
||||||
if (await auth.canCheckBiometrics) {
|
if (await auth.canCheckBiometrics) {
|
||||||
final didAuth = await auth.authenticate(
|
final didAuth = await auth.authenticate(
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
localizedReason: AppLocalizations.of(context).authenticateToAccess,
|
localizedReason: AppLocalizations.of(context).authenticateToAccess,
|
||||||
options: const AuthenticationOptions(biometricOnly: true),
|
options: const AuthenticationOptions(biometricOnly: true),
|
||||||
);
|
);
|
||||||
@@ -155,7 +156,7 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
['1', '2', '3'],
|
['1', '2', '3'],
|
||||||
['4', '5', '6'],
|
['4', '5', '6'],
|
||||||
['7', '8', '9'],
|
['7', '8', '9'],
|
||||||
['Enter', '0', '<']
|
['Enter', '0', '<'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
@@ -174,8 +175,9 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
_handleComplete();
|
_handleComplete();
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
errorText =
|
errorText = AppLocalizations.of(
|
||||||
AppLocalizations.of(context).pleaseEnter4Digits;
|
context,
|
||||||
|
).pleaseEnter4Digits;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (key.isNotEmpty) {
|
} else if (key.isNotEmpty) {
|
||||||
@@ -196,7 +198,9 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
key == '<' ? '⌫' : key,
|
key == '<' ? '⌫' : key,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: key == 'Enter' ? Colors.blue : Colors.black,
|
color: key == 'Enter'
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -238,8 +242,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
if (errorText != null)
|
if (errorText != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child:
|
child: Text(
|
||||||
Text(errorText!, style: const TextStyle(color: Colors.red)),
|
errorText!,
|
||||||
|
style: const TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
buildNumberPad(),
|
buildNumberPad(),
|
||||||
|
|||||||
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 40,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,143 +0,0 @@
|
|||||||
import 'package:flutter_gen/gen_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 login after 6 seconds
|
|
||||||
Timer(const Duration(seconds: 6), () {
|
|
||||||
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: Colors.white,
|
|
||||||
letterSpacing: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context).kccBankFull,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
color: Colors.white,
|
|
||||||
letterSpacing: 1.2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
/// 🔹 Loading Spinner at Bottom
|
|
||||||
const Positioned(
|
|
||||||
bottom: 40,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*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,10 +1,22 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
|
import 'beneficiary_result_page.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.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 {
|
class AddBeneficiaryScreen extends StatefulWidget {
|
||||||
const AddBeneficiaryScreen({super.key});
|
final String customerName;
|
||||||
|
|
||||||
|
const AddBeneficiaryScreen({
|
||||||
|
super.key,
|
||||||
|
required this.customerName,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AddBeneficiaryScreen> createState() => _AddBeneficiaryScreen();
|
State<AddBeneficiaryScreen> createState() => _AddBeneficiaryScreen();
|
||||||
@@ -21,7 +33,12 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
final TextEditingController branchNameController = TextEditingController();
|
final TextEditingController branchNameController = TextEditingController();
|
||||||
final TextEditingController ifscController = TextEditingController();
|
final TextEditingController ifscController = TextEditingController();
|
||||||
final TextEditingController phoneController = TextEditingController();
|
final TextEditingController phoneController = TextEditingController();
|
||||||
|
final service = getIt<BeneficiaryService>();
|
||||||
|
|
||||||
|
bool _isValidating = false;
|
||||||
|
bool _isBeneficiaryValidated = false;
|
||||||
|
// ignore: unused_field
|
||||||
|
String? _validationError;
|
||||||
late String accountType;
|
late String accountType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,99 +46,174 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
accountType = AppLocalizations.of(context).savings;
|
accountType = 'Savings';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _submitForm() {
|
void _validateIFSC() async {
|
||||||
if (_formKey.currentState!.validate()) {
|
var beneficiaryService = getIt<BeneficiaryService>();
|
||||||
// Handle successful submission
|
final ifsc = ifscController.text.trim().toUpperCase();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
if (ifsc.isEmpty) return;
|
||||||
SnackBar(
|
|
||||||
backgroundColor: Colors.grey[900],
|
final result = await beneficiaryService.validateIFSC(ifsc);
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
margin: const EdgeInsets.all(12),
|
if (mounted) {
|
||||||
duration: const Duration(seconds: 5),
|
if (result.bankName == '') {
|
||||||
content: Row(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||||
children: [
|
);
|
||||||
Expanded(
|
bankNameController.clear();
|
||||||
child: Text(
|
branchNameController.clear();
|
||||||
AppLocalizations.of(context).beneficiaryAdded,
|
} else {
|
||||||
style: TextStyle(color: Colors.white),
|
bankNameController.text = result.bankName;
|
||||||
),
|
branchNameController.text = result.branchName;
|
||||||
),
|
}
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
// Navigate to Payment Screen or do something
|
|
||||||
},
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
foregroundColor: Colors.blue[200],
|
|
||||||
),
|
|
||||||
child: Text(AppLocalizations.of(context).payNow),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.close, color: Colors.white),
|
|
||||||
onPressed: () {
|
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _validateIFSC() async {
|
void _validateBeneficiary() async {
|
||||||
final ifsc = ifscController.text.trim().toUpperCase();
|
FocusScope.of(context).unfocus();
|
||||||
|
setState(() {
|
||||||
|
_isValidating = true;
|
||||||
|
_validationError = null;
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
nameController.text = ''; // clear previous name
|
||||||
|
});
|
||||||
|
|
||||||
// 🔹 Format check
|
final String accountNo = accountNumberController.text.trim();
|
||||||
final isValidFormat = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$').hasMatch(ifsc);
|
final String ifsc = ifscController.text.trim();
|
||||||
if (!isValidFormat) {
|
final String remitter = widget.customerName;
|
||||||
bankNameController.clear();
|
|
||||||
branchNameController.clear();
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
nameController.text = beneficiaryName;
|
||||||
|
_isBeneficiaryValidated = true;
|
||||||
|
_validationError = null;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_validationError = e.toString();
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_isValidating = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void validateAndAddBeneficiary() async {
|
||||||
|
// First, validate the form fields (account number, confirm account, ifsc, etc.)
|
||||||
|
if (!_formKey.currentState!.validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure beneficiary is validated before proceeding to TPIN
|
||||||
|
if (!_isBeneficiaryValidated) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfscFormat)),
|
SnackBar(
|
||||||
|
content: Text(AppLocalizations.of(context)
|
||||||
|
.pleaseValidateBeneficiaryDetailsFirst)),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await Future.delayed(
|
|
||||||
const Duration(seconds: 2)); //Mock delay for 2 sec to imitate api call
|
|
||||||
// 🔹 Mock IFSC lookup (you can replace this with API)
|
|
||||||
const mockIfscData = {
|
|
||||||
'KCCB0001234': {
|
|
||||||
'bank': 'Kangra Central Co-operative Bank',
|
|
||||||
'branch': 'Dharamshala',
|
|
||||||
},
|
|
||||||
'SBIN0004567': {
|
|
||||||
'bank': 'State Bank of India',
|
|
||||||
'branch': 'Connaught Place',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (mockIfscData.containsKey(ifsc)) {
|
// Create the beneficiary object without TPIN for now
|
||||||
final data = mockIfscData[ifsc]!;
|
final beneficiaryWithoutTpin = Beneficiary(
|
||||||
bankNameController.text = data['bank']!;
|
accountNo: accountNumberController.text.trim(),
|
||||||
branchNameController.text = data['branch']!;
|
accountType: accountType,
|
||||||
} else {
|
name: nameController.text.trim(),
|
||||||
bankNameController.clear();
|
ifscCode: ifscController.text.trim(),
|
||||||
branchNameController.clear();
|
bankName: bankNameController.text.trim(),
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
branchName: branchNameController.text.trim(),
|
||||||
SnackBar(content: Text(AppLocalizations.of(context).noIfscDetails)),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// Navigate to TPIN screen
|
||||||
🔸 Optional: Use real IFSC API like:
|
Navigator.push(
|
||||||
final response = await http.get(Uri.parse('https://ifsc.razorpay.com/$ifsc'));
|
context,
|
||||||
if (response.statusCode == 200) {
|
MaterialPageRoute(
|
||||||
final data = jsonDecode(response.body);
|
builder: (context) => TransactionPinScreen(
|
||||||
bankNameController.text = data['BANK'];
|
onPinCompleted: (pinScreenContext, tpin) async {
|
||||||
branchNameController.text = data['BRANCH'];
|
// 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
|
@override
|
||||||
@@ -136,7 +228,8 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).addBeneficiary,
|
AppLocalizations.of(context).addBeneficiary,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -170,28 +263,39 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
TextFormField(
|
TextFormField(
|
||||||
controller: accountNumberController,
|
controller: accountNumberController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText:
|
labelText: AppLocalizations.of(
|
||||||
AppLocalizations.of(context).accountNumber,
|
context,
|
||||||
|
).accountNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor:
|
||||||
enabledBorder: OutlineInputBorder(
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.black, width: 2),
|
color: Colors.black,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
|
onChanged: (value) {
|
||||||
|
nameController.clear();
|
||||||
|
setState(() {
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.length < 10) {
|
if (value == null || value.length < 10) {
|
||||||
return AppLocalizations.of(context)
|
return AppLocalizations.of(
|
||||||
.enterValidAccountNumber;
|
context,
|
||||||
|
).enterValidAccountNumber;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@@ -201,178 +305,64 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
TextFormField(
|
TextFormField(
|
||||||
controller: confirmAccountNumberController,
|
controller: confirmAccountNumberController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context)
|
labelText: AppLocalizations.of(
|
||||||
.confirmAccountNumber,
|
context,
|
||||||
|
).confirmAccountNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor:
|
||||||
enabledBorder: OutlineInputBorder(
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.black, width: 2),
|
color: Colors.black,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return AppLocalizations.of(context)
|
return AppLocalizations.of(
|
||||||
.reenterAccountNumber;
|
context,
|
||||||
|
).reenterAccountNumber;
|
||||||
}
|
}
|
||||||
if (value != accountNumberController.text) {
|
if (value != accountNumberController.text) {
|
||||||
return AppLocalizations.of(context)
|
return AppLocalizations.of(
|
||||||
.accountMismatch;
|
context,
|
||||||
|
).accountMismatch;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
TextFormField(
|
|
||||||
controller: nameController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: AppLocalizations.of(context).name,
|
|
||||||
// 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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
validator: (value) => value == null || value.isEmpty
|
|
||||||
? AppLocalizations.of(context).nameRequired
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
/*const SizedBox(height: 24),
|
|
||||||
TextFormField(
|
|
||||||
controller: bankNameController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Beneficiary Bank Name',
|
|
||||||
// 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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
validator: (value) =>
|
|
||||||
value == null || value.isEmpty ? "Bank name is required" : null,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
TextFormField(
|
|
||||||
controller: branchNameController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Branch Name',
|
|
||||||
// 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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
validator: (value) =>
|
|
||||||
value == null || value.isEmpty ? "Branch name is required" : null,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: TextFormField(
|
|
||||||
controller: ifscController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'IFSC Code',
|
|
||||||
// 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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
validator: (value) => value == null || value.length < 5
|
|
||||||
? "Enter a valid IFSC"
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: DropdownButtonFormField<String>(
|
|
||||||
value: accountType,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Account Type',
|
|
||||||
// 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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
items: ['Savings', 'Current']
|
|
||||||
.map((type) => DropdownMenuItem(
|
|
||||||
value: type,
|
|
||||||
child: Text(type),
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
accountType = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),*/
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
// 🔹 IFSC Code Field
|
// 🔹 IFSC Code Field
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: ifscController,
|
controller: ifscController,
|
||||||
|
maxLength: 11,
|
||||||
|
inputFormatters: [
|
||||||
|
LengthLimitingTextInputFormatter(11),
|
||||||
|
],
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).ifscCode,
|
labelText: AppLocalizations.of(context).ifscCode,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor:
|
||||||
enabledBorder: OutlineInputBorder(
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.black, width: 2),
|
color: Colors.black,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
textCapitalization: TextCapitalization.characters,
|
textCapitalization: TextCapitalization.characters,
|
||||||
@@ -392,15 +382,16 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
final pattern = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$');
|
final pattern = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$');
|
||||||
if (value == null || value.trim().isEmpty) {
|
if (value == null || value.trim().isEmpty) {
|
||||||
return AppLocalizations.of(context).enterIfsc;
|
return AppLocalizations.of(context).enterIfsc;
|
||||||
} else if (!pattern
|
} else if (!pattern.hasMatch(
|
||||||
.hasMatch(value.trim().toUpperCase())) {
|
value.trim().toUpperCase(),
|
||||||
return AppLocalizations.of(context)
|
)) {
|
||||||
.invalidIfscFormat;
|
return AppLocalizations.of(
|
||||||
|
context,
|
||||||
|
).invalidIfscFormat;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 🔹 Bank Name (Disabled)
|
// 🔹 Bank Name (Disabled)
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -408,20 +399,22 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
enabled: false, // changed from readOnly to disabled
|
enabled: false, // changed from readOnly to disabled
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).bankName,
|
labelText: AppLocalizations.of(context).bankName,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white, // disabled color
|
fillColor: Theme.of(context)
|
||||||
enabledBorder: OutlineInputBorder(
|
.dialogBackgroundColor, // disabled color
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.black, width: 2),
|
color: Colors.black,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 🔹 Branch Name (Disabled)
|
// 🔹 Branch Name (Disabled)
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -429,46 +422,109 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
enabled: false, // changed from readOnly to disabled
|
enabled: false, // changed from readOnly to disabled
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).branchName,
|
labelText: AppLocalizations.of(context).branchName,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
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 =
|
||||||
|
'Please enter a valid and matching account number.';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: _isValidating
|
||||||
|
? const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: Text(AppLocalizations.of(context)
|
||||||
|
.validateBeneficiary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
//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:
|
||||||
BorderSide(color: Colors.black, width: 2),
|
BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
validator: (value) => value == null || value.isEmpty
|
||||||
|
? AppLocalizations.of(context).nameRequired
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 🔹 Account Type Dropdown
|
// 🔹 Account Type Dropdown
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
value: accountType,
|
value: accountType,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).accountType,
|
labelText: AppLocalizations.of(context).accountType,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor:
|
||||||
enabledBorder: OutlineInputBorder(
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.black, width: 2),
|
color: Colors.black,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
items: [
|
items: [
|
||||||
AppLocalizations.of(context).savings,
|
'Savings',
|
||||||
AppLocalizations.of(context).current
|
'Current',
|
||||||
]
|
]
|
||||||
.map((type) => DropdownMenuItem(
|
.map(
|
||||||
value: type,
|
(type) => DropdownMenuItem(
|
||||||
child: Text(type),
|
value: type,
|
||||||
))
|
child: Text(type),
|
||||||
|
),
|
||||||
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -483,17 +539,20 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
keyboardType: TextInputType.phone,
|
keyboardType: TextInputType.phone,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).phone,
|
labelText: AppLocalizations.of(context).phone,
|
||||||
prefixIcon: Icon(Icons.phone),
|
prefixIcon: const Icon(Icons.phone),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor:
|
||||||
enabledBorder: OutlineInputBorder(
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide:
|
borderSide: BorderSide(
|
||||||
BorderSide(color: Colors.black, width: 2),
|
color: Colors.black,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
@@ -513,12 +572,10 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 250,
|
width: 250,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: _submitForm,
|
onPressed: validateAndAddBeneficiary,
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.blue[900],
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).validateAndAdd),
|
child: Text(AppLocalizations.of(context).validateAndAdd),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
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: 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),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
116
lib/features/beneficiaries/screens/beneficiary_result_page.dart
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:lottie/lottie.dart';
|
||||||
|
import 'package:confetti/confetti.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
import '../../../app.dart';
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
class BeneficiaryResultPage extends StatefulWidget {
|
||||||
|
final bool isSuccess;
|
||||||
|
|
||||||
|
const BeneficiaryResultPage({super.key, required this.isSuccess});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BeneficiaryResultPage> createState() => _BeneficiaryResultPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
||||||
|
late ConfettiController _confettiController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_confettiController =
|
||||||
|
ConfettiController(duration: const Duration(seconds: 3));
|
||||||
|
if (widget.isSuccess) {
|
||||||
|
_confettiController.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_confettiController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
const successAnimation = 'assets/animations/done.json';
|
||||||
|
const errorAnimation = 'assets/animations/error.json';
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: widget.isSuccess ? Colors.green[50] : Colors.red[50],
|
||||||
|
body: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Lottie.asset(
|
||||||
|
widget.isSuccess ? successAnimation : errorAnimation,
|
||||||
|
width: 150,
|
||||||
|
height: 150,
|
||||||
|
repeat: false,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
widget.isSuccess
|
||||||
|
? AppLocalizations.of(context).beneficiaryAddedSuccess
|
||||||
|
: AppLocalizations.of(context).beneficiaryAdditionFailed,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: widget.isSuccess ? Colors.green : Colors.red,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
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: const TextStyle(fontSize: 18), // slightly bigger text
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.isSuccess)
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: ConfettiWidget(
|
||||||
|
confettiController: _confettiController,
|
||||||
|
blastDirection: pi / 2,
|
||||||
|
maxBlastForce: 10,
|
||||||
|
minBlastForce: 5,
|
||||||
|
emissionFrequency: 0.05,
|
||||||
|
numberOfParticles: 20,
|
||||||
|
gravity: 0.2,
|
||||||
|
shouldLoop: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:kmobile/features/beneficiaries/screens/beneficiary_details_screen.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.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/widgets/bank_logos.dart';
|
||||||
|
|
||||||
class ManageBeneficiariesScreen extends StatefulWidget {
|
class ManageBeneficiariesScreen extends StatefulWidget {
|
||||||
const ManageBeneficiariesScreen({super.key});
|
final String customerName;
|
||||||
|
const ManageBeneficiariesScreen({super.key, required this.customerName});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ManageBeneficiariesScreen> createState() =>
|
State<ManageBeneficiariesScreen> createState() =>
|
||||||
@@ -13,88 +18,112 @@ class ManageBeneficiariesScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||||
final List<Map<String, String>> beneficiaries = [
|
var service = getIt<BeneficiaryService>();
|
||||||
{
|
bool _isLoading = true;
|
||||||
'bank': 'State Bank Of India',
|
List<Beneficiary> _beneficiaries = [];
|
||||||
'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
|
@override
|
||||||
Widget build(BuildContext context) {
|
void initState() {
|
||||||
return Scaffold(
|
super.initState();
|
||||||
appBar: AppBar(
|
_loadBeneficiaries();
|
||||||
leading: IconButton(
|
}
|
||||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
|
||||||
onPressed: () {
|
Future<void> _loadBeneficiaries() async {
|
||||||
Navigator.pop(context);
|
final data = await service.fetchBeneficiaryList();
|
||||||
},
|
setState(() {
|
||||||
),
|
_beneficiaries = data;
|
||||||
title: Text(
|
_isLoading = false;
|
||||||
AppLocalizations.of(context).beneficiaries,
|
});
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
}
|
||||||
),
|
|
||||||
centerTitle: false,
|
Widget _buildShimmerList() {
|
||||||
actions: [
|
return ListView.builder(
|
||||||
Padding(
|
itemCount: 6,
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
itemBuilder: (context, index) => Shimmer.fromColors(
|
||||||
child: CircleAvatar(
|
baseColor: Colors.grey.shade300,
|
||||||
backgroundColor: Colors.grey[200],
|
highlightColor: Colors.grey.shade100,
|
||||||
radius: 20,
|
child: ListTile(
|
||||||
child: SvgPicture.asset(
|
leading: const CircleAvatar(
|
||||||
'assets/images/avatar_male.svg',
|
radius: 24,
|
||||||
width: 40,
|
backgroundColor: Colors.white,
|
||||||
height: 40,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
title: Container(
|
||||||
|
height: 16,
|
||||||
|
color: Colors.white,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
),
|
||||||
|
subtitle: Container(
|
||||||
|
height: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
);
|
||||||
padding: const EdgeInsets.all(8.0),
|
}
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: beneficiaries.length,
|
Widget _buildBeneficiaryList() {
|
||||||
itemBuilder: (context, index) {
|
if (_beneficiaries.isEmpty) {
|
||||||
final beneficiary = beneficiaries[index];
|
return Center(
|
||||||
return ListTile(
|
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||||
leading: const CircleAvatar(
|
}
|
||||||
backgroundColor: Colors.blue, child: Text('A')),
|
return ListView.builder(
|
||||||
title: Text(beneficiary['name']!),
|
itemCount: _beneficiaries.length,
|
||||||
subtitle: Text(beneficiary['bank']!),
|
itemBuilder: (context, index) {
|
||||||
trailing: IconButton(
|
final item = _beneficiaries[index];
|
||||||
icon: const Icon(Symbols.delete_forever, color: Colors.red),
|
return ListTile(
|
||||||
onPressed: () {
|
leading: CircleAvatar(
|
||||||
// Delete action
|
radius: 24,
|
||||||
},
|
backgroundColor: Colors.transparent,
|
||||||
|
child: getBankLogo(item.bankName),
|
||||||
|
),
|
||||||
|
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),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
String customerName = widget.customerName;
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(AppLocalizations.of(context).beneficiaries),
|
||||||
),
|
),
|
||||||
|
body: _isLoading ? _buildShimmerList() : _buildBeneficiaryList(),
|
||||||
floatingActionButton: Padding(
|
floatingActionButton: Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => const AddBeneficiaryScreen()));
|
builder: (context) =>
|
||||||
|
AddBeneficiaryScreen(customerName: customerName),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
backgroundColor: Colors.grey[300],
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
foregroundColor: Colors.blue[900],
|
foregroundColor: Theme.of(context).primaryColor,
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
|
|
||||||
class BlockCardScreen extends StatefulWidget {
|
class BlockCardScreen extends StatefulWidget {
|
||||||
@@ -42,7 +42,7 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Just close the SnackBar
|
// Just close the SnackBar
|
||||||
},
|
},
|
||||||
textColor: Colors.white,
|
textColor: Theme.of(context).dialogBackgroundColor,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
behavior: SnackBarBehavior.floating,
|
behavior: SnackBarBehavior.floating,
|
||||||
@@ -64,7 +64,8 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).blockCard,
|
AppLocalizations.of(context).blockCard,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -94,14 +95,14 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
controller: _cardController,
|
controller: _cardController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).cardNumber,
|
labelText: AppLocalizations.of(context).cardNumber,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -119,14 +120,14 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
controller: _cvvController,
|
controller: _cvvController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).cvv,
|
labelText: AppLocalizations.of(context).cvv,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -146,15 +147,15 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
onTap: _pickExpiryDate,
|
onTap: _pickExpiryDate,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).expiryDate,
|
labelText: AppLocalizations.of(context).expiryDate,
|
||||||
suffixIcon: Icon(Icons.calendar_today),
|
suffixIcon: const Icon(Icons.calendar_today),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -170,15 +171,15 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
controller: _phoneController,
|
controller: _phoneController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).phone,
|
labelText: AppLocalizations.of(context).phone,
|
||||||
prefixIcon: Icon(Icons.phone),
|
prefixIcon: const Icon(Icons.phone),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -198,8 +199,9 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.blue[900],
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).block),
|
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,9 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:kmobile/features/card/screens/block_card_screen.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:kmobile/features/card/screens/card_pin_change_details_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class CardManagementScreen extends StatefulWidget {
|
class CardManagementScreen extends StatefulWidget {
|
||||||
const CardManagementScreen({super.key});
|
const CardManagementScreen({super.key});
|
||||||
@@ -20,7 +21,8 @@ class _CardManagementScreen extends State<CardManagementScreen> {
|
|||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).cardManagement,
|
AppLocalizations.of(context).cardManagement,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -46,42 +48,53 @@ class _CardManagementScreen extends State<CardManagementScreen> {
|
|||||||
label: AppLocalizations.of(context).applyDebitCard,
|
label: AppLocalizations.of(context).applyDebitCard,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
CardManagementTile(
|
CardManagementTile(
|
||||||
icon: Symbols.remove_moderator,
|
icon: Symbols.remove_moderator,
|
||||||
label: AppLocalizations.of(context).blockUnblockCard,
|
label: AppLocalizations.of(context).blockUnblockCard,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => const BlockCardScreen()));
|
builder: (context) => const BlockCardScreen(),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
CardManagementTile(
|
CardManagementTile(
|
||||||
icon: Symbols.password_2,
|
icon: Symbols.password_2,
|
||||||
label: AppLocalizations.of(context).changeCardPin,
|
label: AppLocalizations.of(context).changeCardPin,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
// Navigator.push(
|
||||||
context,
|
// context,
|
||||||
MaterialPageRoute(
|
// MaterialPageRoute(
|
||||||
builder: (context) =>
|
// builder: (context) => const CardPinChangeDetailsScreen(),
|
||||||
const CardPinChangeDetailsScreen()));
|
// ),
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
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),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class CardManagementTile extends StatelessWidget {
|
class CardManagementTile extends StatelessWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String label;
|
final String label;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:flutter_svg/svg.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:kmobile/features/card/screens/card_pin_set_screen.dart';
|
import 'package:kmobile/features/card/screens/card_pin_set_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class CardPinChangeDetailsScreen extends StatefulWidget {
|
class CardPinChangeDetailsScreen extends StatefulWidget {
|
||||||
const CardPinChangeDetailsScreen({super.key});
|
const CardPinChangeDetailsScreen({super.key});
|
||||||
@@ -54,7 +54,8 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).cardDetails,
|
AppLocalizations.of(context).cardDetails,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -84,14 +85,14 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
|||||||
controller: _cardController,
|
controller: _cardController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).cardNumber,
|
labelText: AppLocalizations.of(context).cardNumber,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -109,14 +110,14 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
|||||||
controller: _cvvController,
|
controller: _cvvController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).cvv,
|
labelText: AppLocalizations.of(context).cvv,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -136,15 +137,15 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
|||||||
onTap: _pickExpiryDate,
|
onTap: _pickExpiryDate,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).expiryDate,
|
labelText: AppLocalizations.of(context).expiryDate,
|
||||||
suffixIcon: Icon(Icons.calendar_today),
|
suffixIcon: const Icon(Icons.calendar_today),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -160,15 +161,15 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
|||||||
controller: _phoneController,
|
controller: _phoneController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).phone,
|
labelText: AppLocalizations.of(context).phone,
|
||||||
prefixIcon: Icon(Icons.phone),
|
prefixIcon: const Icon(Icons.phone),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -188,8 +189,9 @@ class _CardPinChangeDetailsScreen extends State<CardPinChangeDetailsScreen> {
|
|||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.blue[900],
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).next),
|
child: Text(AppLocalizations.of(context).next),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class CardPinSetScreen extends StatefulWidget {
|
class CardPinSetScreen extends StatefulWidget {
|
||||||
const CardPinSetScreen({super.key});
|
const CardPinSetScreen({super.key});
|
||||||
@@ -25,7 +25,7 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Just close the SnackBar
|
// Just close the SnackBar
|
||||||
},
|
},
|
||||||
textColor: Colors.white,
|
textColor: Theme.of(context).dialogBackgroundColor,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
behavior: SnackBarBehavior.floating,
|
behavior: SnackBarBehavior.floating,
|
||||||
@@ -54,7 +54,8 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).cardPin,
|
AppLocalizations.of(context).cardPin,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -84,14 +85,14 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
|||||||
obscureText: true,
|
obscureText: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).enterNewPin,
|
labelText: AppLocalizations.of(context).enterNewPin,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -113,14 +114,14 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
|||||||
obscureText: true,
|
obscureText: true,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).enterAgain,
|
labelText: AppLocalizations.of(context).enterAgain,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -143,8 +144,9 @@ class _CardPinSetScreen extends State<CardPinSetScreen> {
|
|||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.blue[900],
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).submit),
|
child: Text(AppLocalizations.of(context).submit),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class ChequeManagementScreen extends StatefulWidget {
|
class ChequeManagementScreen extends StatefulWidget {
|
||||||
const ChequeManagementScreen({super.key});
|
const ChequeManagementScreen({super.key});
|
||||||
@@ -24,7 +24,8 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).chequeManagement,
|
AppLocalizations.of(context).chequeManagement,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -51,54 +52,42 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
|
|||||||
label: AppLocalizations.of(context).requestChequeBook,
|
label: AppLocalizations.of(context).requestChequeBook,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ChequeManagementTile(
|
ChequeManagementTile(
|
||||||
icon: Symbols.data_alert,
|
icon: Symbols.data_alert,
|
||||||
label: AppLocalizations.of(context).enquiry,
|
label: AppLocalizations.of(context).enquiry,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(builder: (context) => const EnquiryScreen()),
|
||||||
builder: (context) => const EnquiryScreen()));
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ChequeManagementTile(
|
ChequeManagementTile(
|
||||||
icon: Symbols.approval_delegation,
|
icon: Symbols.approval_delegation,
|
||||||
label: AppLocalizations.of(context).chequeDeposit,
|
label: AppLocalizations.of(context).chequeDeposit,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ChequeManagementTile(
|
ChequeManagementTile(
|
||||||
icon: Symbols.front_hand,
|
icon: Symbols.front_hand,
|
||||||
label: AppLocalizations.of(context).stopCheque,
|
label: AppLocalizations.of(context).stopCheque,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ChequeManagementTile(
|
ChequeManagementTile(
|
||||||
icon: Symbols.cancel_presentation,
|
icon: Symbols.cancel_presentation,
|
||||||
label: AppLocalizations.of(context).revokeStop,
|
label: AppLocalizations.of(context).revokeStop,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ChequeManagementTile(
|
ChequeManagementTile(
|
||||||
icon: Symbols.payments,
|
icon: Symbols.payments,
|
||||||
label: AppLocalizations.of(context).positivePay,
|
label: AppLocalizations.of(context).positivePay,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:kmobile/data/models/user.dart';
|
import 'package:kmobile/data/models/user.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
class CustomerInfoScreen extends StatefulWidget {
|
class CustomerInfoScreen extends StatefulWidget {
|
||||||
final User user;
|
final User user;
|
||||||
@@ -16,97 +15,83 @@ class _CustomerInfoScreenState extends State<CustomerInfoScreen> {
|
|||||||
late final User user = widget.user;
|
late final User user = widget.user;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
title: Text(
|
||||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
AppLocalizations.of(context).customerInfo,
|
||||||
onPressed: () {
|
),
|
||||||
Navigator.pop(context);
|
),
|
||||||
},
|
body: SingleChildScrollView(
|
||||||
),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
title: Text(
|
child: Padding(
|
||||||
AppLocalizations.of(context).kMobile,
|
padding: const EdgeInsets.all(16.0),
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
child: SafeArea(
|
||||||
),
|
child: Center(
|
||||||
actions: [
|
child: Column(
|
||||||
Padding(
|
children: [
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
const SizedBox(height: 30),
|
||||||
child: CircleAvatar(
|
CircleAvatar(
|
||||||
backgroundColor: Colors.grey[200],
|
radius: 50,
|
||||||
radius: 20,
|
child: SvgPicture.asset(
|
||||||
child: SvgPicture.asset(
|
'assets/images/avatar_male.svg',
|
||||||
'assets/images/avatar_male.svg',
|
width: 150,
|
||||||
width: 100,
|
height: 150,
|
||||||
height: 100,
|
fit: BoxFit.cover,
|
||||||
fit: BoxFit.cover,
|
),
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10.0),
|
||||||
|
child: Text(
|
||||||
|
user.name ?? '',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: theme.colorScheme.onSurface,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${AppLocalizations.of(context).cif}: ${user.cifNumber ?? 'N/A'}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: theme.colorScheme.onSurfaceVariant),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
InfoField(
|
||||||
|
label: AppLocalizations.of(context).activeAccounts,
|
||||||
|
value: user.activeAccounts?.toString() ?? '6',
|
||||||
|
),
|
||||||
|
InfoField(
|
||||||
|
label: AppLocalizations.of(context).mobileNumber,
|
||||||
|
value: user.mobileNo ?? 'N/A',
|
||||||
|
),
|
||||||
|
InfoField(
|
||||||
|
label: AppLocalizations.of(context).dateOfBirth,
|
||||||
|
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',
|
||||||
|
), // Replace with DOB if available
|
||||||
|
InfoField(
|
||||||
|
label: AppLocalizations.of(context).branchCode,
|
||||||
|
value: user.branchId ?? 'N/A',
|
||||||
|
),
|
||||||
|
InfoField(
|
||||||
|
label: AppLocalizations.of(context).branchAddress,
|
||||||
|
value: user.address ?? 'N/A',
|
||||||
|
), // Replace with Aadhar if available
|
||||||
|
InfoField(
|
||||||
|
label: AppLocalizations.of(context).primaryId,
|
||||||
|
value: user.primaryId ?? 'N/A',
|
||||||
|
), // Replace with PAN if available
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
),
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
);
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: SafeArea(
|
|
||||||
child: Center(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
CircleAvatar(
|
|
||||||
backgroundColor: Colors.grey[200],
|
|
||||||
radius: 50,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
'assets/images/avatar_male.svg',
|
|
||||||
width: 150,
|
|
||||||
height: 150,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 10.0),
|
|
||||||
child: Text(
|
|
||||||
user.name ?? '',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'${AppLocalizations.of(context).cif}: ${user.cifNumber ?? 'N/A'}',
|
|
||||||
style:
|
|
||||||
const TextStyle(fontSize: 16, color: Colors.grey),
|
|
||||||
),
|
|
||||||
SizedBox(height: 30),
|
|
||||||
InfoField(
|
|
||||||
label: AppLocalizations.of(context).activeAccounts,
|
|
||||||
value: user.activeAccounts?.toString() ?? '6'),
|
|
||||||
InfoField(
|
|
||||||
label: AppLocalizations.of(context).mobileNumber,
|
|
||||||
value: user.mobileNo ?? 'N/A'),
|
|
||||||
InfoField(
|
|
||||||
label: AppLocalizations.of(context).dateOfBirth,
|
|
||||||
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'), // Replace with DOB if available
|
|
||||||
InfoField(
|
|
||||||
label: AppLocalizations.of(context).branchCode,
|
|
||||||
value: user.branchId ?? 'N/A'),
|
|
||||||
InfoField(
|
|
||||||
label: AppLocalizations.of(context).branchAddress,
|
|
||||||
value: user.address ??
|
|
||||||
'N/A'), // Replace with Aadhar if available
|
|
||||||
InfoField(
|
|
||||||
label: AppLocalizations.of(context).primaryId,
|
|
||||||
value: user.primaryId ??
|
|
||||||
'N/A'), // Replace with PAN if available
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +103,7 @@ class InfoField extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||||
@@ -126,19 +112,16 @@ class InfoField extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.black87,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 3),
|
const SizedBox(height: 3),
|
||||||
Text(
|
Text(
|
||||||
value,
|
value,
|
||||||
style: const TextStyle(
|
style: TextStyle(fontSize: 16, color: theme.colorScheme.onSurface),
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ import 'package:kmobile/data/repositories/transaction_repository.dart';
|
|||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
import 'package:kmobile/features/accounts/screens/account_info_screen.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/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_cubit.dart';
|
||||||
import 'package:kmobile/features/auth/controllers/auth_state.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/customer_info/screens/customer_info_screen.dart';
|
||||||
import 'package:kmobile/features/beneficiaries/screens/manage_beneficiaries_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/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/profile/profile_screen.dart';
|
||||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
@@ -20,7 +21,7 @@ import 'package:material_symbols_icons/material_symbols_icons.dart';
|
|||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:shimmer/shimmer.dart';
|
import 'package:shimmer/shimmer.dart';
|
||||||
import 'package:kmobile/data/models/transaction.dart';
|
import 'package:kmobile/data/models/transaction.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class DashboardScreen extends StatefulWidget {
|
class DashboardScreen extends StatefulWidget {
|
||||||
const DashboardScreen({super.key});
|
const DashboardScreen({super.key});
|
||||||
@@ -57,11 +58,18 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
setState(() => _transactions = fiveTxns);
|
setState(() => _transactions = fiveTxns);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(accountNo, error: e);
|
log(accountNo, error: e);
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
if (!mounted) return;
|
||||||
content:
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
Text(AppLocalizations.of(context).failedToLoad(e.toString()))));
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(context).failedToLoad(e.toString()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setState(() => _txLoading = false);
|
if (mounted) {
|
||||||
|
setState(() => _txLoading = false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,9 +81,13 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
// Call your AuthCubit or repository to refresh user/accounts data
|
// Call your AuthCubit or repository to refresh user/accounts data
|
||||||
await context.read<AuthCubit>().refreshUserData();
|
await context.read<AuthCubit>().refreshUserData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (!context.mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
/*const*/ SnackBar(
|
SnackBar(
|
||||||
content: Text(AppLocalizations.of(context).failedToRefresh)),
|
content: Text(AppLocalizations.of(context).failedToRefresh),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -84,14 +96,12 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBalanceShimmer() {
|
Widget _buildBalanceShimmer() {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return Shimmer.fromColors(
|
return Shimmer.fromColors(
|
||||||
baseColor: Colors.white.withOpacity(0.7),
|
baseColor: theme.primaryColor,
|
||||||
highlightColor: Colors.white.withOpacity(0.3),
|
highlightColor: theme.colorScheme.onPrimary,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 100,
|
width: 200, height: 42, color: theme.scaffoldBackgroundColor),
|
||||||
height: 32,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +116,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
'dr.',
|
'dr.',
|
||||||
'shri',
|
'shri',
|
||||||
'smt.',
|
'smt.',
|
||||||
'kumari'
|
'kumari',
|
||||||
];
|
];
|
||||||
String processed = name.trim().toLowerCase();
|
String processed = name.trim().toLowerCase();
|
||||||
for (final title in titles) {
|
for (final title in titles) {
|
||||||
@@ -151,6 +161,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await storage.write('biometric_prompt_shown', 'true');
|
await storage.write('biometric_prompt_shown', 'true');
|
||||||
|
if (!mounted) return;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context).later),
|
child: Text(AppLocalizations.of(context).later),
|
||||||
@@ -159,6 +170,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final auth = LocalAuthentication();
|
final auth = LocalAuthentication();
|
||||||
final canCheck = await auth.canCheckBiometrics;
|
final canCheck = await auth.canCheckBiometrics;
|
||||||
|
if (!mounted) return;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if (canCheck) {
|
if (canCheck) {
|
||||||
ok = await auth.authenticate(
|
ok = await auth.authenticate(
|
||||||
@@ -169,6 +181,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
await storage.write('biometric_enabled', 'true');
|
await storage.write('biometric_enabled', 'true');
|
||||||
}
|
}
|
||||||
await storage.write('biometric_prompt_shown', 'true');
|
await storage.write('biometric_prompt_shown', 'true');
|
||||||
|
if (!mounted) return;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context).enable),
|
child: Text(AppLocalizations.of(context).enable),
|
||||||
@@ -180,6 +193,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return BlocListener<AuthCubit, AuthState>(
|
return BlocListener<AuthCubit, AuthState>(
|
||||||
listener: (context, state) async {
|
listener: (context, state) async {
|
||||||
if (state is Authenticated && !_biometricPromptShown) {
|
if (state is Authenticated && !_biometricPromptShown) {
|
||||||
@@ -192,16 +206,18 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: const Color(0xfff5f9fc),
|
backgroundColor: theme.scaffoldBackgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: const Color(0xfff5f9fc),
|
backgroundColor: theme.scaffoldBackgroundColor,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).kMobile,
|
AppLocalizations.of(context).kconnect,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryColor,
|
color: theme.primaryColor,
|
||||||
fontWeight: FontWeight.w500),
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
centerTitle: true,
|
||||||
actions: [
|
actions: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
padding: const EdgeInsets.only(right: 10.0),
|
||||||
@@ -211,7 +227,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => const ProfileScreen()),
|
builder: (context) => const ProfileScreen(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
@@ -228,345 +245,435 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: BlocBuilder<AuthCubit, AuthState>(builder: (context, state) {
|
body: BlocBuilder<AuthCubit, AuthState>(
|
||||||
if (state is AuthLoading || state is AuthInitial) {
|
builder: (context, state) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
if (state is AuthLoading || state is AuthInitial) {
|
||||||
}
|
return const Center(child: CircularProgressIndicator());
|
||||||
if (state is Authenticated) {
|
|
||||||
final users = state.users;
|
|
||||||
final currAccount = users[selectedAccountIndex];
|
|
||||||
// first‐time load
|
|
||||||
if (!_txInitialized) {
|
|
||||||
_txInitialized = true;
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
_loadTransactions(currAccount.accountNo!);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
final firstName = getProcessedFirstName(currAccount.name);
|
if (state is Authenticated) {
|
||||||
|
final users = state.users;
|
||||||
|
final currAccount = users[selectedAccountIndex];
|
||||||
|
// first‐time load
|
||||||
|
if (!_txInitialized) {
|
||||||
|
_txInitialized = true;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_loadTransactions(currAccount.accountNo!);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
final firstName = getProcessedFirstName(currAccount.name);
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
padding: const EdgeInsets.only(left: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
"${AppLocalizations.of(context).hi} $firstName",
|
"${AppLocalizations.of(context).hi} $firstName!",
|
||||||
style: GoogleFonts.montserrat().copyWith(
|
style: GoogleFonts.baumans().copyWith(
|
||||||
fontSize: 25,
|
fontSize: 20,
|
||||||
color: Theme.of(context).primaryColorDark,
|
color: theme.primaryColor,
|
||||||
fontWeight: FontWeight.w700),
|
fontWeight: FontWeight.w700,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 16),
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
// Account Info Card
|
// Account Info Card
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 18, vertical: 10),
|
horizontal: 18,
|
||||||
decoration: BoxDecoration(
|
vertical: 10,
|
||||||
color: Theme.of(context).primaryColor,
|
),
|
||||||
borderRadius: BorderRadius.circular(16),
|
decoration: BoxDecoration(
|
||||||
),
|
color: theme.primaryColor,
|
||||||
child: Column(
|
borderRadius: BorderRadius.circular(16),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
),
|
||||||
children: [
|
child: Column(
|
||||||
Row(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(AppLocalizations.of(context).accountNumber,
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"${getFullAccountType(currAccount.accountType)}: ",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white, fontSize: 12)),
|
color: theme.colorScheme.onPrimary,
|
||||||
DropdownButton<int>(
|
fontSize: 18,
|
||||||
value: selectedAccountIndex,
|
fontWeight: FontWeight.w700,
|
||||||
dropdownColor: Theme.of(context).primaryColor,
|
),
|
||||||
underline: const SizedBox(),
|
),
|
||||||
icon: const Icon(Icons.keyboard_arrow_down),
|
DropdownButton<int>(
|
||||||
iconEnabledColor: Colors.white,
|
value: selectedAccountIndex,
|
||||||
style: const TextStyle(
|
dropdownColor: theme.primaryColor,
|
||||||
color: Colors.white, fontSize: 14),
|
underline: const SizedBox(),
|
||||||
items: List.generate(users.length, (index) {
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
return DropdownMenuItem<int>(
|
iconEnabledColor: theme.colorScheme.onPrimary,
|
||||||
value: index,
|
style: TextStyle(
|
||||||
child: Text(
|
color: theme.colorScheme.onPrimary,
|
||||||
users[index].accountNo ?? 'N/A',
|
fontSize: 18,
|
||||||
style: const TextStyle(
|
),
|
||||||
color: Colors.white, fontSize: 14),
|
items: List.generate(users.length, (index) {
|
||||||
),
|
return DropdownMenuItem<int>(
|
||||||
);
|
value: index,
|
||||||
}),
|
child: Text(
|
||||||
onChanged: (int? newIndex) async {
|
users[index].accountNo ?? 'N/A',
|
||||||
if (newIndex == null ||
|
style: TextStyle(
|
||||||
newIndex == selectedAccountIndex) {
|
color: theme.colorScheme.onPrimary,
|
||||||
return;
|
fontSize: 18,
|
||||||
}
|
fontWeight: FontWeight.w700,
|
||||||
if (isBalanceLoading) return;
|
|
||||||
if (isVisible) {
|
|
||||||
setState(() {
|
|
||||||
isBalanceLoading = true;
|
|
||||||
selectedAccountIndex = newIndex;
|
|
||||||
});
|
|
||||||
await Future.delayed(
|
|
||||||
const Duration(milliseconds: 200));
|
|
||||||
setState(() {
|
|
||||||
isBalanceLoading = false;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
selectedAccountIndex = newIndex;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await _loadTransactions(
|
|
||||||
users[newIndex].accountNo!);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
icon: isRefreshing
|
|
||||||
? const SizedBox(
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
strokeWidth: 2,
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: const Icon(Icons.refresh,
|
);
|
||||||
color: Colors.white),
|
}),
|
||||||
onPressed: isRefreshing
|
onChanged: (int? newIndex) async {
|
||||||
? null
|
if (newIndex == null ||
|
||||||
: () => _refreshAccountData(context),
|
newIndex == selectedAccountIndex) {
|
||||||
tooltip: 'Refresh',
|
return;
|
||||||
),
|
}
|
||||||
],
|
if (isBalanceLoading) return;
|
||||||
),
|
if (isVisible) {
|
||||||
Text(
|
setState(() {
|
||||||
getFullAccountType(currAccount.accountType),
|
isBalanceLoading = true;
|
||||||
style: const TextStyle(
|
selectedAccountIndex = newIndex;
|
||||||
color: Colors.white, fontSize: 16),
|
});
|
||||||
),
|
await Future.delayed(
|
||||||
const SizedBox(height: 4),
|
const Duration(milliseconds: 200),
|
||||||
Row(
|
);
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
setState(() {
|
||||||
children: [
|
isBalanceLoading = false;
|
||||||
const Text("₹ ",
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
selectedAccountIndex = newIndex;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await _loadTransactions(
|
||||||
|
users[newIndex].accountNo!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
IconButton(
|
||||||
|
icon: isRefreshing
|
||||||
|
? SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: theme.colorScheme.onPrimary,
|
||||||
|
strokeWidth: 2,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Icon(
|
||||||
|
Symbols.refresh,
|
||||||
|
color: theme.colorScheme.onPrimary,
|
||||||
|
),
|
||||||
|
onPressed: isRefreshing
|
||||||
|
? null
|
||||||
|
: () => _refreshAccountData(context),
|
||||||
|
tooltip: 'Refresh',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"₹ ",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: theme.colorScheme.onPrimary,
|
||||||
fontSize: 40,
|
fontSize: 40,
|
||||||
fontWeight: FontWeight.w700)),
|
fontWeight: FontWeight.w700,
|
||||||
isRefreshing || isBalanceLoading
|
),
|
||||||
? _buildBalanceShimmer()
|
),
|
||||||
: Text(
|
isRefreshing || isBalanceLoading
|
||||||
isVisible
|
? _buildBalanceShimmer()
|
||||||
? currAccount.currentBalance ?? '0.00'
|
: Text(
|
||||||
: '********',
|
isVisible
|
||||||
style: const TextStyle(
|
? currAccount.currentBalance ??
|
||||||
color: Colors.white,
|
'0.00'
|
||||||
|
: '*****',
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorScheme.onPrimary,
|
||||||
fontSize: 40,
|
fontSize: 40,
|
||||||
fontWeight: FontWeight.w700)),
|
fontWeight: FontWeight.w700,
|
||||||
const Spacer(),
|
),
|
||||||
InkWell(
|
),
|
||||||
onTap: () async {
|
const Spacer(),
|
||||||
if (isBalanceLoading) return;
|
InkWell(
|
||||||
if (!isVisible) {
|
onTap: () async {
|
||||||
setState(() {
|
if (isBalanceLoading) return;
|
||||||
isBalanceLoading = true;
|
if (!isVisible) {
|
||||||
});
|
setState(() {
|
||||||
await Future.delayed(
|
isBalanceLoading = true;
|
||||||
const Duration(seconds: 1));
|
});
|
||||||
setState(() {
|
await Future.delayed(
|
||||||
isVisible = true;
|
const Duration(seconds: 1),
|
||||||
isBalanceLoading = false;
|
);
|
||||||
});
|
setState(() {
|
||||||
} else {
|
isVisible = true;
|
||||||
setState(() {
|
isBalanceLoading = false;
|
||||||
isVisible = false;
|
});
|
||||||
});
|
} else {
|
||||||
}
|
setState(() {
|
||||||
},
|
isVisible = false;
|
||||||
child: Icon(
|
});
|
||||||
isVisible
|
}
|
||||||
? Symbols.visibility_lock
|
},
|
||||||
: Symbols.visibility,
|
child: Padding(
|
||||||
color: Colors.white),
|
padding: const EdgeInsets.all(8.0),
|
||||||
),
|
child: Icon(
|
||||||
],
|
isVisible
|
||||||
|
? Symbols.visibility_lock
|
||||||
|
: Symbols.visibility,
|
||||||
|
color: theme.scaffoldBackgroundColor,
|
||||||
|
weight: 800,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 18),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context).quickLinks,
|
||||||
|
style: const TextStyle(fontSize: 17),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Quick Links
|
||||||
|
GridView.count(
|
||||||
|
crossAxisCount: 4,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
children: [
|
||||||
|
_buildQuickLink(
|
||||||
|
Symbols.id_card,
|
||||||
|
AppLocalizations.of(context).customerInfo,
|
||||||
|
() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => CustomerInfoScreen(
|
||||||
|
user: users[selectedAccountIndex],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
_buildQuickLink(
|
||||||
|
Symbols.currency_rupee,
|
||||||
|
AppLocalizations.of(context).quickPay,
|
||||||
|
() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => QuickPayScreen(
|
||||||
|
debitAccount: currAccount.accountNo!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_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.server_person,
|
||||||
|
AppLocalizations.of(context).accountInfo,
|
||||||
|
() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => AccountInfoScreen(
|
||||||
|
users: users,
|
||||||
|
selectedIndex: selectedAccountIndex,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
_buildQuickLink(Symbols.receipt_long,
|
||||||
|
AppLocalizations.of(context).accountStatement,
|
||||||
|
() {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
AccountStatementScreen(
|
||||||
|
accountNo: users[selectedAccountIndex]
|
||||||
|
.accountNo!,
|
||||||
|
balance: users[selectedAccountIndex]
|
||||||
|
.availableBalance!,
|
||||||
|
)));
|
||||||
|
}),
|
||||||
|
_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),
|
||||||
const SizedBox(height: 18),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context).quickLinks,
|
|
||||||
style: TextStyle(fontSize: 17),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
// Quick Links
|
// Recent Transactions
|
||||||
GridView.count(
|
Text(
|
||||||
crossAxisCount: 4,
|
AppLocalizations.of(context).recentTransactions,
|
||||||
shrinkWrap: true,
|
style: const TextStyle(fontSize: 17),
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
),
|
||||||
children: [
|
const SizedBox(height: 16),
|
||||||
_buildQuickLink(Symbols.id_card,
|
if (_txLoading)
|
||||||
AppLocalizations.of(context).customerInfo, () {
|
..._buildTransactionShimmer()
|
||||||
Navigator.push(
|
else if (_transactions.isNotEmpty)
|
||||||
context,
|
..._transactions.map(
|
||||||
MaterialPageRoute(
|
(tx) => ListTile(
|
||||||
builder: (context) => CustomerInfoScreen(
|
|
||||||
user: users[selectedAccountIndex],
|
|
||||||
)));
|
|
||||||
}),
|
|
||||||
_buildQuickLink(Symbols.currency_rupee,
|
|
||||||
AppLocalizations.of(context).quickPay, () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => QuickPayScreen(
|
|
||||||
debitAccount: currAccount.accountNo!)));
|
|
||||||
}),
|
|
||||||
_buildQuickLink(Symbols.send_money,
|
|
||||||
AppLocalizations.of(context).fundTransfer, () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
const FundTransferBeneficiaryScreen()));
|
|
||||||
}, disable: false),
|
|
||||||
_buildQuickLink(Symbols.server_person,
|
|
||||||
AppLocalizations.of(context).accountInfo, () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => AccountInfoScreen(
|
|
||||||
user: users[selectedAccountIndex])));
|
|
||||||
}),
|
|
||||||
_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: false),
|
|
||||||
_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),
|
|
||||||
|
|
||||||
// Recent Transactions
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context).recentTransactions,
|
|
||||||
style: TextStyle(fontSize: 17),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
if (_txLoading)
|
|
||||||
..._buildTransactionShimmer()
|
|
||||||
else if (_transactions.isNotEmpty)
|
|
||||||
..._transactions.map((tx) => ListTile(
|
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
tx.type == 'CR'
|
tx.type == 'CR'
|
||||||
? Symbols.call_received
|
? Symbols.call_received
|
||||||
: Symbols.call_made,
|
: Symbols.call_made,
|
||||||
color:
|
color: tx.type == 'CR'
|
||||||
tx.type == 'CR' ? Colors.green : Colors.red,
|
? const Color(0xFF10BB10)
|
||||||
|
: theme.colorScheme.error,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
|
tx.date ?? '',
|
||||||
|
style: const TextStyle(fontSize: 15),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
tx.name != null
|
tx.name != null
|
||||||
? (tx.name!.length > 18
|
? (tx.name!.length > 18
|
||||||
? tx.name!.substring(0, 20)
|
? tx.name!.substring(0, 22)
|
||||||
: tx.name!)
|
: tx.name!)
|
||||||
: '',
|
: '',
|
||||||
style: const TextStyle(fontSize: 14),
|
style: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
subtitle: Text(tx.date ?? '',
|
trailing: Text(
|
||||||
style: const TextStyle(fontSize: 12)),
|
"₹${tx.amount}",
|
||||||
trailing: Text("₹${tx.amount}",
|
style: const TextStyle(fontSize: 17),
|
||||||
style: const TextStyle(fontSize: 16)),
|
),
|
||||||
))
|
onTap: () {
|
||||||
else
|
Navigator.push(
|
||||||
Padding(
|
context,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
MaterialPageRoute(
|
||||||
child: Center(
|
builder: (_) =>
|
||||||
child: Text(
|
TransactionDetailsScreen(transaction: tx),
|
||||||
AppLocalizations.of(context).noTransactions,
|
),
|
||||||
style: TextStyle(
|
);
|
||||||
fontSize: 16,
|
},
|
||||||
color: Colors.grey[600],
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 24.0),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).noTransactions,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: Colors.grey[600],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
return Center(
|
||||||
|
child: Text(AppLocalizations.of(context).somethingWentWrong),
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
return Center(
|
),
|
||||||
child: Text(AppLocalizations.of(context).somethingWentWrong));
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildTransactionShimmer() {
|
List<Widget> _buildTransactionShimmer() {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return List.generate(3, (i) {
|
return List.generate(3, (i) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Shimmer.fromColors(
|
leading: Shimmer.fromColors(
|
||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: const CircleAvatar(radius: 12, backgroundColor: Colors.white),
|
child: CircleAvatar(
|
||||||
|
radius: 12, backgroundColor: theme.scaffoldBackgroundColor),
|
||||||
),
|
),
|
||||||
title: Shimmer.fromColors(
|
title: Shimmer.fromColors(
|
||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: Container(height: 10, width: 100, color: Colors.white),
|
child: Container(
|
||||||
|
height: 10, width: 100, color: theme.scaffoldBackgroundColor),
|
||||||
),
|
),
|
||||||
subtitle: Shimmer.fromColors(
|
subtitle: Shimmer.fromColors(
|
||||||
baseColor: Colors.grey[300]!,
|
baseColor: Colors.grey[300]!,
|
||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: Container(height: 8, width: 60, color: Colors.white),
|
child: Container(
|
||||||
|
height: 8, width: 60, color: theme.scaffoldBackgroundColor),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildQuickLink(IconData icon, String label, VoidCallback onTap,
|
Widget _buildQuickLink(
|
||||||
{bool disable = false}) {
|
IconData icon,
|
||||||
|
String label,
|
||||||
|
VoidCallback onTap, {
|
||||||
|
bool disable = false,
|
||||||
|
}) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: disable ? null : onTap,
|
onTap: disable ? null : onTap,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(icon,
|
Icon(
|
||||||
size: 30,
|
icon,
|
||||||
color: disable ? Colors.grey : Theme.of(context).primaryColor),
|
size: 30,
|
||||||
|
color: disable
|
||||||
|
? theme.colorScheme.surfaceContainerHighest
|
||||||
|
: theme.primaryColor,
|
||||||
|
grade: 200,
|
||||||
|
weight: 700,
|
||||||
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(label,
|
Text(
|
||||||
textAlign: TextAlign.center,
|
label,
|
||||||
style: const TextStyle(fontSize: 13)),
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../accounts/models/account.dart';
|
import '../../accounts/models/account.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class AccountCard extends StatelessWidget {
|
class AccountCard extends StatelessWidget {
|
||||||
final Account account;
|
final Account account;
|
||||||
|
|
||||||
const AccountCard({
|
const AccountCard({super.key, required this.account});
|
||||||
super.key,
|
|
||||||
required this.account,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -16,14 +13,7 @@ class AccountCard extends StatelessWidget {
|
|||||||
width: 300,
|
width: 300,
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
color: Theme.of(context).primaryColor,
|
||||||
begin: Alignment.topLeft,
|
|
||||||
end: Alignment.bottomRight,
|
|
||||||
colors: [
|
|
||||||
Theme.of(context).primaryColor,
|
|
||||||
Theme.of(context).primaryColor.withBlue(200),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
@@ -42,8 +32,8 @@ class AccountCard extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
account.accountType,
|
account.accountType,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
@@ -52,23 +42,21 @@ class AccountCard extends StatelessWidget {
|
|||||||
account.accountType == 'Savings'
|
account.accountType == 'Savings'
|
||||||
? Icons.savings
|
? Icons.savings
|
||||||
: Icons.account_balance,
|
: Icons.account_balance,
|
||||||
color: Colors.white,
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(
|
Text(
|
||||||
account.accountNumber,
|
account.accountNumber,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white70,
|
color: Theme.of(context).scaffoldBackgroundColor, fontSize: 16),
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Text(
|
Text(
|
||||||
'${account.currency} ${account.balance.toStringAsFixed(2)}',
|
'${account.currency} ${account.balance.toStringAsFixed(2)}',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
@@ -77,9 +65,7 @@ class AccountCard extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).availableBalance,
|
AppLocalizations.of(context).availableBalance,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white70,
|
color: Theme.of(context).scaffoldBackgroundColor, fontSize: 16),
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import '../../transactions/models/transaction.dart';
|
|||||||
|
|
||||||
class TransactionListItem extends StatelessWidget {
|
class TransactionListItem extends StatelessWidget {
|
||||||
final Transaction transaction;
|
final Transaction transaction;
|
||||||
|
|
||||||
const TransactionListItem({
|
const TransactionListItem({
|
||||||
super.key,
|
super.key,
|
||||||
required this.transaction,
|
required this.transaction,
|
||||||
@@ -13,7 +13,7 @@ class TransactionListItem extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final bool isIncome = transaction.amount > 0;
|
final bool isIncome = transaction.amount > 0;
|
||||||
|
|
||||||
return Card(
|
return Card(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||||
@@ -25,7 +25,8 @@ class TransactionListItem extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: _getCategoryColor(transaction.category).withAlpha((0.1 * 255).toInt()),
|
color: _getCategoryColor(transaction.category)
|
||||||
|
.withAlpha((0.1 * 255).toInt()),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -34,7 +35,7 @@ class TransactionListItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
|
|
||||||
// Transaction details
|
// Transaction details
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -48,7 +49,8 @@ class TransactionListItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
DateFormat('MMM dd, yyyy • h:mm a').format(transaction.date),
|
DateFormat('MMM dd, yyyy • h:mm a')
|
||||||
|
.format(transaction.date),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
@@ -57,7 +59,7 @@ class TransactionListItem extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Amount
|
// Amount
|
||||||
Text(
|
Text(
|
||||||
'${isIncome ? '+' : ''}${transaction.amount.toStringAsFixed(2)} USD',
|
'${isIncome ? '+' : ''}${transaction.amount.toStringAsFixed(2)} USD',
|
||||||
@@ -106,4 +108,4 @@ class TransactionListItem extends StatelessWidget {
|
|||||||
return Icons.category;
|
return Icons.category;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class EnquiryScreen extends StatefulWidget {
|
class EnquiryScreen extends StatefulWidget {
|
||||||
const EnquiryScreen({super.key});
|
const EnquiryScreen({super.key});
|
||||||
@@ -38,12 +40,15 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
|||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => _launchEmailAddress(email),
|
onTap: () => _launchEmailAddress(email),
|
||||||
child: Text(email, style: const TextStyle(color: Colors.blue)),
|
child: Text(email,
|
||||||
|
style: TextStyle(color: Theme.of(context).primaryColor)),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => _launchPhoneNumber(phone),
|
onTap: () => _launchPhoneNumber(phone),
|
||||||
child: Text(phone, style: const TextStyle(color: Colors.blue)),
|
child: Text(phone,
|
||||||
|
style:
|
||||||
|
TextStyle(color: Theme.of(context).scaffoldBackgroundColor)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -61,7 +66,8 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).enquiry,
|
AppLocalizations.of(context).enquiry,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -86,17 +92,18 @@ class _EnquiryScreen extends State<EnquiryScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// … existing Mail us / Call us / Write to us …
|
// … existing Mail us / Call us / Write to us …
|
||||||
|
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(AppLocalizations.of(context).writeToUs,
|
Text(
|
||||||
style: TextStyle(color: Colors.grey)),
|
AppLocalizations.of(context).writeToUs,
|
||||||
|
style: const TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
const Text(
|
Text(
|
||||||
"complaint@kccb.in",
|
"complaint@kccb.in",
|
||||||
style: TextStyle(color: Colors.blue),
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).keyContacts,
|
AppLocalizations.of(context).keyContacts,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|||||||
@@ -0,0 +1,437 @@
|
|||||||
|
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),
|
||||||
|
),
|
||||||
|
body: 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),
|
||||||
|
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).primaryColor,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
borderColor: Colors.transparent,
|
||||||
|
selectedBorderColor: Colors.transparent,
|
||||||
|
splashColor:
|
||||||
|
Theme.of(context).primaryColor,
|
||||||
|
highlightColor:
|
||||||
|
Theme.of(context).primaryColor,
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,115 +1,131 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:kmobile/widgets/bank_logos.dart';
|
||||||
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_amount_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:flutter_gen/gen_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 {
|
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
|
@override
|
||||||
State<FundTransferBeneficiaryScreen> createState() =>
|
State<FundTransferBeneficiaryScreen> createState() =>
|
||||||
_FundTransferBeneficiaryScreen();
|
_FundTransferBeneficiaryScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FundTransferBeneficiaryScreen
|
class _FundTransferBeneficiaryScreenState
|
||||||
extends State<FundTransferBeneficiaryScreen> {
|
extends State<FundTransferBeneficiaryScreen> {
|
||||||
final List<Map<String, String>> beneficiaries = [
|
var service = getIt<BeneficiaryService>();
|
||||||
{
|
bool _isLoading = true;
|
||||||
'bank': 'State Bank Of India',
|
List<Beneficiary> _beneficiaries = [];
|
||||||
'name': 'Trina Bakshi',
|
|
||||||
},
|
@override
|
||||||
{
|
void initState() {
|
||||||
'bank': 'State Bank Of India',
|
super.initState();
|
||||||
'name': 'Sheetal Rao',
|
_loadBeneficiaries();
|
||||||
},
|
}
|
||||||
{
|
|
||||||
'bank': 'Punjab National Bank',
|
Future<void> _loadBeneficiaries() async {
|
||||||
'name': 'Manoj Kumar',
|
final data = await service.fetchBeneficiaryList();
|
||||||
},
|
setState(() {
|
||||||
{
|
_beneficiaries = data
|
||||||
'bank': 'State Bank Of India',
|
.where((b) => widget.isOwnBank
|
||||||
'name': 'Rohit Mehra',
|
? 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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildShimmerList() {
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: 6,
|
||||||
|
itemBuilder: (context, index) => Shimmer.fromColors(
|
||||||
|
baseColor: Colors.grey.shade300,
|
||||||
|
highlightColor: Colors.grey.shade100,
|
||||||
|
child: ListTile(
|
||||||
|
leading: const CircleAvatar(
|
||||||
|
radius: 24,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
title: Container(
|
||||||
|
height: 16,
|
||||||
|
color: Colors.white,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
),
|
||||||
|
subtitle: Container(
|
||||||
|
height: 14,
|
||||||
|
color: Colors.white,
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBeneficiaryList() {
|
||||||
|
if (_beneficiaries.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||||
|
}
|
||||||
|
return ListView.builder(
|
||||||
|
itemCount: _beneficiaries.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final beneficiary = _beneficiaries[index];
|
||||||
|
return ListTile(
|
||||||
|
leading: CircleAvatar(
|
||||||
|
radius: 24,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
child: getBankLogo(beneficiary.bankName),
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
title: Text(AppLocalizations.of(context).beneficiaries),
|
||||||
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: const CircleAvatar(
|
|
||||||
backgroundColor: Colors.blue, 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()));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const AddBeneficiaryScreen()));
|
|
||||||
},
|
|
||||||
backgroundColor: Colors.grey[300],
|
|
||||||
foregroundColor: Colors.blue[900],
|
|
||||||
elevation: 5,
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
body: _isLoading ? _buildShimmerList() : _buildBeneficiaryList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,148 +1,88 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class FundTransferScreen extends StatefulWidget {
|
class FundTransferScreen extends StatelessWidget {
|
||||||
const FundTransferScreen({super.key});
|
final String creditAccountNo;
|
||||||
|
final String remitterName;
|
||||||
|
|
||||||
@override
|
const FundTransferScreen({
|
||||||
State<FundTransferScreen> createState() => _FundTransferScreen();
|
super.key,
|
||||||
}
|
required this.creditAccountNo,
|
||||||
|
required this.remitterName,
|
||||||
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',
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
title: Text(AppLocalizations.of(context).fundTransfer),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: Column(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
FundTransferManagementTile(
|
||||||
Row(
|
icon: Symbols.input_circle,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
label: AppLocalizations.of(context).ownBank,
|
||||||
children: [
|
onTap: () {
|
||||||
Text(AppLocalizations.of(context).debitFrom),
|
Navigator.push(
|
||||||
Text(
|
context,
|
||||||
'0300015678903456',
|
MaterialPageRoute(
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
|
builder: (context) => FundTransferBeneficiaryScreen(
|
||||||
)
|
creditAccountNo: creditAccountNo,
|
||||||
],
|
remitterName: remitterName,
|
||||||
|
isOwnBank: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const Divider(height: 1),
|
||||||
Text(AppLocalizations.of(context).enterAmount,
|
FundTransferManagementTile(
|
||||||
style: TextStyle(fontSize: 20)),
|
icon: Symbols.output_circle,
|
||||||
const SizedBox(height: 20),
|
label: AppLocalizations.of(context).outsideBank,
|
||||||
Container(
|
onTap: () {
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
Navigator.push(
|
||||||
decoration: BoxDecoration(
|
context,
|
||||||
color: Colors.grey.shade200,
|
MaterialPageRoute(
|
||||||
borderRadius: BorderRadius.circular(12),
|
builder: (context) => FundTransferBeneficiaryScreen(
|
||||||
),
|
creditAccountNo: creditAccountNo,
|
||||||
child: Text(
|
remitterName: remitterName,
|
||||||
amount.isEmpty ? "0" : amount,
|
isOwnBank: false,
|
||||||
style: const TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
const Spacer(),
|
},
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
color: Colors.white,
|
|
||||||
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),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
@@ -7,15 +8,13 @@ import 'package:kmobile/data/models/payment_response.dart';
|
|||||||
import 'package:lottie/lottie.dart';
|
import 'package:lottie/lottie.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'package:confetti/confetti.dart';
|
||||||
|
|
||||||
class PaymentAnimationScreen extends StatefulWidget {
|
class PaymentAnimationScreen extends StatefulWidget {
|
||||||
final Future<PaymentResponse> paymentResponse;
|
final Future<PaymentResponse> paymentResponse;
|
||||||
|
|
||||||
const PaymentAnimationScreen({
|
const PaymentAnimationScreen({super.key, required this.paymentResponse});
|
||||||
super.key,
|
|
||||||
required this.paymentResponse,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PaymentAnimationScreen> createState() => _PaymentAnimationScreenState();
|
State<PaymentAnimationScreen> createState() => _PaymentAnimationScreenState();
|
||||||
@@ -23,6 +22,20 @@ class PaymentAnimationScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||||
final GlobalKey _shareKey = GlobalKey();
|
final GlobalKey _shareKey = GlobalKey();
|
||||||
|
late ConfettiController _confettiController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_confettiController =
|
||||||
|
ConfettiController(duration: const Duration(seconds: 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_confettiController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _shareScreenshot() async {
|
Future<void> _shareScreenshot() async {
|
||||||
try {
|
try {
|
||||||
@@ -37,14 +50,18 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
final file = await File('${tempDir.path}/payment_result.png').create();
|
final file = await File('${tempDir.path}/payment_result.png').create();
|
||||||
await file.writeAsBytes(pngBytes);
|
await file.writeAsBytes(pngBytes);
|
||||||
|
|
||||||
await Share.shareXFiles([XFile(file.path)],
|
await Share.shareXFiles(
|
||||||
text: '${AppLocalizations.of(context).paymentResult}');
|
[XFile(file.path)],
|
||||||
|
text: AppLocalizations.of(context).paymentResult,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
'${AppLocalizations.of(context).failedToShareScreenshot}: $e')),
|
'${AppLocalizations.of(context).failedToShareScreenshot}: $e',
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,8 +86,29 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
final response = snapshot.data!;
|
final response = snapshot.data!;
|
||||||
final isSuccess = response.isSuccess;
|
final isSuccess = response.isSuccess;
|
||||||
|
|
||||||
|
if (isSuccess) _confettiController.play();
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
child: ConfettiWidget(
|
||||||
|
confettiController: _confettiController,
|
||||||
|
blastDirectionality: BlastDirectionality.explosive,
|
||||||
|
emissionFrequency: 0.2,
|
||||||
|
numberOfParticles: 40,
|
||||||
|
gravity: 0.3,
|
||||||
|
maxBlastForce: 25,
|
||||||
|
minBlastForce: 10,
|
||||||
|
shouldLoop: false,
|
||||||
|
colors: const [
|
||||||
|
Colors.green,
|
||||||
|
Colors.blue,
|
||||||
|
Colors.pink,
|
||||||
|
Colors.orange,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
Center(
|
Center(
|
||||||
child: RepaintBoundary(
|
child: RepaintBoundary(
|
||||||
key: _shareKey,
|
key: _shareKey,
|
||||||
@@ -95,48 +133,61 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context)
|
AppLocalizations.of(context)
|
||||||
.paymentSuccessful,
|
.paymentSuccessful,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.green),
|
color: Colors.green,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
if (response.amount != null)
|
if (response.amount != null)
|
||||||
Text(
|
Text(
|
||||||
'${AppLocalizations.of(context).amount}: ${response.amount} ${response.currency ?? ''}',
|
'${AppLocalizations.of(context).amount}: ${response.amount} ${response.currency ?? ""}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
fontFamily: 'Rubik'),
|
fontFamily: 'Rubik',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (response.creditedAccount != null)
|
if (response.creditedAccount != null)
|
||||||
Text(
|
Text(
|
||||||
'${AppLocalizations.of(context).creditedAccount}: ${response.creditedAccount}',
|
'${AppLocalizations.of(context).creditedAccount}: ${response.creditedAccount}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
fontFamily: 'Rubik'),
|
fontFamily: 'Rubik',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (response.date != null)
|
if (response.date != null)
|
||||||
Text(
|
Text(
|
||||||
'Date: ${response.date!.toLocal().toIso8601String()}',
|
"Date: ${response.date!.toLocal().toIso8601String()}",
|
||||||
style: const TextStyle(fontSize: 16),
|
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(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).paymentFailed,
|
AppLocalizations.of(context).paymentFailed,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 22,
|
fontSize: 22,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.red),
|
color: Colors.red,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
if (response.errorMessage != null)
|
if (response.errorMessage != null)
|
||||||
Text(
|
Text(
|
||||||
response.errorMessage!,
|
response.errorMessage ?? '',
|
||||||
style: const TextStyle(fontSize: 16),
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -147,7 +198,6 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Buttons at the bottom
|
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
@@ -161,9 +211,10 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
Icons.share_rounded,
|
Icons.share_rounded,
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
label: Text(AppLocalizations.of(context).share,
|
label: Text(
|
||||||
style:
|
AppLocalizations.of(context).share,
|
||||||
TextStyle(color: Theme.of(context).primaryColor)),
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
|
),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Theme.of(context).scaffoldBackgroundColor,
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
@@ -171,15 +222,14 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
horizontal: 32, vertical: 12),
|
horizontal: 32, vertical: 12),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor, width: 1),
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
),
|
),
|
||||||
textStyle: const TextStyle(
|
textStyle: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Colors.black),
|
color: Colors.black,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
@@ -187,6 +237,7 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.popUntil((route) => route.isFirst);
|
.popUntil((route) => route.isFirst);
|
||||||
},
|
},
|
||||||
|
icon: const Icon(Icons.check),
|
||||||
label: Text(AppLocalizations.of(context).done),
|
label: Text(AppLocalizations.of(context).done),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
@@ -195,7 +246,9 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
|||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
),
|
),
|
||||||
textStyle: const TextStyle(
|
textStyle: const TextStyle(
|
||||||
fontSize: 18, fontWeight: FontWeight.w600),
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
|
||||||
|
|
||||||
@@ -12,8 +11,10 @@ class TpinOtpScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
||||||
final List<FocusNode> _focusNodes = List.generate(4, (_) => FocusNode());
|
final List<FocusNode> _focusNodes = List.generate(4, (_) => FocusNode());
|
||||||
final List<TextEditingController> _controllers =
|
final List<TextEditingController> _controllers = List.generate(
|
||||||
List.generate(4, (_) => TextEditingController());
|
4,
|
||||||
|
(_) => TextEditingController(),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -42,9 +43,7 @@ class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
|||||||
if (_enteredOtp == '0000') {
|
if (_enteredOtp == '0000') {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(builder: (_) => TpinSetScreen()),
|
||||||
builder: (_) => TpinSetScreen(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@@ -67,8 +66,11 @@ class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
// mainAxisSize: MainAxisSize.min,
|
// mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.lock_outline,
|
Icon(
|
||||||
size: 48, color: theme.colorScheme.primary),
|
Icons.lock_outline,
|
||||||
|
size: 48,
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).otpVerification,
|
AppLocalizations.of(context).otpVerification,
|
||||||
@@ -103,7 +105,7 @@ class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
counterText: '',
|
counterText: '',
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.blue[50],
|
fillColor: Theme.of(context).primaryColorLight,
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
@@ -129,12 +131,15 @@ class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
|||||||
icon: const Icon(Icons.verified_user_rounded),
|
icon: const Icon(Icons.verified_user_rounded),
|
||||||
label: Text(
|
label: Text(
|
||||||
AppLocalizations.of(context).verifyOtp,
|
AppLocalizations.of(context).verifyOtp,
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
style: const TextStyle(
|
||||||
|
fontSize: 18, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: theme.colorScheme.primary,
|
backgroundColor: theme.colorScheme.primary,
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(
|
||||||
const EdgeInsets.symmetric(vertical: 14, horizontal: 28),
|
vertical: 14,
|
||||||
|
horizontal: 28,
|
||||||
|
),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
),
|
),
|
||||||
@@ -147,7 +152,8 @@ class _TpinOtpScreenState extends State<TpinOtpScreen> {
|
|||||||
// Resend OTP logic here
|
// Resend OTP logic here
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(AppLocalizations.of(context).otpResent)),
|
content: Text(AppLocalizations.of(context).otpResent),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context).resendOtp),
|
child: Text(AppLocalizations.of(context).resendOtp),
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/features/fund_transfer/screens/tpin_otp_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/tpin_otp_screen.dart';
|
||||||
|
|
||||||
@@ -10,16 +9,17 @@ class TpinSetupPromptScreen extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(title: Text(AppLocalizations.of(context).setTpin)),
|
||||||
title: Text(AppLocalizations.of(context).setTpin),
|
|
||||||
),
|
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 100.0),
|
padding: const EdgeInsets.symmetric(vertical: 100.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.lock_person_rounded,
|
Icon(
|
||||||
size: 60, color: theme.colorScheme.primary),
|
Icons.lock_person_rounded,
|
||||||
|
size: 60,
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
const SizedBox(height: 18),
|
const SizedBox(height: 18),
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).tpinRequired,
|
AppLocalizations.of(context).tpinRequired,
|
||||||
@@ -41,12 +41,15 @@ class TpinSetupPromptScreen extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.arrow_forward_rounded),
|
icon: const Icon(Icons.arrow_forward_rounded),
|
||||||
label: Text(
|
label: Text(
|
||||||
AppLocalizations.of(context).setTpin,
|
AppLocalizations.of(context).setTpin,
|
||||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
style:
|
||||||
|
const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: theme.colorScheme.primary,
|
backgroundColor: theme.colorScheme.primary,
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(
|
||||||
const EdgeInsets.symmetric(vertical: 14, horizontal: 32),
|
vertical: 14,
|
||||||
|
horizontal: 32,
|
||||||
|
),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
@@ -54,9 +57,7 @@ class TpinSetupPromptScreen extends StatelessWidget {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(builder: (_) => const TpinOtpScreen()),
|
||||||
builder: (_) => const TpinOtpScreen(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/api/services/auth_service.dart';
|
import 'package:kmobile/api/services/auth_service.dart';
|
||||||
@@ -55,6 +55,7 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
await authService.setTpin(pin);
|
await authService.setTpin(pin);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
// ignore: unnecessary_string_interpolations
|
||||||
_errorText = "${AppLocalizations.of(context).tpinFailed}";
|
_errorText = "${AppLocalizations.of(context).tpinFailed}";
|
||||||
_tpin.clear();
|
_tpin.clear();
|
||||||
});
|
});
|
||||||
@@ -66,14 +67,17 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
shape:
|
shape: RoundedRectangleBorder(
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
|
borderRadius: BorderRadius.circular(18),
|
||||||
|
),
|
||||||
title: Column(
|
title: Column(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.check_circle, color: Colors.green, size: 60),
|
const Icon(Icons.check_circle, color: Colors.green, size: 60),
|
||||||
SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text(AppLocalizations.of(context).success,
|
Text(
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
AppLocalizations.of(context).success,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
content: Text(
|
content: Text(
|
||||||
@@ -85,8 +89,10 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(ctx).pop();
|
Navigator.of(ctx).pop();
|
||||||
},
|
},
|
||||||
child: Text(AppLocalizations.of(context).ok,
|
child: Text(
|
||||||
style: TextStyle(fontSize: 16)),
|
AppLocalizations.of(context).ok,
|
||||||
|
style: const TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -125,7 +131,7 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
['1', '2', '3'],
|
['1', '2', '3'],
|
||||||
['4', '5', '6'],
|
['4', '5', '6'],
|
||||||
['7', '8', '9'],
|
['7', '8', '9'],
|
||||||
['Enter', '0', '<']
|
['Enter', '0', '<'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
@@ -144,8 +150,9 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
_handleComplete();
|
_handleComplete();
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_errorText =
|
_errorText = AppLocalizations.of(
|
||||||
AppLocalizations.of(context).pleaseEnter6Digits;
|
context,
|
||||||
|
).pleaseEnter6Digits;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (key.isNotEmpty) {
|
} else if (key.isNotEmpty) {
|
||||||
@@ -166,7 +173,9 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
key == '<' ? '⌫' : key,
|
key == '<' ? '⌫' : key,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: key == 'Enter' ? Colors.blue : Colors.black,
|
color: key == 'Enter'
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -195,7 +204,8 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
const Icon(Icons.lock_outline, size: 60, color: Colors.blue),
|
Icon(Icons.lock_outline,
|
||||||
|
size: 60, color: Theme.of(context).primaryColor),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Text(
|
Text(
|
||||||
getTitle(),
|
getTitle(),
|
||||||
@@ -206,8 +216,10 @@ class _TpinSetScreenState extends State<TpinSetScreen> {
|
|||||||
if (_errorText != null)
|
if (_errorText != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(_errorText!,
|
child: Text(
|
||||||
style: const TextStyle(color: Colors.red)),
|
_errorText!,
|
||||||
|
style: const TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
buildNumberPad(),
|
buildNumberPad(),
|
||||||
|
|||||||
@@ -1,26 +1,24 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/api/services/auth_service.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/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:kmobile/features/fund_transfer/screens/tpin_prompt_screen.dart';
|
||||||
import 'package:kmobile/features/fund_transfer/screens/transaction_success_screen.dart';
|
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
|
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class TransactionPinScreen extends StatefulWidget {
|
class TransactionPinScreen extends StatefulWidget {
|
||||||
final Transfer transactionData;
|
final Future<void> Function(BuildContext, String) onPinCompleted;
|
||||||
const TransactionPinScreen({super.key, required this.transactionData});
|
|
||||||
|
const TransactionPinScreen({super.key, required this.onPinCompleted});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<TransactionPinScreen> createState() => _TransactionPinScreen();
|
State<TransactionPinScreen> createState() => _TransactionPinScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TransactionPinScreen extends State<TransactionPinScreen> {
|
class _TransactionPinScreenState extends State<TransactionPinScreen> {
|
||||||
final List<String> _pin = [];
|
final List<String> _pin = [];
|
||||||
bool _loading = true;
|
bool _loading = true;
|
||||||
|
bool _isSubmitting = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -36,9 +34,7 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
if (!isSet && mounted) {
|
if (!isSet && mounted) {
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(builder: (_) => const TpinSetupPromptScreen()),
|
||||||
builder: (_) => const TpinSetupPromptScreen(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else if (mounted) {
|
} else if (mounted) {
|
||||||
setState(() => _loading = false);
|
setState(() => _loading = false);
|
||||||
@@ -48,13 +44,15 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
setState(() => _loading = false);
|
setState(() => _loading = false);
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(AppLocalizations.of(context).tpinStatusFailed)),
|
content: Text(AppLocalizations.of(context).tpinStatusFailed),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onKeyPressed(String value) {
|
void _onKeyPressed(String value) {
|
||||||
|
if (_isSubmitting) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
if (value == 'back') {
|
if (value == 'back') {
|
||||||
if (_pin.isNotEmpty) _pin.removeLast();
|
if (_pin.isNotEmpty) _pin.removeLast();
|
||||||
@@ -64,6 +62,27 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
Widget _buildPinIndicators() {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@@ -74,8 +93,10 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
height: 20,
|
height: 20,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
border: Border.all(color: Colors.blue, width: 2),
|
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
|
||||||
color: index < _pin.length ? Colors.blue : Colors.transparent,
|
color: index < _pin.length
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: Colors.transparent,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@@ -85,30 +106,15 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
Widget _buildKey(String label, {IconData? icon}) {
|
Widget _buildKey(String label, {IconData? icon}) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () => label == 'done' ? _submitPin() : _onKeyPressed(label),
|
||||||
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)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_onKeyPressed(label);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: icon != null
|
child: _isSubmitting && label == 'done'
|
||||||
? Icon(icon, size: 28)
|
? const CircularProgressIndicator()
|
||||||
: Text(label, style: const TextStyle(fontSize: 24)),
|
: icon != null
|
||||||
|
? Icon(icon, size: 28)
|
||||||
|
: Text(label, style: const TextStyle(fontSize: 24)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -122,37 +128,17 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
Row(children: [_buildKey('1'), _buildKey('2'), _buildKey('3')]),
|
Row(children: [_buildKey('1'), _buildKey('2'), _buildKey('3')]),
|
||||||
Row(children: [_buildKey('4'), _buildKey('5'), _buildKey('6')]),
|
Row(children: [_buildKey('4'), _buildKey('5'), _buildKey('6')]),
|
||||||
Row(children: [_buildKey('7'), _buildKey('8'), _buildKey('9')]),
|
Row(children: [_buildKey('7'), _buildKey('8'), _buildKey('9')]),
|
||||||
Row(children: [
|
Row(
|
||||||
_buildKey('done', icon: Icons.check),
|
children: [
|
||||||
_buildKey('0'),
|
_buildKey('done', icon: Icons.check),
|
||||||
_buildKey('back', icon: Icons.backspace_outlined),
|
_buildKey('0'),
|
||||||
]),
|
_buildKey('back', icon: Icons.backspace_outlined),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -165,26 +151,29 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).tpin,
|
AppLocalizations.of(context).tpin,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: _loading
|
||||||
padding: const EdgeInsets.only(bottom: 20.0),
|
? const Center(child: CircularProgressIndicator())
|
||||||
child: Column(
|
: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.only(bottom: 20.0),
|
||||||
const Spacer(),
|
child: Column(
|
||||||
Text(
|
children: [
|
||||||
AppLocalizations.of(context).enterTpin,
|
const Spacer(),
|
||||||
style: TextStyle(fontSize: 18),
|
Text(
|
||||||
|
AppLocalizations.of(context).enterTpin,
|
||||||
|
style: const TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildPinIndicators(),
|
||||||
|
const Spacer(),
|
||||||
|
_buildKeypad(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
|
||||||
_buildPinIndicators(),
|
|
||||||
const Spacer(),
|
|
||||||
_buildKeypad(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
@@ -35,8 +35,9 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final String transactionDate =
|
final String transactionDate = DateTime.now().toLocal().toString().split(
|
||||||
DateTime.now().toLocal().toString().split(' ')[0];
|
' ',
|
||||||
|
)[0];
|
||||||
final String creditAccount = widget.creditAccount;
|
final String creditAccount = widget.creditAccount;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -49,40 +50,30 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const CircleAvatar(
|
CircleAvatar(
|
||||||
radius: 50,
|
radius: 50,
|
||||||
backgroundColor: Colors.blue,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
child: Icon(
|
child: Icon(Icons.check,
|
||||||
Icons.check,
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
color: Colors.white,
|
size: 60),
|
||||||
size: 60,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).transactionSuccess,
|
AppLocalizations.of(context).transactionSuccess,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18, fontWeight: FontWeight.w600),
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
Text(
|
Text(
|
||||||
"On $transactionDate",
|
"On $transactionDate",
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 14, color: Colors.black54),
|
||||||
fontSize: 14,
|
|
||||||
color: Colors.black54,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Text(
|
Text(
|
||||||
"${AppLocalizations.of(context).toAccountNumber}: $creditAccount",
|
"${AppLocalizations.of(context).toAccountNumber}: $creditAccount",
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontSize: 12, color: Colors.black87),
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -102,13 +93,14 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
|||||||
icon: const Icon(Icons.share, size: 18),
|
icon: const Icon(Icons.share, size: 18),
|
||||||
label: Text(AppLocalizations.of(context).share),
|
label: Text(AppLocalizations.of(context).share),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.white,
|
backgroundColor:
|
||||||
foregroundColor: Colors.blueAccent,
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
side:
|
foregroundColor: Theme.of(context).primaryColorLight,
|
||||||
const BorderSide(color: Colors.black, width: 1),
|
side: const BorderSide(color: Colors.black, width: 1),
|
||||||
elevation: 0),
|
elevation: 0,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
@@ -117,16 +109,18 @@ class _TransactionSuccessScreen extends State<TransactionSuccessScreen> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
// Done action
|
// Done action
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) => const NavigationScaffold(),
|
||||||
const NavigationScaffold()));
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Colors.blue[900],
|
backgroundColor: Theme.of(context).primaryColorDark,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).done),
|
child: Text(AppLocalizations.of(context).done),
|
||||||
),
|
),
|
||||||
|
|||||||
50
lib/features/profile/preferences/color_theme_dialog.dart
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:kmobile/config/theme_type.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
class ColorThemeDialog extends StatelessWidget {
|
||||||
|
const ColorThemeDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Text(AppLocalizations.of(context).selectThemeColor),
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
leading: const CircleAvatar(backgroundColor: Colors.deepPurple),
|
||||||
|
title: Text(AppLocalizations.of(context).violet),
|
||||||
|
onTap: () {
|
||||||
|
context.read<ThemeCubit>().changeTheme(ThemeType.violet);
|
||||||
|
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),
|
||||||
|
onTap: () {
|
||||||
|
context.read<ThemeCubit>().changeTheme(ThemeType.blue);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +1,40 @@
|
|||||||
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:kmobile/app.dart';
|
import 'package:kmobile/app.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class LanguageDialog extends StatelessWidget {
|
class LanguageDialog extends StatelessWidget {
|
||||||
const LanguageDialog({super.key});
|
// ignore: use_super_parameters
|
||||||
|
const LanguageDialog({Key? key}) : super(key: key);
|
||||||
|
|
||||||
String getLocaleName(AppLocalizations localizations, String code) {
|
Future<void> _setLocale(BuildContext context, String langCode) async {
|
||||||
final localeCodeMap = {
|
final prefs = await SharedPreferences.getInstance();
|
||||||
'en': localizations.english,
|
await prefs.setString('locale', langCode); // Save selected language
|
||||||
'hi': localizations.hindi,
|
KMobile.setLocale(context, Locale(langCode)); // Update locale in app
|
||||||
};
|
Navigator.of(context).pop(); // Close the dialog
|
||||||
return localeCodeMap[code] ?? 'Unknown';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Builder(
|
return AlertDialog(
|
||||||
builder: (context) {
|
title: Text(AppLocalizations.of(context).selectLanguage),
|
||||||
final localizations = AppLocalizations.of(context);
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
final supportedLocales = [
|
children: [
|
||||||
const Locale('en'),
|
ListTile(
|
||||||
const Locale('hi'),
|
leading: const Icon(Icons.language),
|
||||||
];
|
title: const Text('English'),
|
||||||
|
onTap: () => _setLocale(context, 'en'),
|
||||||
return AlertDialog(
|
|
||||||
title: Text(localizations.language),
|
|
||||||
content: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: supportedLocales.map((locale) {
|
|
||||||
return ListTile(
|
|
||||||
leading: const Icon(Icons.language),
|
|
||||||
title: Text(getLocaleName(localizations, locale.languageCode)),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
KMobile.setLocale(context, locale);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
),
|
||||||
actions: [
|
ListTile(
|
||||||
TextButton(
|
leading: const Icon(Icons.language),
|
||||||
onPressed: () => Navigator.pop(context),
|
title: const Text('हिन्दी'),
|
||||||
child: Text(localizations.cancel),
|
onTap: () => _setLocale(context, 'hi'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
),
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'language_dialog.dart';
|
import 'language_dialog.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'color_theme_dialog.dart';
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_state.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class PreferenceScreen extends StatelessWidget {
|
class PreferenceScreen extends StatelessWidget {
|
||||||
const PreferenceScreen({super.key});
|
const PreferenceScreen({super.key});
|
||||||
@@ -11,21 +15,50 @@ class PreferenceScreen extends StatelessWidget {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(loc.preferences), // Localized "Preferences"
|
title: Text(loc.preferences),
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: BlocBuilder<ThemeCubit, ThemeState>(
|
||||||
children: [
|
builder: (context, state) {
|
||||||
ListTile(
|
return ListView(
|
||||||
leading: const Icon(Icons.language),
|
children: [
|
||||||
title: Text(loc.language), // Localized "Language"
|
// Language Selection
|
||||||
onTap: () {
|
ListTile(
|
||||||
showDialog(
|
leading: const Icon(Icons.language),
|
||||||
context: context,
|
title: Text(loc.language),
|
||||||
builder: (context) => LanguageDialog(),
|
onTap: () {
|
||||||
);
|
showDialog(
|
||||||
},
|
context: context,
|
||||||
),
|
builder: (_) =>
|
||||||
],
|
const LanguageDialog(), // your custom language dialog
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
//Theme Mode Switch (Light/Dark)
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.brightness_6),
|
||||||
|
title: Text(AppLocalizations.of(context).themeMode),
|
||||||
|
enabled: false,
|
||||||
|
//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),
|
||||||
|
//enabled: false,
|
||||||
|
onTap: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => const ColorThemeDialog(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
import 'package:kmobile/features/profile/preferences/preference_screen.dart';
|
import 'package:kmobile/features/profile/preferences/preference_screen.dart';
|
||||||
|
|
||||||
class ProfileScreen extends StatelessWidget {
|
class ProfileScreen extends StatelessWidget {
|
||||||
@@ -22,8 +22,7 @@ class ProfileScreen extends StatelessWidget {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => const PreferenceScreen(),
|
builder: (context) => const PreferenceScreen()),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,9 +1,23 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
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/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
|
import '../../../../di/injection.dart';
|
||||||
|
import '../../../../api/services/beneficiary_service.dart';
|
||||||
|
|
||||||
class QuickPayOutsideBankScreen extends StatefulWidget {
|
class QuickPayOutsideBankScreen extends StatefulWidget {
|
||||||
final String debitAccount;
|
final String debitAccount;
|
||||||
@@ -26,21 +40,84 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
final ifscController = TextEditingController();
|
final ifscController = TextEditingController();
|
||||||
final phoneController = TextEditingController();
|
final phoneController = TextEditingController();
|
||||||
final amountController = TextEditingController();
|
final amountController = TextEditingController();
|
||||||
|
final service = getIt<BeneficiaryService>();
|
||||||
|
|
||||||
//String accountType = 'Savings';
|
|
||||||
late String accountType;
|
late String accountType;
|
||||||
|
bool _isValidating = false;
|
||||||
|
bool _isBeneficiaryValidated = false;
|
||||||
|
String? _validationError;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
setState(() {
|
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();
|
||||||
|
// ignore: prefer_const_declarations
|
||||||
|
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) {
|
List<String> transactionModes(BuildContext context) {
|
||||||
return [
|
return [
|
||||||
AppLocalizations.of(context).neft,
|
AppLocalizations.of(context).neft,
|
||||||
@@ -65,6 +142,235 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
super.dispose();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -77,7 +383,8 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).quickPayOutsideBank,
|
AppLocalizations.of(context).quickPayOutsideBank,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -103,28 +410,35 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Row(
|
Text(
|
||||||
children: [
|
AppLocalizations.of(context).debitFrom,
|
||||||
Text(AppLocalizations.of(context).debitFrom),
|
style: Theme.of(context).textTheme.titleSmall,
|
||||||
Text(
|
|
||||||
widget.debitAccount,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18, fontWeight: FontWeight.w500),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
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(
|
TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).accountNumber,
|
labelText: AppLocalizations.of(context).accountNumber,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -132,11 +446,17 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
|
onChanged: (value) {
|
||||||
|
nameController.clear();
|
||||||
|
setState(() {
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return AppLocalizations.of(context).accountNumberRequired;
|
return AppLocalizations.of(context).accountNumberRequired;
|
||||||
} else if (value.length != 11) {
|
} else if (value.length < 7 || value.length > 20) {
|
||||||
return AppLocalizations.of(context).validAccountNumber;
|
return AppLocalizations.of(context).accno7to20;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@@ -147,14 +467,14 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).confirmAccountNumber,
|
labelText: AppLocalizations.of(context).confirmAccountNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -171,130 +491,82 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
TextFormField(
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: AppLocalizations.of(context).name,
|
|
||||||
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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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: Colors.white,
|
|
||||||
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: Colors.white,
|
|
||||||
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(
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
decoration: InputDecoration(
|
maxLength: 11,
|
||||||
labelText: AppLocalizations.of(context).ifscCode,
|
inputFormatters: [
|
||||||
border: OutlineInputBorder(),
|
LengthLimitingTextInputFormatter(11),
|
||||||
isDense: true,
|
],
|
||||||
filled: true,
|
decoration: InputDecoration(
|
||||||
fillColor: Colors.white,
|
labelText: AppLocalizations.of(context).ifscCode,
|
||||||
enabledBorder: OutlineInputBorder(
|
border: const OutlineInputBorder(),
|
||||||
borderSide: BorderSide(color: Colors.black),
|
isDense: true,
|
||||||
),
|
filled: true,
|
||||||
focusedBorder: OutlineInputBorder(
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
enabledBorder: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black),
|
||||||
|
),
|
||||||
|
focusedBorder: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black, 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) {
|
||||||
|
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;
|
||||||
|
},
|
||||||
),
|
),
|
||||||
controller: ifscController,
|
),
|
||||||
textInputAction: TextInputAction.next,
|
const SizedBox(
|
||||||
validator: (value) {
|
width: 10,
|
||||||
if (value == null || value.isEmpty) {
|
),
|
||||||
return AppLocalizations.of(context).ifscRequired;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DropdownButtonFormField<String>(
|
child: DropdownButtonFormField<String>(
|
||||||
value: accountType,
|
value: accountType,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).accountType,
|
labelText: AppLocalizations.of(context).accountType,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
items: [
|
items: [
|
||||||
AppLocalizations.of(context).savings,
|
'Savings',
|
||||||
AppLocalizations.of(context).current
|
'Current',
|
||||||
]
|
]
|
||||||
.map((e) => DropdownMenuItem(
|
.map(
|
||||||
value: e,
|
(e) => DropdownMenuItem(value: e, child: Text(e)),
|
||||||
child: Text(e),
|
)
|
||||||
))
|
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (value) => setState(() {
|
onChanged: (value) => setState(() {
|
||||||
accountType = value!;
|
accountType = value!;
|
||||||
@@ -304,6 +576,111 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
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: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black),
|
||||||
|
),
|
||||||
|
focusedBorder: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
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: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black),
|
||||||
|
),
|
||||||
|
focusedBorder: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.black,
|
||||||
|
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: const TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black),
|
||||||
|
),
|
||||||
|
focusedBorder: const OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return AppLocalizations.of(context).nameRequired;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -312,15 +689,15 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
keyboardType: TextInputType.phone,
|
keyboardType: TextInputType.phone,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).phone,
|
labelText: AppLocalizations.of(context).phone,
|
||||||
prefixIcon: Icon(Icons.phone),
|
prefixIcon: const Icon(Icons.phone),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -335,14 +712,14 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).amount,
|
labelText: AppLocalizations.of(context).amount,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -366,50 +743,33 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(AppLocalizations.of(context).transactionMode,
|
Text(
|
||||||
style: TextStyle(fontWeight: FontWeight.w500)),
|
AppLocalizations.of(context).transactionMode,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Expanded(child: buildTransactionModeSelector()),
|
Expanded(child: buildTransactionModeSelector()),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 45),
|
const SizedBox(height: 45),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SwipeButton.expand(
|
child: SwipeButton.expand(
|
||||||
thumb: const Icon(
|
thumb: Icon(Icons.arrow_forward,
|
||||||
Icons.arrow_forward,
|
color: Theme.of(context).dialogBackgroundColor),
|
||||||
color: Colors.white,
|
activeThumbColor: Theme.of(context).primaryColor,
|
||||||
),
|
activeTrackColor:
|
||||||
activeThumbColor: Colors.blue[900],
|
Theme.of(context).colorScheme.secondary.withAlpha(100),
|
||||||
activeTrackColor: Colors.blue.shade100,
|
borderRadius: BorderRadius.circular(30),
|
||||||
borderRadius: BorderRadius.circular(30),
|
height: 56,
|
||||||
height: 56,
|
onSwipe: _onProceedToPay,
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).swipeToPay,
|
AppLocalizations.of(context).swipeToPay,
|
||||||
style:
|
style: const TextStyle(
|
||||||
TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
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',
|
|
||||||
// )));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -432,19 +792,21 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
|||||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 5),
|
padding: const EdgeInsets.symmetric(vertical: 5),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected ? Colors.blue[200] : Colors.white,
|
color: isSelected
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: Theme.of(context).scaffoldBackgroundColor,
|
||||||
borderRadius: BorderRadius.circular(5),
|
borderRadius: BorderRadius.circular(5),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: isSelected ? Colors.blue : Colors.grey,
|
color: isSelected
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: Theme.of(context).scaffoldBackgroundColor,
|
||||||
width: isSelected ? 0 : 1.2,
|
width: isSelected ? 0 : 1.2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
transactionModes(context)[index],
|
transactionModes(context)[index],
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.black),
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
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_outside_bank_screen.dart';
|
||||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_within_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';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class QuickPayScreen extends StatefulWidget {
|
class QuickPayScreen extends StatefulWidget {
|
||||||
final String debitAccount;
|
final String debitAccount;
|
||||||
@@ -18,32 +17,9 @@ class _QuickPayScreen extends State<QuickPayScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).quickPay,
|
AppLocalizations.of(context).quickPay.replaceAll('\n', ''),
|
||||||
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(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
@@ -52,30 +28,31 @@ class _QuickPayScreen extends State<QuickPayScreen> {
|
|||||||
label: AppLocalizations.of(context).ownBank,
|
label: AppLocalizations.of(context).ownBank,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => QuickPayWithinBankScreen(
|
builder: (context) => QuickPayWithinBankScreen(
|
||||||
debitAccount: widget.debitAccount)));
|
debitAccount: widget.debitAccount,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
QuickPayManagementTile(
|
QuickPayManagementTile(
|
||||||
//disable: true,
|
|
||||||
icon: Symbols.output_circle,
|
icon: Symbols.output_circle,
|
||||||
label: AppLocalizations.of(context).outsideBank,
|
label: AppLocalizations.of(context).outsideBank,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => QuickPayOutsideBankScreen(
|
builder: (context) => QuickPayOutsideBankScreen(
|
||||||
debitAccount: widget.debitAccount)));
|
debitAccount: widget.debitAccount,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:flutter_swipe_button/flutter_swipe_button.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/data/models/transfer.dart';
|
||||||
|
import 'package:kmobile/di/injection.dart';
|
||||||
|
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import '../../fund_transfer/screens/transaction_pin_screen.dart';
|
import '../../fund_transfer/screens/transaction_pin_screen.dart';
|
||||||
|
|
||||||
class QuickPayWithinBankScreen extends StatefulWidget {
|
class QuickPayWithinBankScreen extends StatefulWidget {
|
||||||
@@ -23,6 +28,64 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
final TextEditingController amountController = TextEditingController();
|
final TextEditingController amountController = TextEditingController();
|
||||||
String? _selectedAccountType;
|
String? _selectedAccountType;
|
||||||
|
|
||||||
|
String? _beneficiaryName;
|
||||||
|
bool _isValidating = false;
|
||||||
|
bool _isBeneficiaryValidated = false;
|
||||||
|
String? _validationError;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
accountNumberController.addListener(_resetBeneficiaryValidation);
|
||||||
|
confirmAccountNumberController.addListener(_resetBeneficiaryValidation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _resetBeneficiaryValidation() {
|
||||||
|
if (_isBeneficiaryValidated ||
|
||||||
|
_beneficiaryName != null ||
|
||||||
|
_validationError != null) {
|
||||||
|
setState(() {
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
_beneficiaryName = null;
|
||||||
|
_validationError = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
accountNumberController.removeListener(_resetBeneficiaryValidation);
|
||||||
|
confirmAccountNumberController.removeListener(_resetBeneficiaryValidation);
|
||||||
|
accountNumberController.dispose();
|
||||||
|
confirmAccountNumberController.dispose();
|
||||||
|
amountController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _validateBeneficiary() async {
|
||||||
|
var beneficiaryService = getIt<BeneficiaryService>();
|
||||||
|
setState(() {
|
||||||
|
_isValidating = true;
|
||||||
|
_validationError = null;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
final name = await beneficiaryService
|
||||||
|
.validateBeneficiaryWithinBank(accountNumberController.text);
|
||||||
|
setState(() {
|
||||||
|
_beneficiaryName = name;
|
||||||
|
_isBeneficiaryValidated = true;
|
||||||
|
_isValidating = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_validationError = "Account Number not from KCCB";
|
||||||
|
_isValidating = false;
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
_beneficiaryName = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -35,7 +98,8 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).quickPayOwnBank,
|
AppLocalizations.of(context).quickPayOwnBank,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -64,10 +128,10 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
TextFormField(
|
TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).debitAccountNumber,
|
labelText: AppLocalizations.of(context).debitAccountNumber,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
controller: TextEditingController(text: widget.debitAccount),
|
controller: TextEditingController(text: widget.debitAccount),
|
||||||
@@ -79,14 +143,14 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
TextFormField(
|
TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).accountNumber,
|
labelText: AppLocalizations.of(context).accountNumber,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -103,29 +167,20 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
return null;
|
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),
|
const SizedBox(height: 25),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: confirmAccountNumberController,
|
controller: confirmAccountNumberController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).confirmAccountNumber,
|
labelText: AppLocalizations.of(context).confirmAccountNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -141,19 +196,75 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (!_isBeneficiaryValidated)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12.0),
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: _isValidating
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
|
if (accountNumberController.text.length == 11 &&
|
||||||
|
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 (_beneficiaryName != null && _isBeneficiaryValidated)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12.0),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.check_circle, color: Colors.green),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'${AppLocalizations.of(context).beneficiaryName}: $_beneficiaryName',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.green, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_validationError != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
|
child: Text(
|
||||||
|
_validationError!,
|
||||||
|
style: const TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText:
|
labelText: AppLocalizations.of(
|
||||||
AppLocalizations.of(context).beneficiaryAccountType,
|
context,
|
||||||
border: OutlineInputBorder(),
|
).beneficiaryAccountType,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -180,27 +291,18 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
return null;
|
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),
|
const SizedBox(height: 25),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).amount,
|
labelText: AppLocalizations.of(context).amount,
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -222,52 +324,59 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SwipeButton.expand(
|
child: SwipeButton.expand(
|
||||||
thumb: const Icon(
|
thumb: Icon(Icons.arrow_forward,
|
||||||
Icons.arrow_forward,
|
color: Theme.of(context).dialogBackgroundColor),
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
activeThumbColor: Theme.of(context).primaryColor,
|
activeThumbColor: Theme.of(context).primaryColor,
|
||||||
activeTrackColor:
|
activeTrackColor: Theme.of(
|
||||||
Theme.of(context).colorScheme.secondary.withAlpha(100),
|
context,
|
||||||
|
).colorScheme.secondary.withAlpha(100),
|
||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
height: 56,
|
height: 56,
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).swipeToPay,
|
AppLocalizations.of(context).swipeToPay,
|
||||||
style: TextStyle(fontSize: 16),
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
onSwipe: () {
|
onSwipe: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
|
if (!_isBeneficiaryValidated) {
|
||||||
|
setState(() {
|
||||||
|
_validationError = AppLocalizations.of(context)
|
||||||
|
.validateBeneficiaryproceeding;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Perform payment logic
|
// Perform payment logic
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => TransactionPinScreen(
|
builder: (context) => TransactionPinScreen(
|
||||||
transactionData: Transfer(
|
onPinCompleted: (pinScreenContext, tpin) async {
|
||||||
fromAccount: widget.debitAccount,
|
final transfer = Transfer(
|
||||||
toAccount: accountNumberController.text,
|
fromAccount: widget.debitAccount,
|
||||||
toAccountType: _selectedAccountType!,
|
toAccount: accountNumberController.text,
|
||||||
amount: amountController.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),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 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),
|
|
||||||
// )
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -290,7 +399,7 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
|||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.white,
|
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||||
enabledBorder: const OutlineInputBorder(
|
enabledBorder: const OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(color: Colors.black),
|
||||||
),
|
),
|
||||||
|
|||||||
163
lib/features/service/screens/branch_locator_screen.dart
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
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 5 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, 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: Center(
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// Icon(
|
||||||
|
// Icons.location_on,
|
||||||
|
// size: 80,
|
||||||
|
// color: Theme.of(context).primaryColor,
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 16),
|
||||||
|
// Text(
|
||||||
|
// AppLocalizations.of(context).findnearbybranched,
|
||||||
|
// style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 24),
|
||||||
|
// ElevatedButton.icon(
|
||||||
|
// icon: const Icon(Icons.search),
|
||||||
|
// label: Text( AppLocalizations.of(context).searchbranch),
|
||||||
|
// onPressed: () {
|
||||||
|
// // Place API here
|
||||||
|
|
||||||
|
// // ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
// // SnackBar(content: Text( AppLocalizations.of(context).branchsearchsoon)),
|
||||||
|
// // );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
@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).primaryColor),
|
||||||
|
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,4 +1,6 @@
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:kmobile/features/service/screens/branch_locator_screen.dart';
|
||||||
|
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
@@ -18,7 +20,8 @@ class _ServiceScreen extends State<ServiceScreen> {
|
|||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
title: Text(
|
title: Text(
|
||||||
AppLocalizations.of(context).services,
|
AppLocalizations.of(context).services,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
style:
|
||||||
|
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -38,7 +41,8 @@ class _ServiceScreen extends State<ServiceScreen> {
|
|||||||
},
|
},
|
||||||
child: const CircleAvatar(
|
child: const CircleAvatar(
|
||||||
backgroundImage: AssetImage(
|
backgroundImage: AssetImage(
|
||||||
'assets/images/avatar.jpg'), // Replace with your image
|
'assets/images/avatar.jpg',
|
||||||
|
), // Replace with your image
|
||||||
radius: 20,
|
radius: 20,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -52,33 +56,30 @@ class _ServiceScreen extends State<ServiceScreen> {
|
|||||||
label: AppLocalizations.of(context).accountOpeningDeposit,
|
label: AppLocalizations.of(context).accountOpeningDeposit,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ServiceManagementTile(
|
ServiceManagementTile(
|
||||||
icon: Symbols.add,
|
icon: Symbols.add,
|
||||||
label: AppLocalizations.of(context).accountOpeningLoan,
|
label: AppLocalizations.of(context).accountOpeningLoan,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ServiceManagementTile(
|
ServiceManagementTile(
|
||||||
icon: Symbols.captive_portal,
|
icon: Symbols.captive_portal,
|
||||||
label: AppLocalizations.of(context).quickLinks,
|
label: AppLocalizations.of(context).quickLinks,
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
ServiceManagementTile(
|
ServiceManagementTile(
|
||||||
icon: Symbols.missing_controller,
|
icon: Symbols.missing_controller,
|
||||||
label: AppLocalizations.of(context).branchLocator,
|
label: AppLocalizations.of(context).branchLocator,
|
||||||
onTap: () {},
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const BranchLocatorScreen()));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(height: 1),
|
||||||
height: 1,
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Transaction {
|
|||||||
final double amount;
|
final double amount;
|
||||||
final DateTime date;
|
final DateTime date;
|
||||||
final String category;
|
final String category;
|
||||||
|
|
||||||
Transaction({
|
Transaction({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.description,
|
required this.description,
|
||||||
@@ -12,4 +12,4 @@ class Transaction {
|
|||||||
required this.date,
|
required this.date,
|
||||||
required this.category,
|
required this.category,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@
|
|||||||
"hi": "Hi",
|
"hi": "Hi",
|
||||||
"kMobile": "kMobile",
|
"kMobile": "kMobile",
|
||||||
"scanBiometric": "Scan to enable Biometric login",
|
"scanBiometric": "Scan to enable Biometric login",
|
||||||
"savingsAccount": "Savings Account",
|
"savingsAccount": "Savings",
|
||||||
"loanAccount": "Loan Account",
|
"loanAccount": "Loan",
|
||||||
"termDeposit": "Term Deposit Account",
|
"termDeposit": "Term Deposit",
|
||||||
"recurringDeposit": "Recurring Deposit Account",
|
"recurringDeposit": "Recurring Deposit",
|
||||||
"unknownAccount": "Unknown Account Type",
|
"unknownAccount": "Unknown Account Type",
|
||||||
"customerInfo": "Customer \n Info",
|
"customerInfo": "Customer \n Info",
|
||||||
"fundTransfer": "Fund \n Transfer",
|
"fundTransfer": "Fund \n Transfer",
|
||||||
@@ -219,6 +219,76 @@
|
|||||||
"setMPIN": "Set your mPIN",
|
"setMPIN": "Set your mPIN",
|
||||||
"confirmMPIN": "Confirm your mPIN",
|
"confirmMPIN": "Confirm your mPIN",
|
||||||
"kconnect": "Kconnect",
|
"kconnect": "Kconnect",
|
||||||
"kccBankFull": "Kangra Central Co-operative Bank"
|
"kccBankFull": "Kangra Central Co-operative Bank",
|
||||||
|
"themeColor": "Theme Color",
|
||||||
|
"selectThemeColor": "Select Theme Color",
|
||||||
|
"violet": "Violet",
|
||||||
|
"blue": "Blue",
|
||||||
|
"invalidIfsc": "Invalid IFSC code",
|
||||||
|
"validIfsc": "Valid IFSC",
|
||||||
|
"beneficiaryAddedSuccess": "Beneficiary Added Successfully",
|
||||||
|
"beneficiaryAdditionFailed": "Beneficiary Addition Failed",
|
||||||
|
"noBeneficiaryFound": "No beneficiaries found",
|
||||||
|
"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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,6 +218,77 @@
|
|||||||
"enterMPIN": "अपना mPIN दर्ज करें",
|
"enterMPIN": "अपना mPIN दर्ज करें",
|
||||||
"setMPIN": "अपना mPIN सेट करें",
|
"setMPIN": "अपना mPIN सेट करें",
|
||||||
"confirmMPIN": "अपना mPIN की पुष्टि करें",
|
"confirmMPIN": "अपना mPIN की पुष्टि करें",
|
||||||
"kconnect": "केकनेक्ट",
|
"kconnect": "के-कनेक्ट",
|
||||||
"kccBankFull": "कांगड़ा सेंट्रल को-ऑपरेटिव बैंक"
|
"kccBankFull": "कांगड़ा सेंट्रल को-ऑपरेटिव बैंक",
|
||||||
|
"themeColor": "थीम रंग",
|
||||||
|
"selectThemeColor": "थीम रंग चुनें",
|
||||||
|
"violet": "बैंगनी",
|
||||||
|
"blue": "नीला",
|
||||||
|
"invalidIfsc": "अमान्य IFSC कोड",
|
||||||
|
"validIfsc": "मान्य IFSC",
|
||||||
|
"beneficiaryAddedSuccess": "लाभार्थी सफलतापूर्वक जोड़ा गया",
|
||||||
|
"beneficiaryAdditionFailed": "लाभार्थी जोड़ने में विफल",
|
||||||
|
"noBeneficiaryFound": "कोई लाभार्थी नहीं मिला",
|
||||||
|
"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": "कार्ड विवरण देखें"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';
|
||||||
|
import 'package:kmobile/rooted_screen.dart';
|
||||||
import 'di/injection.dart';
|
import 'di/injection.dart';
|
||||||
import 'app.dart';
|
import 'app.dart';
|
||||||
|
|
||||||
@@ -15,5 +17,16 @@ void main() async {
|
|||||||
// Initialize dependencies
|
// Initialize dependencies
|
||||||
await setupDependencies();
|
await setupDependencies();
|
||||||
|
|
||||||
|
final isJailBroken = await JailbreakRootDetection.instance.isJailBroken;
|
||||||
|
final isRealDevice = await JailbreakRootDetection.instance.isRealDevice;
|
||||||
|
if(isJailBroken || !isRealDevice){
|
||||||
|
runApp(const MaterialApp(
|
||||||
|
home: RootedScreen(),
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
runApp(const KMobile());
|
runApp(const KMobile());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
lib/rooted_screen.dart
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class RootedScreen extends StatelessWidget {
|
||||||
|
const RootedScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
body: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.warning_amber_rounded,
|
||||||
|
color: Colors.red,
|
||||||
|
size: 80,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text(
|
||||||
|
"Rooted Device Detected",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
const Text(
|
||||||
|
"For security reasons, this app cannot run on rooted devices.",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white70,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// Optionally close the app
|
||||||
|
},
|
||||||
|
child: const Text("Exit"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,32 +3,30 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|||||||
|
|
||||||
class SecureStorage {
|
class SecureStorage {
|
||||||
final FlutterSecureStorage _storage;
|
final FlutterSecureStorage _storage;
|
||||||
|
|
||||||
SecureStorage(): _storage = const FlutterSecureStorage();
|
SecureStorage() : _storage = const FlutterSecureStorage();
|
||||||
|
|
||||||
Future<void> write(String key, dynamic value) async {
|
Future<void> write(String key, dynamic value) async {
|
||||||
final stringValue = value is String
|
final stringValue = value is String ? value : json.encode(value);
|
||||||
? value
|
|
||||||
: json.encode(value);
|
|
||||||
await _storage.write(key: key, value: stringValue);
|
await _storage.write(key: key, value: stringValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> read(String key) async {
|
Future<dynamic> read(String key) async {
|
||||||
final value = await _storage.read(key: key);
|
final value = await _storage.read(key: key);
|
||||||
if (value == null) return null;
|
if (value == null) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return json.decode(value);
|
return json.decode(value);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> delete(String key) async {
|
Future<void> delete(String key) async {
|
||||||
await _storage.delete(key: key);
|
await _storage.delete(key: key);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteAll() async {
|
Future<void> deleteAll() async {
|
||||||
await _storage.deleteAll();
|
await _storage.deleteAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
81
lib/widgets/bank_logos.dart
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
Widget getBankLogo(String? bankName) {
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('state bank of')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/sbi_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('kangra central')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('hdfc bank ltd')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/hdfc_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('icici bank ltd')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/icici_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null &&
|
||||||
|
bankName.toLowerCase().contains('punjab national bank')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/pnb_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('axis')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/axisBank_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('baroda')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/bankofBaroda_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('canara bank')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/canaraBank_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('kotak')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/kotak_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (bankName != null && bankName.toLowerCase().contains('bank of india')) {
|
||||||
|
return Image.asset(
|
||||||
|
'assets/images/boi_logo.png',
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const Icon(
|
||||||
|
Icons.account_balance,
|
||||||
|
size: 40,
|
||||||
|
color: Colors.grey,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
pubspec.lock
@@ -89,6 +89,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.18.0"
|
||||||
|
confetti:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: confetti
|
||||||
|
sha256: "979aafde2428c53947892c95eb244466c109c129b7eee9011f0a66caaca52267"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.0"
|
||||||
cross_file:
|
cross_file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -203,6 +211,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_neumorphic:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_neumorphic
|
||||||
|
sha256: "02606d937a3ceaa497b8a7c25f3efa95188bf93d77ebf0bd6552e432db4c2ec6"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.0"
|
||||||
flutter_plugin_android_lifecycle:
|
flutter_plugin_android_lifecycle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -289,10 +305,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: get_it
|
name: get_it
|
||||||
sha256: f126a3e286b7f5b578bf436d5592968706c4c1de28a228b870ce375d9f743103
|
sha256: e87cd1d108e472a0580348a543a0c49ed3d70c8a5c809c6d418583e595d0a389
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "8.0.3"
|
version: "8.1.0"
|
||||||
glob:
|
glob:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -341,6 +357,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.19.0"
|
version: "0.19.0"
|
||||||
|
jailbreak_root_detection:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: jailbreak_root_detection
|
||||||
|
sha256: c611229940a09785bd686364e92a40b07724926d2496c931527805101eb3da86
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.6"
|
||||||
js:
|
js:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -457,10 +481,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: material_symbols_icons
|
name: material_symbols_icons
|
||||||
sha256: "7c50901b39d1ad645ee25d920aed008061e1fd541a897b4ebf2c01d966dbf16b"
|
sha256: ef20d86fb34c2b59eb7553c4d795bb8a7ec8c890c53ffd3148c64f7adc46ae50
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2815.1"
|
version: "4.2858.1"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
18
pubspec.yaml
@@ -30,6 +30,7 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_neumorphic : 3.2.0
|
||||||
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
@@ -57,13 +58,16 @@ dependencies:
|
|||||||
shimmer: ^3.0.0
|
shimmer: ^3.0.0
|
||||||
lottie: ^2.6.0
|
lottie: ^2.6.0
|
||||||
share_plus: ^7.2.1
|
share_plus: ^7.2.1
|
||||||
|
confetti: ^0.7.0
|
||||||
|
jailbreak_root_detection: "^1.1.6"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
# The "flutter_lints" package below contains a set of recommended lints to
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
# encourage good coding practices. The lint set provided by the package is
|
||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
# activated in the `analysis_options.yaml` file located at the root of your
|
||||||
@@ -89,6 +93,12 @@ flutter:
|
|||||||
- assets/images/kccb_logo.svg
|
- assets/images/kccb_logo.svg
|
||||||
- assets/images/avatar.jpg
|
- assets/images/avatar.jpg
|
||||||
- assets/images/logo.png
|
- assets/images/logo.png
|
||||||
|
- assets/images/sbi_logo.png
|
||||||
|
- assets/images/axisbank_logo.png
|
||||||
|
- assets/images/BankofBaroda_logo.png
|
||||||
|
- assets/images/canaraBank_logo.png
|
||||||
|
- assets/images/kotak_logo.png
|
||||||
|
- assets/images/boi_logo.png
|
||||||
- assets/images/kmobile_splash.jpg
|
- assets/images/kmobile_splash.jpg
|
||||||
- assets/images/kmobile_splash2.png
|
- assets/images/kmobile_splash2.png
|
||||||
- assets/images/icon.svg
|
- assets/images/icon.svg
|
||||||
@@ -96,9 +106,13 @@ flutter:
|
|||||||
- assets/images/avatar_male.svg
|
- assets/images/avatar_male.svg
|
||||||
- assets/images/avatar_female.svg
|
- assets/images/avatar_female.svg
|
||||||
- assets/images/kconnect2.webp
|
- assets/images/kconnect2.webp
|
||||||
|
- assets/images/icici_logo.png
|
||||||
|
- assets/images/hdfc_logo.png
|
||||||
|
- assets/images/pnb_logo.png
|
||||||
- assets/animations/rupee.json
|
- assets/animations/rupee.json
|
||||||
- assets/animations/error.json
|
- assets/animations/error.json
|
||||||
- assets/animations/done.json
|
- assets/animations/done.json
|
||||||
|
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||||
@@ -125,4 +139,4 @@ flutter:
|
|||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: true
|
android: true
|
||||||
ios: false
|
ios: false
|
||||||
image_path: assets/images/icon.png
|
image_path: assets/images/icon.png
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
|||||||