Compare commits
162 Commits
language-t
...
security
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a314ee2bd | |||
| 2743f92283 | |||
| 72a9d5711a | |||
| 1edb2804f1 | |||
| c9c52b39fa | |||
| 7a0265ad8d | |||
| 58e53d0aeb | |||
| 06ef2ab36b | |||
| 0362bf2013 | |||
| 73b96b82f7 | |||
| c78a90dbfe | |||
| df025babd5 | |||
| 4d19bf6146 | |||
| d36cad31c1 | |||
| 39e7a02ca5 | |||
| 0c7470d74b | |||
| 32463680e8 | |||
| 00cb98ae83 | |||
| 18844495c2 | |||
| 3f7869677c | |||
| 0e4072fe8f | |||
| b5acae85d5 | |||
| cc7c7a8042 | |||
| 475f30a4bb | |||
| b00bc6c8c0 | |||
| c47862bd60 | |||
| 8ef4f1327f | |||
| 87e00d540f | |||
| 44a6307995 | |||
| f6b24e4c6f | |||
| 9cf4c44bb0 | |||
| b3b51d423d | |||
| b1f4d380c6 | |||
| 17ebf8626a | |||
| e466dff424 | |||
| 8f2b981b5b | |||
| ba1ef0ed24 | |||
| d2044d49b5 | |||
| db39cfbcc9 | |||
| bf23627e0a | |||
| eba38c2e42 | |||
|
|
d4bba6dc49 | ||
| b56bf0d7df | |||
| 82e057d804 | |||
| 0f205873a9 | |||
| 191610c9b2 | |||
| b03e917d78 | |||
|
|
188fbe9bb1 | ||
|
|
817f3d75f5 | ||
|
|
c42b973bee | ||
|
|
def009003c | ||
| 52e9f59e6f | |||
| e4e104837b | |||
| dd7b7a6f4c | |||
| c322d1d2fd | |||
| b3fb387bdd | |||
|
|
b62b8a157d | ||
| c729b775c9 | |||
| 465065db57 | |||
| 0a6dde9ead | |||
| b513664a47 | |||
| d8d87e8da4 | |||
| 1204507375 | |||
| be9a6fc93f | |||
| b8337d1152 | |||
| d3792a1a06 | |||
| 845ce1fe78 | |||
| 45dbf8464a | |||
|
|
a1ea60841e | ||
|
|
2abc315af9 | ||
|
|
a44ac67842 | ||
|
|
1b684af3a8 | ||
|
|
aa5a7877e4 | ||
|
|
d6a99ea295 | ||
|
|
cf8964ca36 | ||
|
|
c489bf3895 | ||
|
|
ba819f51d7 | ||
|
|
48f169d10c | ||
|
|
64e80148a3 | ||
|
|
85f58c1e25 | ||
|
|
3b9b1e507c | ||
| 57439f2acb | |||
| 52534f9210 | |||
| d9f78629d2 | |||
| 3e3465d5e8 | |||
| be76465774 | |||
| de596aa138 | |||
| 720c6ec03a | |||
| d081a5433c | |||
| 90f4a6bb81 | |||
|
|
f71c8d646b | ||
|
|
6a8f091ac5 | ||
|
|
596f0a96eb | ||
|
|
768d312066 | ||
|
|
4277ca9169 | ||
|
|
53caa5b7ae | ||
|
|
bfa0721e79 | ||
|
|
75bcce8201 | ||
|
|
99f4b1b735 | ||
|
|
6ebc96d153 | ||
|
|
6496aa95c0 | ||
|
|
e91efafa0e | ||
|
|
61a6e356d9 | ||
|
|
a48781ad1b | ||
|
|
d425af184e | ||
|
|
bc2c460f96 | ||
|
|
ef3556f207 | ||
|
|
6724d8bed0 | ||
|
|
83ed973b44 | ||
|
|
f7dd31fb93 | ||
|
|
9c60dc1c1c | ||
|
|
c369ad415d | ||
|
|
f934f0bff6 | ||
|
|
da0287ef38 | ||
|
|
f65507a706 | ||
| 9f6b35d3eb | |||
| a33b4bc1e1 | |||
| 0d629226a8 | |||
| 6d502a0c81 | |||
| 96d1e37c42 | |||
| b0610ad84d | |||
| ceb29ee7fe | |||
| 57cb93c124 | |||
| 0ac9a1f319 | |||
| d3ad68b25c | |||
|
|
eb0e1c120e | ||
| a64e68d642 | |||
| 80faa06272 | |||
| 0bab68a2e6 | |||
|
|
351ee84414 | ||
|
|
f77549310a | ||
| 4b28a113d4 | |||
| bf35ec61d5 | |||
| 180d3a3a60 | |||
|
|
737ce6cce6 | ||
|
|
e75f48aed5 | ||
|
|
5ee88403dd | ||
|
|
7fe8e8f084 | ||
|
|
59eb509dda | ||
|
|
5f41c6e7f4 | ||
|
|
36474786c1 | ||
|
|
df51c4f30b | ||
|
|
cf8588b336 | ||
| 04c992c934 | |||
| fc76528206 | |||
| 7527db3d2f | |||
| 19d3487552 | |||
|
|
60a5703c35 | ||
| 09618db28e | |||
| 712553e49f | |||
| 842eef2cc7 | |||
|
|
e6ea764785 | ||
| e2a809d363 | |||
| f48bfabb4a | |||
| 76d5874e19 | |||
| 913e31a6ab | |||
| 7f5258b5b7 | |||
|
|
82951b7919 | ||
| 8ae26e2f18 | |||
| e7bbab13ba | |||
| 72862492c0 | |||
|
|
f91d0f739b |
3
.gitignore
vendored
@@ -41,3 +41,6 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/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,10 @@
|
|||||||
|
|
||||||
# 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
|
||||||
|
non_constant_identifier_names: 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
|
||||||
@@ -45,7 +45,7 @@ android {
|
|||||||
applicationId "com.example.kmobile"
|
applicationId "com.example.kmobile"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||||
minSdkVersion flutter.minSdkVersion
|
minSdkVersion 29
|
||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdkVersion flutter.targetSdkVersion
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
@@ -56,6 +56,10 @@ android {
|
|||||||
// 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
|
signingConfig signingConfigs.debug
|
||||||
|
minifyEnabled true
|
||||||
|
shrinkResources true
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
android/app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
-keep class io.flutter.app.** { *; }
|
||||||
|
-keep class io.flutter.plugin.** { *; }
|
||||||
|
-keep class io.flutter.util.** { *; }
|
||||||
|
-keep class io.flutter.view.** { *; }
|
||||||
|
-keep class io.flutter.embedding.** { *; }
|
||||||
|
-keep class io.flutter.embedding.engine.plugins.** { *; }
|
||||||
|
-keep class com.google.firebase.** { *; }
|
||||||
|
-keep class com.google.android.gms.** { *; }
|
||||||
|
# Please add these rules to your existing keep rules in order to suppress warnings.
|
||||||
|
# This is generated automatically by the Android Gradle plugin.
|
||||||
|
-dontwarn com.google.android.play.core.splitcompat.SplitCompatApplication
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallException
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManager
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallManagerFactory
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest$Builder
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallRequest
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallSessionState
|
||||||
|
-dontwarn com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener
|
||||||
|
-dontwarn com.google.android.play.core.tasks.OnFailureListener
|
||||||
|
-dontwarn com.google.android.play.core.tasks.OnSuccessListener
|
||||||
|
-dontwarn com.google.android.play.core.tasks.Task
|
||||||
@@ -2,10 +2,13 @@
|
|||||||
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
|
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
|
||||||
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
|
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.SEND_SMS"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||||
<application
|
<application
|
||||||
android:label="kmobile"
|
android:label="kmobile"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
|
android:allowBackup="false"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package com.example.kmobile
|
package com.example.kmobile
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterFragmentActivity
|
import io.flutter.embedding.android.FlutterFragmentActivity
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
import android.view.WindowManager.LayoutParams
|
||||||
|
import android.os.Bundle
|
||||||
|
|
||||||
class MainActivity: FlutterFragmentActivity()
|
class MainActivity: FlutterFragmentActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
window.addFlags(LayoutParams.FLAG_SECURE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
663
android/build/reports/problems/problems-report.html
Normal file
BIN
assets/images/BankofBaroda_logo.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/images/axisbank_logo.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
assets/images/boi_logo.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
assets/images/canaraBank_logo.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
assets/images/hdfc_logo.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
assets/images/icici_logo.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
assets/images/ipos_logo.png
Normal file
|
After Width: | Height: | Size: 5.8 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 |
BIN
assets/images/uco_logo.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/yes_bank_logo.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
@@ -427,7 +427,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@@ -484,7 +484,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 237 KiB |
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 1006 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 14 KiB |
@@ -47,5 +47,19 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>NSFaceIDUsageDescription</key>
|
<key>NSFaceIDUsageDescription</key>
|
||||||
<string>We use Face ID to secure your data.</string>
|
<string>We use Face ID to secure your data.</string>
|
||||||
|
<key>LSApplicationQueriesSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>https</string>
|
||||||
|
<string>http</string>
|
||||||
|
</array>
|
||||||
|
<key>NSCameraUsageDescription</key>
|
||||||
|
<string>This app needs camera access to scan QR codes and take pictures.</string>
|
||||||
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
|
<string>This app needs photo library access to save and share images.</string>
|
||||||
|
<key>NSContactsUsageDescription</key>
|
||||||
|
<string>This app needs contacts access to easily send money to your contacts.</string>
|
||||||
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
|
<string>This app needs microphone access for voice commands.</string>
|
||||||
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// 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';
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -26,11 +25,13 @@ class AuthService {
|
|||||||
print(e.toString());
|
print(e.toString());
|
||||||
}
|
}
|
||||||
if (e.response?.statusCode == 401) {
|
if (e.response?.statusCode == 401) {
|
||||||
throw AuthException('Invalid credentials');
|
throw AuthException(
|
||||||
|
e.response?.data['error'] ?? 'SOMETHING WENT WRONG');
|
||||||
}
|
}
|
||||||
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 +41,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 +55,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 +67,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 +78,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 +88,57 @@ 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()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
Future<void> sendOtpForSettingPassword(String customerNo) async {
|
||||||
|
try {
|
||||||
|
final response =
|
||||||
|
await _dio.get('/api/otp/send/set-password', queryParameters: {
|
||||||
|
'customerNo': customerNo,
|
||||||
|
});
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception(response.data['error'] ?? 'Failed to send OTP');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} on DioException catch (e) {
|
||||||
|
throw Exception('Network error: ${e.message}');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Unexpected error: ${e.toString()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> verifyOtpForSettingPassword(
|
||||||
|
String customerNo, String otp) async {
|
||||||
|
try {
|
||||||
|
final response = await _dio.get(
|
||||||
|
'/api/otp/verify/set-password',
|
||||||
|
queryParameters: {'customerNo': customerNo, 'otp': otp},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return response.data['token'];
|
||||||
|
} else {
|
||||||
|
throw Exception(response.data['error'] ?? 'Failed to verify OTP');
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
throw Exception('Network error: ${e.message}');
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Unexpected error: ${e.toString()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future changePassword(String newPassword, String token) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/auth/login_password',
|
||||||
|
data: {'login_password': newPassword},
|
||||||
|
options: Options(headers: {'Authorization': 'Bearer $token'}),
|
||||||
|
);
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception('Error setting password');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import 'dart:developer';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:kmobile/core/errors/exceptions.dart';
|
||||||
import 'package:kmobile/data/models/ifsc.dart';
|
import 'package:kmobile/data/models/ifsc.dart';
|
||||||
import 'package:kmobile/data/models/beneficiary.dart';
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
|
|
||||||
@@ -9,14 +11,16 @@ class BeneficiaryService {
|
|||||||
|
|
||||||
Future<String> validateBeneficiaryWithinBank(String accountNumber) async {
|
Future<String> validateBeneficiaryWithinBank(String accountNumber) async {
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get('/api/beneficiary/validate/within-bank', queryParameters: {
|
final response = await _dio
|
||||||
|
.get('/api/beneficiary/validate/within-bank', queryParameters: {
|
||||||
'accountNumber': accountNumber,
|
'accountNumber': accountNumber,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return response.data['name'];
|
return response.data['name'];
|
||||||
} else {
|
} else {
|
||||||
throw Exception(response.data['error'] ?? 'Failed to validate beneficiary');
|
throw Exception(
|
||||||
|
response.data['error'] ?? 'Failed to validate beneficiary');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
throw Exception('Network error: ${e.message}');
|
throw Exception('Network error: ${e.message}');
|
||||||
@@ -24,156 +28,102 @@ class BeneficiaryService {
|
|||||||
throw Exception('Unexpected error: ${e.toString()}');
|
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) {
|
Future<Ifsc> validateIFSC(String ifscCode) async {
|
||||||
return ifsc.fromJson(response.data);
|
try {
|
||||||
|
final response = await _dio.get('/api/beneficiary/ifsc-details',
|
||||||
|
queryParameters: {"ifscCode": ifscCode});
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return Ifsc.fromJson(response.data);
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
if (e.response?.statusCode == 404) {
|
||||||
|
throw Exception('INVALID IFSC CODE');
|
||||||
|
} else if (e.response?.statusCode == 401) {
|
||||||
|
throw Exception('INVALID IFSC CODE');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw UnexpectedException(
|
||||||
|
'Unexpected error during login: ${e.toString()}');
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
return Ifsc.fromJson({});
|
||||||
if (e.response?.statusCode == 404) {
|
|
||||||
print('Invalid IFSC code.');
|
|
||||||
} else {
|
|
||||||
print('API error: ${e.message}');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print('Unexpected error: $e');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
Future<String> validateBeneficiary({
|
||||||
///Step 1: Validate beneficiary (returns refNo)
|
|
||||||
Future<String?> validateBeneficiary({
|
|
||||||
required String accountNo,
|
required String accountNo,
|
||||||
required String ifscCode,
|
required String ifscCode,
|
||||||
required String remitterName,
|
required String remitterName,
|
||||||
}) async {
|
}) async {
|
||||||
|
log('inside validate beneficiary service');
|
||||||
try {
|
final response = await _dio.get(
|
||||||
final response = await _dio.post(
|
'/api/beneficiary/validate/outside-bank',
|
||||||
'/api/beneficiary/validate/outside_bank',
|
queryParameters: {
|
||||||
queryParameters: {
|
'accountNo': accountNo,
|
||||||
'accountNo': accountNo,
|
'ifscCode': ifscCode,
|
||||||
'ifscCode': ifscCode,
|
'remitterName': remitterName,
|
||||||
'remitterName': remitterName,
|
},
|
||||||
},
|
options: Options(
|
||||||
);
|
sendTimeout: const Duration(seconds: 60),
|
||||||
|
receiveTimeout: const Duration(seconds: 60),
|
||||||
if (response.statusCode == 200) {
|
),
|
||||||
return response.data['refNo'];
|
);
|
||||||
} else {
|
if (response.statusCode != 200) {
|
||||||
return null;
|
throw Exception("Invalid Beneficiary Details");
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("Error validating beneficiary: $e");
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return response.data['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Step 2: Check validation status (returns Beneficiary name if success)
|
// Beneficiary Validate And ADD
|
||||||
Future<String?> checkValidationStatus(String refNo) async {
|
Future<bool> sendForValidation(Beneficiary beneficiary) async {
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get(
|
|
||||||
'/api/beneficiary/check',
|
|
||||||
queryParameters: {
|
|
||||||
'refNo': refNo,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200 && response.data != null) {
|
|
||||||
return Beneficiary.fromJson(response.data).name;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("Error checking validation status: $e");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send Data for Validation
|
|
||||||
Future<void> sendForValidation(Beneficiary beneficiary) async {
|
|
||||||
try {
|
|
||||||
print(beneficiary.toJson());
|
|
||||||
final response = await _dio.post(
|
final response = await _dio.post(
|
||||||
'/api/beneficiary/add',
|
'/api/beneficiary',
|
||||||
data: beneficiary.toJson(),
|
data: beneficiary.toJson(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print("SENT FOR VALIDATION");
|
return true;
|
||||||
} else {
|
} else {
|
||||||
print("VALIDATION REQUEST FAILED: ${response.statusCode}");
|
return false;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("ERROR IN SENDING REQUEST: $e");
|
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll to check if beneficiary is found
|
Future<List<Beneficiary>> fetchBeneficiaryList() async {
|
||||||
Future<bool> checkIfFound(String accountNo) async {
|
|
||||||
const int timeoutInSeconds = 30;
|
|
||||||
const int intervalInSeconds = 2;
|
|
||||||
const int maxTries = timeoutInSeconds ~/ intervalInSeconds;
|
|
||||||
|
|
||||||
int attempts = 0;
|
|
||||||
|
|
||||||
while (attempts < maxTries) {
|
|
||||||
try {
|
|
||||||
final response = await _dio.get(
|
|
||||||
'/api/beneficiary/check?',
|
|
||||||
queryParameters: {
|
|
||||||
'accountNo': accountNo
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
print("FOUND");
|
|
||||||
return true;
|
|
||||||
} else if (response.statusCode == 404) {
|
|
||||||
print("NOT FOUND");
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("ERROR DURING STATUS: $e");
|
|
||||||
}
|
|
||||||
attempts++;
|
|
||||||
}
|
|
||||||
|
|
||||||
print("Beneficiary not found within timeout.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Beneficiary>> fetchBeneficiaryList() async{
|
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get(
|
final response = await _dio.get(
|
||||||
"/api/beneficiary/get",
|
"/api/beneficiary",
|
||||||
options: Options(
|
options: Options(
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return Beneficiary.listFromJson(response.data);
|
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return Beneficiary.listFromJson(response.data);
|
||||||
} else {
|
} else {
|
||||||
throw Exception("Failed to fetch beneficiaries");
|
throw Exception("Failed to fetch beneficiaries");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error fetching beneficiaries: $e");
|
|
||||||
return [];
|
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()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
70
lib/api/services/change_password_service.dart
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
|
class ChangePasswordService {
|
||||||
|
final Dio _dio;
|
||||||
|
|
||||||
|
ChangePasswordService(this._dio);
|
||||||
|
|
||||||
|
Future getOtp({
|
||||||
|
required String mobileNumber,
|
||||||
|
}) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/otp/send',
|
||||||
|
data: {'mobileNumber': mobileNumber, 'type': "CHANGE_LPWORD"},
|
||||||
|
);
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception("Invalid Mobile Number/Type");
|
||||||
|
}
|
||||||
|
print(response.toString());
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future getOtpTpin({
|
||||||
|
required String mobileNumber,
|
||||||
|
}) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/otp/send',
|
||||||
|
data: {'mobileNumber': mobileNumber, 'type': "CHANGE_TPIN"},
|
||||||
|
);
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception("Invalid Mobile Number/Type");
|
||||||
|
}
|
||||||
|
print(response.toString());
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future validateOtp({
|
||||||
|
required String otp,
|
||||||
|
required String mobileNumber,
|
||||||
|
}) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/otp/verify?mobileNumber=$mobileNumber',
|
||||||
|
data: {
|
||||||
|
'otp': otp,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception("Wrong OTP");
|
||||||
|
}
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future validateChangePwd({
|
||||||
|
required String OldLPsw,
|
||||||
|
required String newLPsw,
|
||||||
|
required String confirmLPsw,
|
||||||
|
}) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/auth/change/login_password',
|
||||||
|
data: {
|
||||||
|
'OldLPsw': OldLPsw,
|
||||||
|
'newLPsw': newLPsw,
|
||||||
|
'confirmLPsw': confirmLPsw,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode != 200) {
|
||||||
|
throw Exception("Wrong OTP");
|
||||||
|
}
|
||||||
|
return response.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,7 +10,7 @@ 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
|
||||||
|
|
||||||
await _dio.post('/api/payment/transfer', data: transfer.toJson());
|
await _dio.post('/api/payment/transfer', data: transfer.toJson());
|
||||||
|
|
||||||
return PaymentResponse(
|
return PaymentResponse(
|
||||||
|
|||||||
31
lib/api/services/rtgs_service.dart
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:kmobile/data/models/rtgs_response.dart';
|
||||||
|
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||||
|
|
||||||
|
class RtgsService {
|
||||||
|
final Dio _dio;
|
||||||
|
|
||||||
|
RtgsService(this._dio);
|
||||||
|
|
||||||
|
Future<RtgsResponse> processRtgsTransaction(
|
||||||
|
RtgsTransaction transaction) async {
|
||||||
|
try {
|
||||||
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/payment/rtgs',
|
||||||
|
data: transaction.toJson(),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return RtgsResponse.fromJson(response.data);
|
||||||
|
} else {
|
||||||
|
throw Exception(
|
||||||
|
'RTGS transaction failed with status code: ${response.statusCode}');
|
||||||
|
}
|
||||||
|
} on DioException {
|
||||||
|
rethrow;
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('An unexpected error occurred: ${e.toString()}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
129
lib/api/services/send_sms_service.dart
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
// // ignore_for_file: avoid_print
|
||||||
|
// import 'dart:io';
|
||||||
|
// import 'package:flutter/material.dart';
|
||||||
|
// import 'send_sms.dart';
|
||||||
|
// import 'package:simcards/sim_card.dart';
|
||||||
|
// import 'package:simcards/simcards.dart';
|
||||||
|
|
||||||
|
// import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
|
// class SmsService {
|
||||||
|
// final Simcards _simcards = Simcards();
|
||||||
|
|
||||||
|
// Future<void> sendVerificationSms({
|
||||||
|
// required BuildContext context,
|
||||||
|
// required String destinationNumber,
|
||||||
|
// required String message,
|
||||||
|
// }) async {
|
||||||
|
// try {
|
||||||
|
// await _simcards.requestPermission();
|
||||||
|
|
||||||
|
// bool permissionGranted = await _simcards.hasPermission();
|
||||||
|
// if (!permissionGranted) {
|
||||||
|
// print("Permission denied." );
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// List<SimCard> simCardList = await _simcards.getSimCards();
|
||||||
|
// if (simCardList.isEmpty) {
|
||||||
|
// print("No SIM detected." );
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// await _sendSms(destinationNumber, message, simCardList.first);
|
||||||
|
|
||||||
|
// } catch (e) {
|
||||||
|
// print("Error in SMS process: $e");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// Future<void> _sendSms(
|
||||||
|
// String destinationNumber, String message, SimCard selectedSim) async {
|
||||||
|
// if (Platform.isAndroid) {
|
||||||
|
// try {
|
||||||
|
// var uuid = const Uuid();
|
||||||
|
// String uniqueId = uuid.v4();
|
||||||
|
|
||||||
|
// String smsMessage = uniqueId;
|
||||||
|
// String result = await sendSMS(
|
||||||
|
// message: smsMessage,
|
||||||
|
// recipients: [destinationNumber],
|
||||||
|
// sendDirect: true,
|
||||||
|
// );
|
||||||
|
// print("SMS send result: $result. Sent via ${selectedSim.displayName} (Note: OS default SIM isused).");
|
||||||
|
|
||||||
|
// } catch (e) {
|
||||||
|
// print("Error sending SMS: $e");
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// print("SMS sending is only supported on Android.");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ignore_for_file: avoid_print
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_sms/flutter_sms.dart'; // <-- 1. IMPORT the new package
|
||||||
|
import 'package:simcards/sim_card.dart';
|
||||||
|
import 'package:simcards/simcards.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
|
class SmsService {
|
||||||
|
final Simcards _simcards = Simcards();
|
||||||
|
|
||||||
|
Future<void> sendVerificationSms({
|
||||||
|
required BuildContext context,
|
||||||
|
required String destinationNumber,
|
||||||
|
required String message,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
await _simcards.requestPermission();
|
||||||
|
|
||||||
|
bool permissionGranted = await _simcards.hasPermission();
|
||||||
|
if (!permissionGranted) {
|
||||||
|
print("Permission denied.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SimCard> simCardList = await _simcards.getSimCards();
|
||||||
|
if (simCardList.isEmpty) {
|
||||||
|
print("No SIM detected.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await _sendSms(destinationNumber, message, simCardList.first);
|
||||||
|
} catch (e) {
|
||||||
|
print("Error in SMS process: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _sendSms(
|
||||||
|
String destinationNumber, String message, SimCard selectedSim) async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
try {
|
||||||
|
var uuid = const Uuid();
|
||||||
|
String uniqueId = uuid.v4();
|
||||||
|
|
||||||
|
String smsMessage = uniqueId;
|
||||||
|
|
||||||
|
// v-- 2. UPDATE the function call below --v
|
||||||
|
String result = await sendSMS(
|
||||||
|
message: smsMessage,
|
||||||
|
recipients: [destinationNumber],
|
||||||
|
);
|
||||||
|
// ^-- The 'sendDirect' parameter is not available in this package. --^
|
||||||
|
// It will open the user's default messaging app with the fields pre-filled.
|
||||||
|
|
||||||
|
print(
|
||||||
|
"SMS send result: $result. Sent via ${selectedSim.displayName} (Note: OS default SIM isused)."
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
print("Error sending SMS: $e");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("SMS sending is only supported on Android.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,4 +28,4 @@ class UserService {
|
|||||||
throw Exception('Unexpected error: ${e.toString()}');
|
throw Exception('Unexpected error: ${e.toString()}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
246
lib/app.dart
@@ -2,6 +2,8 @@ import 'dart:io';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_mode_state.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import './l10n/app_localizations.dart';
|
import './l10n/app_localizations.dart';
|
||||||
@@ -11,13 +13,14 @@ 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 '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';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
class KMobile extends StatefulWidget {
|
class KMobile extends StatefulWidget {
|
||||||
const KMobile({super.key});
|
const KMobile({super.key});
|
||||||
@@ -26,38 +29,64 @@ class KMobile extends StatefulWidget {
|
|||||||
State<KMobile> createState() => _KMobileState();
|
State<KMobile> createState() => _KMobileState();
|
||||||
|
|
||||||
static void setLocale(BuildContext context, Locale newLocale) {
|
static void setLocale(BuildContext context, Locale newLocale) {
|
||||||
final _KMobileState? state = context.findAncestorStateOfType<_KMobileState>();
|
final _KMobileState? state =
|
||||||
|
context.findAncestorStateOfType<_KMobileState>();
|
||||||
state?.setLocale(newLocale);
|
state?.setLocale(newLocale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _KMobileState extends State<KMobile> {
|
class _KMobileState extends State<KMobile> with WidgetsBindingObserver {
|
||||||
|
Timer? _backgroundTimer;
|
||||||
bool showSplash = true;
|
bool showSplash = true;
|
||||||
Locale? _locale;
|
Locale? _locale;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addObserver(this);
|
||||||
loadPreferences();
|
loadPreferences();
|
||||||
Future.delayed(const Duration(seconds: 2), () {
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
showSplash = false;
|
showSplash = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
|
_backgroundTimer?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
super.didChangeAppLifecycleState(state);
|
||||||
|
switch (state) {
|
||||||
|
case AppLifecycleState.resumed:
|
||||||
|
_backgroundTimer?.cancel();
|
||||||
|
break;
|
||||||
|
case AppLifecycleState.paused:
|
||||||
|
_backgroundTimer = Timer(const Duration(minutes: 2), () {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
SystemNavigator.pop();
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> loadPreferences() async {
|
Future<void> loadPreferences() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
// Load Locale
|
|
||||||
final String? langCode = prefs.getString('locale');
|
final String? langCode = prefs.getString('locale');
|
||||||
if (langCode != null) {
|
if (langCode != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_locale = Locale(langCode);
|
_locale = Locale(langCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLocale(Locale locale) {
|
void setLocale(Locale locale) {
|
||||||
@@ -66,57 +95,56 @@ class _KMobileState extends State<KMobile> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Set status bar color and brightness
|
SystemChrome.setSystemUIOverlayStyle(
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
const SystemUiOverlayStyle(
|
||||||
const SystemUiOverlayStyle(
|
statusBarColor: Colors.transparent,
|
||||||
statusBarColor: Colors.transparent,
|
statusBarIconBrightness: Brightness.dark,
|
||||||
statusBarIconBrightness: Brightness.dark,
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
BlocProvider<AuthCubit>(create: (_) => getIt<AuthCubit>()),
|
||||||
BlocProvider<ThemeCubit>(create: (_) => getIt<ThemeCubit>()),
|
BlocProvider<ThemeCubit>(create: (_) => ThemeCubit()),
|
||||||
],
|
BlocProvider<ThemeModeCubit>(create: (_) => ThemeModeCubit()),
|
||||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
],
|
||||||
builder: (context, themeState) {
|
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||||
print('global theme state changed');
|
builder: (context, themeState) {
|
||||||
print(themeState);
|
return BlocBuilder<ThemeModeCubit, ThemeModeState>(
|
||||||
return MaterialApp(
|
builder: (context, modeState) {
|
||||||
debugShowCheckedModeBanner: false,
|
return MaterialApp(
|
||||||
locale: _locale ?? const Locale('en'),
|
debugShowCheckedModeBanner: false,
|
||||||
supportedLocales: const [
|
locale: _locale ?? const Locale('en'),
|
||||||
Locale('en'),
|
supportedLocales: const [
|
||||||
Locale('hi'),
|
Locale('en'),
|
||||||
],
|
Locale('hi'),
|
||||||
localizationsDelegates: const [
|
],
|
||||||
AppLocalizations.delegate,
|
localizationsDelegates: const [
|
||||||
GlobalMaterialLocalizations.delegate,
|
AppLocalizations.delegate,
|
||||||
GlobalWidgetsLocalizations.delegate,
|
GlobalMaterialLocalizations.delegate,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
GlobalWidgetsLocalizations.delegate,
|
||||||
],
|
GlobalCupertinoLocalizations.delegate,
|
||||||
title: 'kMobile',
|
],
|
||||||
//theme: AppThemes.getLightTheme(themeState.themeType),
|
title: 'kMobile',
|
||||||
theme: themeState.getThemeData(),
|
theme: themeState.getLightThemeData(),
|
||||||
// darkTheme: AppThemes.getDarkTheme(themeState.themeType),
|
darkTheme: themeState.getDarkThemeData(),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: context.watch<ThemeModeCubit>().state.mode,
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
onGenerateRoute: AppRoutes.generateRoute,
|
||||||
initialRoute: AppRoutes.splash,
|
initialRoute: AppRoutes.splash,
|
||||||
home: showSplash ? const SplashScreen() : const AuthGate(),
|
home: showSplash ? const SplashScreen() : const AuthGate(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
class AuthGate extends StatefulWidget {
|
class AuthGate extends StatefulWidget {
|
||||||
const AuthGate({super.key});
|
const AuthGate({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AuthGate> createState() => _AuthGateState();
|
State<AuthGate> createState() => _AuthGateState();
|
||||||
}
|
}
|
||||||
@@ -124,7 +152,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;
|
||||||
@@ -142,8 +169,7 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
final mpin = await storage.read('mpin');
|
final mpin = await storage.read('mpin');
|
||||||
final biometric = await storage.read('biometric_enabled');
|
final biometric = await storage.read('biometric_enabled');
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoggedIn =
|
_isLoggedIn = accessToken != null &&
|
||||||
accessToken != null &&
|
|
||||||
accessTokenExpiry != null &&
|
accessTokenExpiry != null &&
|
||||||
DateTime.parse(accessTokenExpiry).isAfter(DateTime.now());
|
DateTime.parse(accessTokenExpiry).isAfter(DateTime.now());
|
||||||
_hasMPin = mpin != null;
|
_hasMPin = mpin != null;
|
||||||
@@ -158,9 +184,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,
|
||||||
@@ -172,24 +202,11 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_checking) {
|
if (_checking) {
|
||||||
return const SplashScreen();
|
return const SplashScreen();
|
||||||
}
|
}
|
||||||
// ✅ Step 1: Show welcome screen first, only once
|
|
||||||
if (_showWelcome) {
|
|
||||||
return WelcomeScreen(
|
|
||||||
onContinue: () {
|
|
||||||
setState(() {
|
|
||||||
_showWelcome = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ✅ Step 2: Check login status
|
|
||||||
if (_isLoggedIn) {
|
if (_isLoggedIn) {
|
||||||
if (_hasMPin) {
|
if (_hasMPin) {
|
||||||
if (_biometricEnabled) {
|
if (_biometricEnabled) {
|
||||||
@@ -199,12 +216,9 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return const SplashScreen();
|
return const SplashScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snapshot.data == true) {
|
if (snapshot.data == true) {
|
||||||
return const NavigationScaffold(); // Authenticated
|
return const NavigationScaffold();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ❌ Biometric failed → Show MPIN screen
|
|
||||||
return MPinScreen(
|
return MPinScreen(
|
||||||
mode: MPinMode.enter,
|
mode: MPinMode.enter,
|
||||||
onCompleted: (_) {
|
onCompleted: (_) {
|
||||||
@@ -230,13 +244,11 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No MPIN set → show MPIN set screen + biometric dialog
|
|
||||||
return MPinScreen(
|
return MPinScreen(
|
||||||
mode: MPinMode.set,
|
mode: MPinMode.set,
|
||||||
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,
|
||||||
@@ -257,15 +269,16 @@ 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,
|
||||||
@@ -277,25 +290,23 @@ class _AuthGateState extends State<AuthGate> {
|
|||||||
await storage.write('biometric_enabled', 'false');
|
await storage.write('biometric_enabled', 'false');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (context.mounted) {
|
||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => const NavigationScaffold(),
|
builder: (_) => const NavigationScaffold(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Step 3: If not logged in, show login screen
|
|
||||||
return const LoginScreen();
|
return const LoginScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NavigationScaffold extends StatefulWidget {
|
class NavigationScaffold extends StatefulWidget {
|
||||||
const NavigationScaffold({super.key});
|
const NavigationScaffold({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<NavigationScaffold> createState() => _NavigationScaffoldState();
|
State<NavigationScaffold> createState() => _NavigationScaffoldState();
|
||||||
}
|
}
|
||||||
@@ -303,20 +314,12 @@ class NavigationScaffold extends StatefulWidget {
|
|||||||
class _NavigationScaffoldState extends State<NavigationScaffold> {
|
class _NavigationScaffoldState extends State<NavigationScaffold> {
|
||||||
final PageController _pageController = PageController();
|
final PageController _pageController = PageController();
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
const DashboardScreen(),
|
const DashboardScreen(),
|
||||||
const CardManagementScreen(),
|
const CardManagementScreen(),
|
||||||
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(
|
||||||
@@ -357,10 +360,15 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
|||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
currentIndex: _selectedIndex,
|
currentIndex: _selectedIndex,
|
||||||
type: BottomNavigationBarType.fixed,
|
type: BottomNavigationBarType.fixed,
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor, // Light blue background
|
backgroundColor: const Color(0XFF1E58AD),
|
||||||
selectedItemColor: Theme.of(context).primaryColor,
|
selectedItemColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
unselectedItemColor: Colors.black54,
|
unselectedItemColor: Theme.of(context).colorScheme.onSecondary,
|
||||||
onTap: _onItemTapped,
|
onTap: (index) {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = index;
|
||||||
|
});
|
||||||
|
_pageController.jumpToPage(index);
|
||||||
|
},
|
||||||
items: [
|
items: [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: const Icon(Icons.home_filled),
|
icon: const Icon(Icons.home_filled),
|
||||||
@@ -381,34 +389,9 @@ class _NavigationScaffoldState extends State<NavigationScaffold> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SplashScreen extends StatelessWidget {
|
|
||||||
const SplashScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const CircularProgressIndicator(),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context).loading,
|
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this widget at the end of the file
|
|
||||||
class BiometricPromptScreen extends StatelessWidget {
|
class BiometricPromptScreen extends StatelessWidget {
|
||||||
final VoidCallback onCompleted;
|
final VoidCallback onCompleted;
|
||||||
const BiometricPromptScreen({super.key, required this.onCompleted});
|
const BiometricPromptScreen({super.key, required this.onCompleted});
|
||||||
|
|
||||||
Future<void> _handleBiometric(BuildContext context) async {
|
Future<void> _handleBiometric(BuildContext context) async {
|
||||||
final localAuth = LocalAuthentication();
|
final localAuth = LocalAuthentication();
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
final canCheck = await localAuth.canCheckBiometrics;
|
||||||
@@ -416,8 +399,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,
|
||||||
@@ -461,6 +448,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 {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
enum ThemeType {
|
enum ThemeType {
|
||||||
violet,
|
violet,
|
||||||
green,
|
green,
|
||||||
orange,
|
orange,
|
||||||
blue,
|
blue,
|
||||||
}
|
yellow,
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,32 +1,52 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'theme_type.dart';
|
import 'theme_type.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
class AppThemes {
|
class AppThemes {
|
||||||
static ThemeData getLightTheme(ThemeType type) {
|
static ThemeData getLightTheme(ThemeType type) {
|
||||||
switch (type) {
|
final Color seedColor = _getSeedColor(type);
|
||||||
case ThemeType.green:
|
final colorScheme = ColorScheme.fromSeed(
|
||||||
return ThemeData(primarySwatch: Colors.green);
|
seedColor: seedColor,
|
||||||
case ThemeType.orange:
|
brightness: Brightness.light,
|
||||||
return ThemeData(primarySwatch: Colors.orange);
|
);
|
||||||
case ThemeType.blue:
|
return ThemeData.from(
|
||||||
return ThemeData(primarySwatch: Colors.blue);
|
colorScheme: colorScheme,
|
||||||
case ThemeType.violet:
|
useMaterial3: true,
|
||||||
default:
|
textTheme: GoogleFonts.rubikTextTheme(),
|
||||||
return ThemeData(primarySwatch: Colors.deepPurple);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static ThemeData getDarkTheme(ThemeType type) {
|
static ThemeData getDarkTheme(ThemeType type) {
|
||||||
|
final Color seedColor = _getSeedColor(type);
|
||||||
|
log(seedColor.toString());
|
||||||
|
final colorScheme = ColorScheme.fromSeed(
|
||||||
|
seedColor: seedColor,
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
);
|
||||||
|
|
||||||
|
return ThemeData.from(
|
||||||
|
colorScheme: colorScheme,
|
||||||
|
useMaterial3: true,
|
||||||
|
textTheme: GoogleFonts.rubikTextTheme(
|
||||||
|
ThemeData(brightness: Brightness.dark).textTheme,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Color _getSeedColor(ThemeType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ThemeType.green:
|
case ThemeType.green:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.green);
|
return Colors.green;
|
||||||
case ThemeType.orange:
|
case ThemeType.orange:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.orange);
|
return Colors.orange;
|
||||||
case ThemeType.blue:
|
case ThemeType.blue:
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.blue);
|
return Colors.blue;
|
||||||
case ThemeType.violet:
|
case ThemeType.violet:
|
||||||
default:
|
return Colors.deepPurple;
|
||||||
return ThemeData.dark().copyWith(primaryColor: Colors.deepPurple);
|
case ThemeType.yellow:
|
||||||
|
return Colors.yellow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
15
lib/core/logger.dart
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:kmobile/core/toast.dart';
|
||||||
|
|
||||||
|
class Logger {
|
||||||
|
static void info(String message) {
|
||||||
|
showToast('INFO: $message');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void warning(String message) {
|
||||||
|
showToast('WARNING: $message');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void error(String message) {
|
||||||
|
showToast('ERROR: $message');
|
||||||
|
}
|
||||||
|
}
|
||||||
14
lib/core/toast.dart
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
|
void showToast(String message) {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: message,
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
timeInSecForIosWeb: 1,
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 16.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
// ignore_for_file: non_constant_identifier_names
|
|
||||||
|
|
||||||
class Beneficiary {
|
class Beneficiary {
|
||||||
final String accountNo;
|
final String accountNo;
|
||||||
final String accountType;
|
final String accountType;
|
||||||
@@ -9,6 +5,7 @@ class Beneficiary {
|
|||||||
final String ifscCode;
|
final String ifscCode;
|
||||||
final String? bankName;
|
final String? bankName;
|
||||||
final String? branchName;
|
final String? branchName;
|
||||||
|
final String? tpin;
|
||||||
|
|
||||||
Beneficiary({
|
Beneficiary({
|
||||||
required this.accountNo,
|
required this.accountNo,
|
||||||
@@ -17,31 +14,43 @@ class Beneficiary {
|
|||||||
required this.ifscCode,
|
required this.ifscCode,
|
||||||
this.bankName,
|
this.bankName,
|
||||||
this.branchName,
|
this.branchName,
|
||||||
|
this.tpin,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
factory Beneficiary.fromJson(Map<String, dynamic> json) {
|
||||||
return Beneficiary(
|
return Beneficiary(
|
||||||
accountNo: json['accountNo'] ?? '',
|
accountNo: json['account_no'] ?? json['accountNo'] ?? '',
|
||||||
accountType: json['accountType'] ?? '',
|
accountType: json['account_type'] ?? json['accountType'] ?? '',
|
||||||
name: json['name'] ?? '',
|
name: json['name'] ?? '',
|
||||||
ifscCode: json['ifscCode'] ?? '',
|
ifscCode: json['ifsc_code'] ?? json['ifscCode'] ?? '',
|
||||||
bankName: json['bankName'] ?? '',
|
bankName: json['bank_name'] ?? json['bankName'] ?? '',
|
||||||
branchName: json['branchName'] ?? '',
|
branchName: json['branch_name'] ?? json['branchName'] ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
final Map<String, dynamic> json = {
|
||||||
'accountNo': accountNo,
|
'accountNo': accountNo,
|
||||||
'accountType': accountType,
|
'accountType': accountType,
|
||||||
'name': name,
|
'name': name,
|
||||||
'ifscCode' : ifscCode,
|
'ifscCode': ifscCode,
|
||||||
};
|
};
|
||||||
|
if (bankName != null && bankName!.isNotEmpty) {
|
||||||
|
json['bankName'] = bankName;
|
||||||
|
}
|
||||||
|
if (branchName != null && branchName!.isNotEmpty) {
|
||||||
|
json['branchName'] = branchName;
|
||||||
|
}
|
||||||
|
if (tpin != null && tpin!.isNotEmpty) {
|
||||||
|
json['tpin'] = tpin;
|
||||||
|
}
|
||||||
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<Beneficiary> listFromJson(List<dynamic> jsonList) {
|
static List<Beneficiary> listFromJson(List<dynamic> jsonList) {
|
||||||
final beneficiaryList = jsonList.map((beneficiary) => Beneficiary.fromJson(beneficiary)).toList();
|
final beneficiaryList = jsonList
|
||||||
print(beneficiaryList);
|
.map((beneficiary) => Beneficiary.fromJson(beneficiary))
|
||||||
|
.toList();
|
||||||
return beneficiaryList;
|
return beneficiaryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,4 +58,4 @@ class Beneficiary {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)';
|
return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
class BeneficiaryRecieve {
|
|
||||||
final String accountNo;
|
|
||||||
final String accountType;
|
|
||||||
final String name;
|
|
||||||
final String ifscCode;
|
|
||||||
final String bankName;
|
|
||||||
final String branchName;
|
|
||||||
|
|
||||||
|
|
||||||
BeneficiaryRecieve({
|
|
||||||
required this.accountNo,
|
|
||||||
required this.accountType,
|
|
||||||
required this.name,
|
|
||||||
required this.ifscCode,
|
|
||||||
required this.bankName,
|
|
||||||
required this.branchName,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory BeneficiaryRecieve.fromJson(Map<String, dynamic> json) {
|
|
||||||
return BeneficiaryRecieve(
|
|
||||||
accountNo: json['account_no'] ?? '',
|
|
||||||
accountType: json['account_type'] ?? '',
|
|
||||||
name: json['name'] ?? '',
|
|
||||||
ifscCode: json['ifsc_code'] ?? '',
|
|
||||||
bankName: json['bank_name'] ?? '',
|
|
||||||
branchName: json['branch_name'] ?? '',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
|
||||||
return {
|
|
||||||
'account_no': accountNo,
|
|
||||||
'account_type': accountType,
|
|
||||||
'name': name,
|
|
||||||
'ifsc_code' : ifscCode,
|
|
||||||
'bank_name' : bankName,
|
|
||||||
'branch_name' : branchName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'ListBeneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name, bankName: $bankName, branchName: $branchName)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
class ifsc {
|
class Ifsc {
|
||||||
final String ifscCode;
|
final String ifscCode;
|
||||||
final String bankName;
|
final String bankName;
|
||||||
final String branchName;
|
final String branchName;
|
||||||
|
|
||||||
ifsc({
|
Ifsc({
|
||||||
required this.ifscCode,
|
required this.ifscCode,
|
||||||
required this.bankName,
|
required this.bankName,
|
||||||
required this.branchName,
|
required this.branchName,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory ifsc.fromJson(Map<String, dynamic> json) {
|
factory Ifsc.fromJson(Map<String, dynamic> json) {
|
||||||
return ifsc(
|
return Ifsc(
|
||||||
ifscCode: json['ifsc_code'] ?? '',
|
ifscCode: json['ifsc_code'] ?? '',
|
||||||
bankName: json['bank_name'] ?? '',
|
bankName: json['bank_name'] ?? '',
|
||||||
branchName: json['branch_name'] ?? '',
|
branchName: json['branch_name'] ?? '',
|
||||||
@@ -29,4 +29,4 @@ class ifsc {
|
|||||||
String toString() {
|
String toString() {
|
||||||
return 'IFSC(ifscCode: $ifscCode, bankName: $bankName, branchName: $branchName)';
|
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'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
lib/data/models/imps_transaction.dart
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
class ImpsTransaction {
|
||||||
|
final String fromAccount;
|
||||||
|
final String toAccount;
|
||||||
|
final String amount;
|
||||||
|
final String ifscCode;
|
||||||
|
final String? remitterName;
|
||||||
|
final String beneficiaryName;
|
||||||
|
final String tpin;
|
||||||
|
final String? remarks;
|
||||||
|
|
||||||
|
ImpsTransaction({
|
||||||
|
required this.fromAccount,
|
||||||
|
required this.toAccount,
|
||||||
|
required this.amount,
|
||||||
|
required this.ifscCode,
|
||||||
|
this.remitterName,
|
||||||
|
required this.beneficiaryName,
|
||||||
|
required this.tpin,
|
||||||
|
this.remarks,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'fromAccount': fromAccount,
|
||||||
|
'toAccount': toAccount,
|
||||||
|
'amount': amount,
|
||||||
|
'ifscCode': ifscCode,
|
||||||
|
'remitterName': remitterName,
|
||||||
|
'beneficiaryName': beneficiaryName,
|
||||||
|
'tpin': tpin,
|
||||||
|
'remarks': remarks,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
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'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
lib/data/models/neft_transaction.dart
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
class NeftTransaction {
|
||||||
|
final String fromAccount;
|
||||||
|
final String toAccount;
|
||||||
|
final String amount;
|
||||||
|
final String ifscCode;
|
||||||
|
final String remitterName;
|
||||||
|
final String beneficiaryName;
|
||||||
|
final String tpin;
|
||||||
|
final String? remarks;
|
||||||
|
|
||||||
|
NeftTransaction({
|
||||||
|
required this.fromAccount,
|
||||||
|
required this.toAccount,
|
||||||
|
required this.amount,
|
||||||
|
required this.ifscCode,
|
||||||
|
required this.remitterName,
|
||||||
|
required this.beneficiaryName,
|
||||||
|
required this.tpin,
|
||||||
|
this.remarks,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'fromAccount': fromAccount,
|
||||||
|
'toAccount': toAccount,
|
||||||
|
'amount': amount,
|
||||||
|
'ifscCode': ifscCode,
|
||||||
|
'remitterName': remitterName,
|
||||||
|
'beneficiaryName': beneficiaryName,
|
||||||
|
'tpin': tpin,
|
||||||
|
'remarks': remarks,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
34
lib/data/models/rtgs_transaction.dart
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
class RtgsTransaction {
|
||||||
|
final String fromAccount;
|
||||||
|
final String toAccount;
|
||||||
|
final String amount;
|
||||||
|
final String ifscCode;
|
||||||
|
final String remitterName;
|
||||||
|
final String beneficiaryName;
|
||||||
|
final String tpin;
|
||||||
|
final String? remarks;
|
||||||
|
|
||||||
|
RtgsTransaction({
|
||||||
|
required this.fromAccount,
|
||||||
|
required this.toAccount,
|
||||||
|
required this.amount,
|
||||||
|
required this.ifscCode,
|
||||||
|
required this.remitterName,
|
||||||
|
required this.beneficiaryName,
|
||||||
|
required this.tpin,
|
||||||
|
this.remarks,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'fromAccount': fromAccount,
|
||||||
|
'toAccount': toAccount,
|
||||||
|
'amount': amount,
|
||||||
|
'ifscCode': ifscCode,
|
||||||
|
'remitterName': remitterName,
|
||||||
|
'beneficiaryName': beneficiaryName,
|
||||||
|
'tpin': tpin,
|
||||||
|
'remarks': remarks,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,8 +4,18 @@ class Transaction {
|
|||||||
final String? date;
|
final String? date;
|
||||||
final String? amount;
|
final String? amount;
|
||||||
final String? type;
|
final String? type;
|
||||||
|
final String? balance;
|
||||||
|
final String? balanceType;
|
||||||
|
|
||||||
|
Transaction(
|
||||||
|
{this.id,
|
||||||
|
this.name,
|
||||||
|
this.date,
|
||||||
|
this.amount,
|
||||||
|
this.type,
|
||||||
|
this.balance,
|
||||||
|
this.balanceType});
|
||||||
|
|
||||||
Transaction({this.id, this.name, this.date, this.amount, this.type});
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'id': id,
|
'id': id,
|
||||||
@@ -13,16 +23,19 @@ class Transaction {
|
|||||||
'date': date,
|
'date': date,
|
||||||
'amount': amount,
|
'amount': amount,
|
||||||
'type': type,
|
'type': type,
|
||||||
|
'balance': balance,
|
||||||
|
'balanceType': balanceType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Transaction.fromJson(Map<String, dynamic> json) {
|
factory Transaction.fromJson(Map<String, dynamic> json) {
|
||||||
return Transaction(
|
return Transaction(
|
||||||
id: json['id'] as String?,
|
id: json['id'] as String?,
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
date: json['date'] as String?,
|
date: json['date'] as String?,
|
||||||
amount: json['amount'] as String?,
|
amount: json['amount'] as String?,
|
||||||
type: json['type'] as String?,
|
type: json['type'] as String?,
|
||||||
);
|
balance: json['balance'] as String?,
|
||||||
|
balanceType: json['balanceType'] as String?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class Transfer {
|
|||||||
final String toAccountType;
|
final String toAccountType;
|
||||||
final String amount;
|
final String amount;
|
||||||
String? tpin;
|
String? tpin;
|
||||||
|
String? remarks;
|
||||||
|
|
||||||
Transfer({
|
Transfer({
|
||||||
required this.fromAccount,
|
required this.fromAccount,
|
||||||
@@ -11,6 +12,7 @@ class Transfer {
|
|||||||
required this.toAccountType,
|
required this.toAccountType,
|
||||||
required this.amount,
|
required this.amount,
|
||||||
this.tpin,
|
this.tpin,
|
||||||
|
this.remarks,
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
@@ -20,6 +22,7 @@ class Transfer {
|
|||||||
'toAccountType': toAccountType,
|
'toAccountType': toAccountType,
|
||||||
'amount': amount,
|
'amount': amount,
|
||||||
'tpin': tpin,
|
'tpin': tpin,
|
||||||
|
'remarks': remarks,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +35,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 +45,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,41 @@ 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<void> clearAuthTokens() async {
|
||||||
|
await _secureStorage.deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
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 +65,4 @@ class AuthRepository {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
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 +12,21 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 +39,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,3 +1,6 @@
|
|||||||
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package: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/beneficiary_service.dart';
|
||||||
@@ -5,20 +8,21 @@ 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 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||||
|
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||||
import '../api/services/auth_service.dart';
|
import '../api/services/auth_service.dart';
|
||||||
import '../api/interceptors/auth_interceptor.dart';
|
import '../api/interceptors/auth_interceptor.dart';
|
||||||
|
import '../api/services/change_password_service.dart';
|
||||||
import '../data/repositories/auth_repository.dart';
|
import '../data/repositories/auth_repository.dart';
|
||||||
import '../features/auth/controllers/auth_cubit.dart';
|
import '../features/auth/controllers/auth_cubit.dart';
|
||||||
import '../security/secure_storage.dart';
|
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<ThemeController>(() => ThemeController());
|
||||||
//getIt.registerLazySingleton<ThemeModeController>(() => ThemeModeController());
|
//getIt.registerLazySingleton<ThemeModeController>(() => ThemeModeController());
|
||||||
getIt.registerSingleton<ThemeCubit>( ThemeCubit());
|
getIt.registerSingleton<ThemeCubit>(ThemeCubit());
|
||||||
|
getIt.registerSingleton<ThemeModeCubit>(ThemeModeCubit());
|
||||||
|
|
||||||
// Register Dio client
|
// Register Dio client
|
||||||
getIt.registerSingleton<Dio>(_createDioClient());
|
getIt.registerSingleton<Dio>(_createDioClient());
|
||||||
@@ -42,6 +46,12 @@ Future<void> setupDependencies() async {
|
|||||||
|
|
||||||
getIt.registerSingleton<PaymentService>(PaymentService(getIt<Dio>()));
|
getIt.registerSingleton<PaymentService>(PaymentService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<BeneficiaryService>(BeneficiaryService(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>()));
|
||||||
|
getIt.registerLazySingleton<ChangePasswordService>(
|
||||||
|
() => ChangePasswordService(getIt<Dio>()),
|
||||||
|
);
|
||||||
|
|
||||||
// Add auth interceptor after repository is available
|
// Add auth interceptor after repository is available
|
||||||
getIt<Dio>().interceptors.add(
|
getIt<Dio>().interceptors.add(
|
||||||
@@ -51,17 +61,17 @@ Future<void> setupDependencies() async {
|
|||||||
// Register controllers/cubits
|
// Register controllers/cubits
|
||||||
getIt.registerFactory<AuthCubit>(
|
getIt.registerFactory<AuthCubit>(
|
||||||
() => AuthCubit(getIt<AuthRepository>(), getIt<UserService>()));
|
() => AuthCubit(getIt<AuthRepository>(), getIt<UserService>()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dio _createDioClient() {
|
Dio _createDioClient() {
|
||||||
final dio = Dio(
|
final dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
baseUrl:
|
baseUrl:
|
||||||
//'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080',
|
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080', //test
|
||||||
'http://localhost:8081',
|
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
|
||||||
connectTimeout: const Duration(seconds: 5),
|
//'https://kccbmbnk.net',
|
||||||
receiveTimeout: const Duration(seconds: 3),
|
connectTimeout: const Duration(seconds: 60),
|
||||||
|
receiveTimeout: const Duration(seconds: 60),
|
||||||
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,7 +1,5 @@
|
|||||||
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 '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
class AccountInfoScreen extends StatefulWidget {
|
class AccountInfoScreen extends StatefulWidget {
|
||||||
@@ -32,35 +30,9 @@ class _AccountInfoScreen extends State<AccountInfoScreen> {
|
|||||||
int selectedIndex = widget.selectedIndex;
|
int selectedIndex = widget.selectedIndex;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
title: Text(AppLocalizations.of(context)
|
||||||
icon: const Icon(Symbols.arrow_back_ios_new),
|
.accountInfo
|
||||||
onPressed: () {
|
.replaceFirst(RegExp('\n'), '')),
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
AppLocalizations.of(context).accountInfo,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
centerTitle: false,
|
|
||||||
actions: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: CircleAvatar(
|
|
||||||
backgroundColor: Colors.grey[200],
|
|
||||||
radius: 20,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
'assets/images/avatar_male.svg',
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
@@ -70,7 +42,6 @@ class _AccountInfoScreen extends State<AccountInfoScreen> {
|
|||||||
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14),
|
style: const TextStyle(fontWeight: FontWeight.w500, fontSize: 14),
|
||||||
),
|
),
|
||||||
|
|
||||||
/// Dropdown to change account
|
|
||||||
DropdownButton<User>(
|
DropdownButton<User>(
|
||||||
value: selectedUser,
|
value: selectedUser,
|
||||||
onChanged: (User? newUser) {
|
onChanged: (User? newUser) {
|
||||||
@@ -88,12 +59,6 @@ class _AccountInfoScreen extends State<AccountInfoScreen> {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
|
|
||||||
/*InfoRow(
|
|
||||||
title: AppLocalizations.of(context).accountNumber,
|
|
||||||
value: users[selectedIndex].accountNo ?? 'N/A'),
|
|
||||||
// InfoRow(title: 'Nominee Customer No', value: user.nomineeCustomerNo),
|
|
||||||
// InfoRow(title: 'SMS Service', value: user.smsService),
|
|
||||||
// InfoRow(title: 'Missed Call Service', value: user.missedCallService),*/
|
|
||||||
InfoRow(
|
InfoRow(
|
||||||
title: AppLocalizations.of(context).customerNumber,
|
title: AppLocalizations.of(context).customerNumber,
|
||||||
value: selectedUser.cifNumber ?? 'N/A',
|
value: selectedUser.cifNumber ?? 'N/A',
|
||||||
@@ -136,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),
|
||||||
@@ -144,16 +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(fontSize: 16, color: Colors.black),
|
style: TextStyle(fontSize: 16, color: theme.colorScheme.onSurface),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,15 +1,29 @@
|
|||||||
|
import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.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: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 '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'transaction_details_screen.dart';
|
||||||
|
import 'package:pdf/widgets.dart' as pw;
|
||||||
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
class AccountStatementScreen extends StatefulWidget {
|
class AccountStatementScreen extends StatefulWidget {
|
||||||
final String accountNo;
|
final String accountNo;
|
||||||
const AccountStatementScreen({super.key, required this.accountNo});
|
final String balance;
|
||||||
|
final String accountType;
|
||||||
|
const AccountStatementScreen({
|
||||||
|
super.key,
|
||||||
|
required this.accountNo,
|
||||||
|
required this.balance,
|
||||||
|
required this.accountType,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AccountStatementScreen> createState() => _AccountStatementScreen();
|
State<AccountStatementScreen> createState() => _AccountStatementScreen();
|
||||||
@@ -22,6 +36,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
List<Transaction> _transactions = [];
|
List<Transaction> _transactions = [];
|
||||||
final _minAmountController = TextEditingController();
|
final _minAmountController = TextEditingController();
|
||||||
final _maxAmountController = TextEditingController();
|
final _maxAmountController = TextEditingController();
|
||||||
|
//Future<Map<String, dynamic>?>? accountStatementsFuture;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -36,7 +51,11 @@ 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;
|
||||||
@@ -109,30 +128,10 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
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).accountStatement,
|
AppLocalizations.of(context).accountStatement,
|
||||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
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(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(12.0),
|
||||||
@@ -144,7 +143,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"${AppLocalizations.of(context).accountNumber}: ",
|
"${AppLocalizations.of(context).accountNumber}: ",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 19,
|
fontSize: 17,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -152,6 +151,19 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
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(
|
Text(
|
||||||
AppLocalizations.of(context).filters,
|
AppLocalizations.of(context).filters,
|
||||||
style: const TextStyle(fontSize: 17),
|
style: const TextStyle(fontSize: 17),
|
||||||
@@ -181,56 +193,29 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
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:
|
||||||
labelText: AppLocalizations.of(context).minAmount,
|
Theme.of(context).colorScheme.primaryContainer,
|
||||||
border: const OutlineInputBorder(),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
isDense: true,
|
),
|
||||||
filled: true,
|
child: Text(
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
AppLocalizations.of(context).search,
|
||||||
),
|
style: TextStyle(
|
||||||
keyboardType: TextInputType.number,
|
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
textInputAction: TextInputAction.next,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
),
|
||||||
Expanded(
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _maxAmountController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: AppLocalizations.of(context).maxAmount,
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
isDense: true,
|
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
),
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
textInputAction: TextInputAction.done,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
SizedBox(
|
|
||||||
width: 70,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: _loadTransactions,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
|
||||||
),
|
|
||||||
child: Icon(
|
|
||||||
Symbols.arrow_forward,
|
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
size: 30,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 35),
|
const SizedBox(height: 15),
|
||||||
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(
|
||||||
@@ -238,7 +223,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Colors.grey[700],
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -252,7 +237,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
highlightColor: Colors.grey[100]!,
|
highlightColor: Colors.grey[100]!,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: 12,
|
radius: 12,
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Shimmer.fromColors(
|
title: Shimmer.fromColors(
|
||||||
@@ -278,12 +264,13 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
: _transactions.isEmpty
|
: _transactions.isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
AppLocalizations.of(context).noTransactions,
|
AppLocalizations.of(context).noTransactions,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16, color: Colors.grey[600]),
|
fontSize: 16,
|
||||||
),
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.separated(
|
||||||
itemCount: _transactions.length,
|
itemCount: _transactions.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final tx = _transactions[index];
|
final tx = _transactions[index];
|
||||||
@@ -292,40 +279,247 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
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,
|
? Colors.green
|
||||||
|
: Theme.of(context).colorScheme.error,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
tx.name != null
|
tx.date ?? '',
|
||||||
? (tx.name!.length > 18
|
style: const TextStyle(fontSize: 15),
|
||||||
? tx.name!.substring(0, 20)
|
|
||||||
: tx.name!)
|
|
||||||
: '',
|
|
||||||
style: const TextStyle(fontSize: 14),
|
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
tx.date ?? '',
|
tx.name != null
|
||||||
|
? (tx.name!.length > 22
|
||||||
|
? tx.name!.substring(0, 22)
|
||||||
|
: tx.name!)
|
||||||
|
: '',
|
||||||
style: const TextStyle(fontSize: 12),
|
style: const TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
trailing: Text(
|
trailing: Column(
|
||||||
"₹${tx.amount}",
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
style: const TextStyle(fontSize: 16),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"₹${tx.amount}",
|
||||||
|
style: const TextStyle(fontSize: 17),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"Bal: ₹${tx.balance}",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12), // Style matches tx.name
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => TransactionDetailsScreen(
|
||||||
|
transaction: tx),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return const Divider();
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
_exportToPdf();
|
||||||
|
},
|
||||||
|
child: const Icon(Icons.download),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _exportToPdf() async {
|
||||||
|
// Step 1: Check if there are any transactions to export.
|
||||||
|
if (_transactions.isEmpty) {
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('No transactions to export.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var logo = await rootBundle.load('assets/images/logo.png');
|
||||||
|
var rubik = await rootBundle.load("assets/fonts/Rubik-Regular.ttf");
|
||||||
|
final pdf = pw.Document();
|
||||||
|
|
||||||
|
pdf.addPage(pw.MultiPage(
|
||||||
|
margin: const pw.EdgeInsets.all(20),
|
||||||
|
build: (pw.Context context) {
|
||||||
|
return [
|
||||||
|
pw.Row(
|
||||||
|
mainAxisAlignment: pw.MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: pw.CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
pw.Image(pw.MemoryImage(logo.buffer.asUint8List()),
|
||||||
|
width: 50, height: 50),
|
||||||
|
pw.SizedBox(width: 20),
|
||||||
|
pw.Text('Account Statement - KCCB',
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 24, fontWeight: pw.FontWeight.bold)),
|
||||||
|
]),
|
||||||
|
pw.SizedBox(height: 20),
|
||||||
|
pw.Row(
|
||||||
|
mainAxisAlignment: pw.MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
pw.Text('Account Number: ${widget.accountNo}',
|
||||||
|
style:
|
||||||
|
pw.TextStyle(font: pw.Font.ttf(rubik), fontSize: 15)),
|
||||||
|
pw.Text('Account Type: ${widget.accountType}',
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
font: pw.Font.ttf(rubik),
|
||||||
|
)),
|
||||||
|
]),
|
||||||
|
pw.SizedBox(height: 20),
|
||||||
|
pw.Table(border: pw.TableBorder.all(), columnWidths: {
|
||||||
|
0: const pw.FractionColumnWidth(0.2),
|
||||||
|
1: const pw.FractionColumnWidth(0.45),
|
||||||
|
2: const pw.FractionColumnWidth(0.15),
|
||||||
|
3: const pw.FractionColumnWidth(0.20),
|
||||||
|
}, children: [
|
||||||
|
pw.TableRow(
|
||||||
|
children: [
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(4),
|
||||||
|
child: pw.Text('Date')),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(4),
|
||||||
|
child: pw.Text('Description', softWrap: true)),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(4),
|
||||||
|
child: pw.Text('Amount')),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(4),
|
||||||
|
child: pw.Text('Balance')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
..._transactions.map<pw.TableRow>((tx) {
|
||||||
|
return pw.TableRow(children: [
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(10),
|
||||||
|
child: pw.Text(tx.date ?? '',
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
font: pw.Font.ttf(rubik),
|
||||||
|
))),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(10),
|
||||||
|
child: pw.Text(tx.name ?? '',
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 12, font: pw.Font.ttf(rubik)))),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(10),
|
||||||
|
child: pw.Text("₹${tx.amount} ${tx.type}",
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
font: pw.Font.ttf(rubik),
|
||||||
|
))),
|
||||||
|
pw.Padding(
|
||||||
|
padding: const pw.EdgeInsets.all(10),
|
||||||
|
child: pw.Text("₹${tx.balance} ${tx.balanceType}",
|
||||||
|
style: pw.TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
font: pw.Font.ttf(rubik),
|
||||||
|
))),
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
];
|
||||||
|
},
|
||||||
|
footer: (pw.Context context) {
|
||||||
|
return pw.Container(
|
||||||
|
alignment: pw.Alignment.centerRight,
|
||||||
|
margin: const pw.EdgeInsets.only(top: 10),
|
||||||
|
child: pw.Text(
|
||||||
|
'Kangra Central Co-Operative Bank Pvt Ltd. ©. All rights reserved.',
|
||||||
|
style: pw.TextStyle(
|
||||||
|
font: pw.Font.ttf(rubik),
|
||||||
|
fontSize: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
|
||||||
|
//Logic For all platforms
|
||||||
|
try {
|
||||||
|
final Uint8List pdfBytes = await pdf.save();
|
||||||
|
final String timestamp = DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
|
final String fileName = 'account_statement_$timestamp.pdf';
|
||||||
|
|
||||||
|
// For Android
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
final androidInfo = await DeviceInfoPlugin().androidInfo;
|
||||||
|
if (androidInfo.version.sdkInt < 29) {
|
||||||
|
final status = await Permission.storage.status;
|
||||||
|
if (status.isDenied) {
|
||||||
|
final result = await Permission.storage.request();
|
||||||
|
if (result.isDenied) {
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Storage permission is required to save PDF'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final directory = Directory('/storage/emulated/0/Download');
|
||||||
|
final file = File('${directory.path}/$fileName');
|
||||||
|
await file.writeAsBytes(pdfBytes);
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('PDF saved to: ${file.path}'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add for IOS
|
||||||
|
else if (Platform.isIOS) {
|
||||||
|
// On iOS, we save to a temporary directory and then open the share sheet.
|
||||||
|
final tempDir = await getTemporaryDirectory();
|
||||||
|
final file = await File('${tempDir.path}/$fileName').create();
|
||||||
|
await file.writeAsBytes(pdfBytes);
|
||||||
|
|
||||||
|
// Use share_plus to open the iOS share dialog
|
||||||
|
await Share.shareXFiles(
|
||||||
|
[XFile(file.path)],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Error saving PDF: $e'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget buildDateBox(String label, DateTime? date) {
|
Widget buildDateBox(String label, DateTime? date) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.grey),
|
border:
|
||||||
|
Border.all(color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -335,7 +529,9 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
|||||||
date != null ? _formatDate(date) : label,
|
date != null ? _formatDate(date) : label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: date != null ? Colors.black : Colors.grey,
|
color: date != null
|
||||||
|
? Theme.of(context).colorScheme.onSurface
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Icon(Icons.arrow_drop_down),
|
const Icon(Icons.arrow_drop_down),
|
||||||
|
|||||||
112
lib/features/accounts/screens/transaction_details_screen.dart
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
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 ?? "")
|
||||||
|
// ]
|
||||||
|
_buildDetailRow(
|
||||||
|
AppLocalizations.of(context).details, transaction.name),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDetailRow(String label, String value) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"$label: ",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 17,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
value,
|
||||||
|
style: const TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,48 +1,27 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'theme_state.dart';
|
|
||||||
import 'package:kmobile/config/theme_type.dart';
|
import 'package:kmobile/config/theme_type.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'theme_state.dart';
|
||||||
|
|
||||||
class ThemeCubit extends Cubit<ThemeState> {
|
class ThemeCubit extends Cubit<ThemeState> {
|
||||||
ThemeCubit(): super(ThemeViolet()) {
|
ThemeCubit() : super(const ThemeState(themeType: ThemeType.violet)) {
|
||||||
loadTheme();
|
loadTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadTheme() async {
|
Future<void> loadTheme() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final themeIndex = prefs.getInt('theme_type') ?? 0;
|
final themeIndex = prefs.getInt('theme_type') ?? 0;
|
||||||
// final isDark = prefs.getBool('is_dark_mode') ?? false;
|
|
||||||
|
|
||||||
final type = ThemeType.values[themeIndex];
|
final type = ThemeType.values[themeIndex];
|
||||||
switch(type) {
|
emit(ThemeState(themeType: type));
|
||||||
case ThemeType.blue:
|
|
||||||
emit(ThemeBlue());
|
|
||||||
case ThemeType.violet:
|
|
||||||
emit(ThemeViolet());
|
|
||||||
default:
|
|
||||||
emit(ThemeViolet());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changeTheme(ThemeType type) async {
|
Future<void> changeTheme(ThemeType type) async {
|
||||||
|
log("Attempting to change theme...");
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setInt('theme_type', type.index);
|
await prefs.setInt('theme_type', type.index);
|
||||||
log("Mode Change");
|
emit(ThemeState(themeType: type));
|
||||||
print("mode changed");
|
|
||||||
switch(type) {
|
|
||||||
case ThemeType.blue:
|
|
||||||
emit(ThemeBlue());
|
|
||||||
print('blue matched');
|
|
||||||
break;
|
|
||||||
case ThemeType.violet:
|
|
||||||
emit(ThemeViolet());
|
|
||||||
print('violet matched');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
emit(ThemeBlue());
|
|
||||||
print('default macthed');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
lib/features/auth/controllers/theme_mode_cubit.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'theme_mode_state.dart';
|
||||||
|
|
||||||
|
class ThemeModeCubit extends Cubit<ThemeModeState> {
|
||||||
|
ThemeModeCubit() : super(const ThemeModeState(mode: ThemeMode.system)) {
|
||||||
|
loadThemeMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> loadThemeMode() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final modeIndex = prefs.getInt('theme_mode') ?? 0; // default system
|
||||||
|
final mode = ThemeMode.values[modeIndex];
|
||||||
|
emit(ThemeModeState(mode: mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> changeThemeMode(ThemeMode mode) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setInt('theme_mode', mode.index);
|
||||||
|
emit(ThemeModeState(mode: mode));
|
||||||
|
}
|
||||||
|
}
|
||||||
11
lib/features/auth/controllers/theme_mode_state.dart
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ThemeModeState extends Equatable {
|
||||||
|
final ThemeMode mode;
|
||||||
|
|
||||||
|
const ThemeModeState({required this.mode});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [mode];
|
||||||
|
}
|
||||||
@@ -1,27 +1,38 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
/*import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/config/theme_type.dart';
|
import 'package:kmobile/config/theme_type.dart';
|
||||||
import 'package:kmobile/config/themes.dart';
|
import 'package:kmobile/config/themes.dart';
|
||||||
|
|
||||||
|
class ThemeState extends Equatable {
|
||||||
|
final ThemeType themeType;
|
||||||
|
|
||||||
abstract class ThemeState extends Equatable {
|
const ThemeState({required this.themeType});
|
||||||
getThemeData();
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [];
|
|
||||||
}
|
|
||||||
|
|
||||||
class ThemeBlue extends ThemeState {
|
ThemeData getThemeData() {
|
||||||
|
return AppThemes.getLightTheme(themeType);
|
||||||
@override
|
|
||||||
getThemeData() {
|
|
||||||
print('returning blue theme');
|
|
||||||
return AppThemes.getLightTheme(ThemeType.blue);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class ThemeViolet extends ThemeState {
|
|
||||||
@override
|
@override
|
||||||
getThemeData() {
|
List<Object?> get props => [themeType];
|
||||||
print('returning violet theme');
|
}*/
|
||||||
return AppThemes.getLightTheme(ThemeType.violet);
|
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/config/theme_type.dart';
|
||||||
|
import 'package:kmobile/config/themes.dart';
|
||||||
|
|
||||||
|
class ThemeState extends Equatable {
|
||||||
|
final ThemeType themeType;
|
||||||
|
const ThemeState({required this.themeType});
|
||||||
|
|
||||||
|
ThemeData getLightThemeData() {
|
||||||
|
return AppThemes.getLightTheme(themeType);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
ThemeData getDarkThemeData() {
|
||||||
|
return AppThemes.getDarkTheme(themeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [themeType];
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import 'package:equatable/equatable.dart';
|
|||||||
class AuthToken extends Equatable {
|
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];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.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/set_password_screen.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import '../../../app.dart';
|
import '../../../app.dart';
|
||||||
import '../controllers/auth_cubit.dart';
|
import '../controllers/auth_cubit.dart';
|
||||||
@@ -23,23 +24,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();
|
||||||
@@ -48,9 +35,9 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
void _submitForm() {
|
void _submitForm() {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
context.read<AuthCubit>().login(
|
context.read<AuthCubit>().login(
|
||||||
_customerNumberController.text.trim(),
|
_customerNumberController.text.trim(),
|
||||||
_passwordController.text,
|
_passwordController.text,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +50,7 @@ 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(
|
||||||
@@ -87,9 +75,15 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (state is AuthError) {
|
} else if (state is AuthError) {
|
||||||
ScaffoldMessenger.of(
|
if (state.message == 'MIGRATED_USER_HAS_NO_PASSWORD') {
|
||||||
context,
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
).showSnackBar(SnackBar(content: Text(state.message)));
|
builder: (_) => SetPasswordScreen(
|
||||||
|
customerNo: _customerNumberController.text.trim(),
|
||||||
|
)));
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context)
|
||||||
|
.showSnackBar(SnackBar(content: Text(state.message)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@@ -100,21 +94,17 @@ 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 Icon(
|
color: Theme.of(context).primaryColor,
|
||||||
Icons.account_balance,
|
);
|
||||||
size: 100,
|
},
|
||||||
color: Theme.of(context).primaryColor,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Title
|
// Title
|
||||||
@@ -133,15 +123,18 @@ 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: Theme.of(context).scaffoldBackgroundColor,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.outline),
|
||||||
),
|
),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
width: 2),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
@@ -159,19 +152,21 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
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: Theme.of(context).scaffoldBackgroundColor,
|
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
enabledBorder: const OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black),
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.outline),
|
||||||
),
|
),
|
||||||
focusedBorder: const OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
borderSide: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
width: 2),
|
||||||
),
|
),
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
@@ -202,52 +197,59 @@ 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: Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor:
|
||||||
|
Theme.of(context).scaffoldBackgroundColor,
|
||||||
foregroundColor: Theme.of(context).primaryColorDark,
|
foregroundColor: Theme.of(context).primaryColorDark,
|
||||||
side: const BorderSide(color: Colors.black, width: 1),
|
side: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.outline,
|
||||||
|
width: 1),
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
child: state is AuthLoading
|
child: state is AuthLoading
|
||||||
? const CircularProgressIndicator()
|
? const CircularProgressIndicator()
|
||||||
: Text(
|
: Text(
|
||||||
AppLocalizations.of(context).login,
|
AppLocalizations.of(context).login,
|
||||||
style: TextStyle(fontSize: 16),
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onPrimaryContainer),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
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()),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
// Register Button
|
// Register Button
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 250,
|
// width: 250,
|
||||||
child: ElevatedButton(
|
// child: ElevatedButton(
|
||||||
//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: Theme.of(context).primaryColorLight,
|
// backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
foregroundColor: Colors.black,
|
// foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
),
|
// ),
|
||||||
child: Text(AppLocalizations.of(context).register),
|
// child: Text(AppLocalizations.of(context).register,
|
||||||
),
|
// style: TextStyle(color: Theme.of(context).colorScheme.onPrimary),),
|
||||||
),
|
// ),
|
||||||
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -257,227 +259,3 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:kmobile/di/injection.dart';
|
|
||||||
import 'package:kmobile/features/auth/screens/mpin_screen.dart';
|
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
|
||||||
import '../../../app.dart';
|
|
||||||
import '../controllers/auth_cubit.dart';
|
|
||||||
import '../controllers/auth_state.dart';
|
|
||||||
|
|
||||||
class LoginScreen extends StatefulWidget {
|
|
||||||
const LoginScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
LoginScreenState createState() => LoginScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class LoginScreenState extends State<LoginScreen> {
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
|
||||||
final _customerNumberController = TextEditingController();
|
|
||||||
final _passwordController = TextEditingController();
|
|
||||||
bool _obscurePassword = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_customerNumberController.dispose();
|
|
||||||
_passwordController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _submitForm() {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
context.read<AuthCubit>().login(
|
|
||||||
_customerNumberController.text.trim(),
|
|
||||||
_passwordController.text,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
// appBar: AppBar(title: const Text('Login')),
|
|
||||||
body: BlocConsumer<AuthCubit, AuthState>(
|
|
||||||
listener: (context, state) async {
|
|
||||||
if (state is Authenticated) {
|
|
||||||
final storage = getIt<SecureStorage>();
|
|
||||||
final mpin = await storage.read('mpin');
|
|
||||||
if (mpin == null) {
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => MPinScreen(
|
|
||||||
mode: MPinMode.set,
|
|
||||||
onCompleted: (_) {
|
|
||||||
Navigator.of(context, rootNavigator: true)
|
|
||||||
.pushReplacement(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) => const NavigationScaffold()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Navigator.of(context).pushReplacement(
|
|
||||||
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else if (state is AuthError) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text(state.message)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
builder: (context, state) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(24.0),
|
|
||||||
child: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Image.asset('assets/images/logo.png', width: 150, height: 150,
|
|
||||||
errorBuilder: (context, error, stackTrace) {
|
|
||||||
return const Icon(Icons.account_balance,
|
|
||||||
size: 100, color: Colors.blue);
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
// Title
|
|
||||||
const Text(
|
|
||||||
'KCCB',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.blue),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 48),
|
|
||||||
|
|
||||||
TextFormField(
|
|
||||||
controller: _customerNumberController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Customer Number',
|
|
||||||
// prefixIcon: Icon(Icons.person),
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
isDense: true,
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.white,
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return 'Please enter your username';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
TextFormField(
|
|
||||||
controller: _passwordController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Password',
|
|
||||||
// prefixIcon: const Icon(Icons.lock),
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
isDense: true,
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.white,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
|
||||||
),
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
_obscurePassword
|
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_obscurePassword = !_obscurePassword;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textInputAction: TextInputAction.done,
|
|
||||||
obscureText: _obscurePassword,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return 'Please enter your password';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
SizedBox(
|
|
||||||
width: 250,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: state is AuthLoading ? null : _submitForm,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
shape: const StadiumBorder(),
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
foregroundColor: Colors.blueAccent,
|
|
||||||
side: const BorderSide(color: Colors.black, width: 1),
|
|
||||||
elevation: 0),
|
|
||||||
child: state is AuthLoading
|
|
||||||
? const CircularProgressIndicator()
|
|
||||||
: const Text(
|
|
||||||
'Login',
|
|
||||||
style: TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 16),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Expanded(child: Divider()),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
child: Text('OR'),
|
|
||||||
),
|
|
||||||
Expanded(child: Divider()),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
|
|
||||||
// Register Button
|
|
||||||
SizedBox(
|
|
||||||
width: 250,
|
|
||||||
child: ElevatedButton(
|
|
||||||
//disable until registration is implemented
|
|
||||||
onPressed: null,
|
|
||||||
style: OutlinedButton.styleFrom(
|
|
||||||
shape: const StadiumBorder(),
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
||||||
backgroundColor: Colors.lightBlue[100],
|
|
||||||
foregroundColor: Colors.black),
|
|
||||||
child: const Text('Register'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'dart:developer';
|
// import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/app.dart';
|
import 'package:kmobile/app.dart';
|
||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
enum MPinMode { enter, set, confirm }
|
enum MPinMode { enter, set, confirm }
|
||||||
|
|
||||||
@@ -26,26 +28,78 @@ class MPinScreen extends StatefulWidget {
|
|||||||
State<MPinScreen> createState() => _MPinScreenState();
|
State<MPinScreen> createState() => _MPinScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MPinScreenState extends State<MPinScreen> {
|
class _MPinScreenState extends State<MPinScreen> with TickerProviderStateMixin {
|
||||||
List<String> mPin = [];
|
List<String> mPin = [];
|
||||||
String? errorText;
|
String? errorText;
|
||||||
|
|
||||||
|
// Animation controllers
|
||||||
|
late final AnimationController _bounceController;
|
||||||
|
late final Animation<double> _bounceAnimation;
|
||||||
|
late final AnimationController _shakeController;
|
||||||
|
late final AnimationController _waveController;
|
||||||
|
late final Animation<double> _waveAnimation;
|
||||||
|
|
||||||
|
// State flags for animations
|
||||||
|
bool _isError = false;
|
||||||
|
bool _isSuccess = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
// Bounce animation for single dot entry
|
||||||
|
_bounceController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 150),
|
||||||
|
);
|
||||||
|
_bounceAnimation = Tween<double>(begin: 1.0, end: 1.2).animate(
|
||||||
|
CurvedAnimation(
|
||||||
|
parent: _bounceController,
|
||||||
|
curve: Curves.elasticIn,
|
||||||
|
reverseCurve: Curves.elasticOut,
|
||||||
|
),
|
||||||
|
)..addStatusListener((status) {
|
||||||
|
if (status == AnimationStatus.completed) {
|
||||||
|
_bounceController.reverse();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Shake animation for error
|
||||||
|
_shakeController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 400),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wave animation for success
|
||||||
|
_waveController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 800),
|
||||||
|
);
|
||||||
|
_waveAnimation = Tween<double>(begin: 0, end: 1).animate(
|
||||||
|
CurvedAnimation(parent: _waveController, curve: Curves.easeInOut),
|
||||||
|
);
|
||||||
|
|
||||||
if (widget.mode == MPinMode.enter) {
|
if (widget.mode == MPinMode.enter) {
|
||||||
_tryBiometricBeforePin();
|
_tryBiometricBeforePin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_bounceController.dispose();
|
||||||
|
_shakeController.dispose();
|
||||||
|
_waveController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _tryBiometricBeforePin() async {
|
Future<void> _tryBiometricBeforePin() async {
|
||||||
final storage = getIt<SecureStorage>();
|
final storage = getIt<SecureStorage>();
|
||||||
final enabled = await storage.read('biometric_enabled');
|
final enabled = await storage.read('biometric_enabled');
|
||||||
log('biometric_enabled: $enabled');
|
// log('biometric_enabled: $enabled');
|
||||||
if (enabled != null && enabled) {
|
if (enabled != null && enabled) {
|
||||||
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),
|
||||||
);
|
);
|
||||||
@@ -61,11 +115,13 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addDigit(String digit) {
|
void addDigit(String digit) {
|
||||||
|
if (_shakeController.isAnimating || _waveController.isAnimating) return;
|
||||||
if (mPin.length < 4) {
|
if (mPin.length < 4) {
|
||||||
setState(() {
|
setState(() {
|
||||||
mPin.add(digit);
|
mPin.add(digit);
|
||||||
errorText = null;
|
errorText = null;
|
||||||
});
|
});
|
||||||
|
_bounceController.forward(from: 0);
|
||||||
if (mPin.length == 4) {
|
if (mPin.length == 4) {
|
||||||
_handleComplete();
|
_handleComplete();
|
||||||
}
|
}
|
||||||
@@ -73,6 +129,7 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void deleteDigit() {
|
void deleteDigit() {
|
||||||
|
if (_shakeController.isAnimating || _waveController.isAnimating) return;
|
||||||
if (mPin.isNotEmpty) {
|
if (mPin.isNotEmpty) {
|
||||||
setState(() {
|
setState(() {
|
||||||
mPin.removeLast();
|
mPin.removeLast();
|
||||||
@@ -82,19 +139,36 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _handleComplete() async {
|
Future<void> _handleComplete() async {
|
||||||
|
if (_shakeController.isAnimating || _waveController.isAnimating) return;
|
||||||
|
|
||||||
final pin = mPin.join();
|
final pin = mPin.join();
|
||||||
final storage = SecureStorage();
|
final storage = SecureStorage();
|
||||||
|
|
||||||
switch (widget.mode) {
|
switch (widget.mode) {
|
||||||
case MPinMode.enter:
|
case MPinMode.enter:
|
||||||
final storedPin = await storage.read('mpin');
|
final storedPin = await storage.read('mpin');
|
||||||
log('storedPin: $storedPin');
|
// log('storedPin: $storedPin');
|
||||||
if (storedPin == int.tryParse(pin)) {
|
if (storedPin == int.tryParse(pin)) {
|
||||||
widget.onCompleted?.call(pin);
|
// Correct PIN
|
||||||
} else {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_isSuccess = true;
|
||||||
|
errorText = null;
|
||||||
|
});
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
_waveController.forward(from: 0).whenComplete(() {
|
||||||
|
widget.onCompleted?.call(pin);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Incorrect PIN
|
||||||
|
setState(() {
|
||||||
|
_isError = true;
|
||||||
errorText = AppLocalizations.of(context).incorrectMPIN;
|
errorText = AppLocalizations.of(context).incorrectMPIN;
|
||||||
|
});
|
||||||
|
await _shakeController.forward(from: 0);
|
||||||
|
setState(() {
|
||||||
mPin.clear();
|
mPin.clear();
|
||||||
|
_isError = false;
|
||||||
|
// Keep error text until next digit is entered
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -125,28 +199,81 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_isError = true;
|
||||||
errorText = AppLocalizations.of(context).pinsDoNotMatch;
|
errorText = AppLocalizations.of(context).pinsDoNotMatch;
|
||||||
|
});
|
||||||
|
await _shakeController.forward(from: 0);
|
||||||
|
setState(() {
|
||||||
mPin.clear();
|
mPin.clear();
|
||||||
|
_isError = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildMPinDots() {
|
Widget buildMPinDots(BuildContext context) {
|
||||||
return Row(
|
return AnimatedBuilder(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
animation: Listenable.merge(
|
||||||
children: List.generate(4, (index) {
|
[_bounceController, _shakeController, _waveController]),
|
||||||
return Container(
|
builder: (context, child) {
|
||||||
margin: const EdgeInsets.all(8),
|
double shakeOffset = 0;
|
||||||
width: 15,
|
if (_shakeController.isAnimating) {
|
||||||
height: 15,
|
// 4 cycles of sine wave for shake
|
||||||
decoration: BoxDecoration(
|
shakeOffset = sin(_shakeController.value * 4 * pi) * 12;
|
||||||
shape: BoxShape.circle,
|
}
|
||||||
color: index < mPin.length ? Colors.black : Colors.grey[400],
|
|
||||||
|
return Transform.translate(
|
||||||
|
offset: Offset(shakeOffset, 0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: List.generate(4, (index) {
|
||||||
|
final isFilled = index < mPin.length;
|
||||||
|
|
||||||
|
// Bounce animation for single dot
|
||||||
|
final isAnimatingBounce =
|
||||||
|
index == mPin.length - 1 && _bounceController.isAnimating;
|
||||||
|
double bounceScale =
|
||||||
|
isAnimatingBounce ? _bounceAnimation.value : 1.0;
|
||||||
|
|
||||||
|
// Success wave animation
|
||||||
|
double waveScale = 1.0;
|
||||||
|
if (_isSuccess) {
|
||||||
|
final waveDelay = index * 0.15;
|
||||||
|
final waveValue =
|
||||||
|
(_waveAnimation.value - waveDelay).clamp(0.0, 1.0);
|
||||||
|
// Grow and shrink
|
||||||
|
waveScale = 1.0 + sin(waveValue * pi) * 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine dot color
|
||||||
|
Color dotColor;
|
||||||
|
if (_isError) {
|
||||||
|
dotColor = Theme.of(context).colorScheme.error;
|
||||||
|
} else if (_isSuccess) {
|
||||||
|
dotColor = Colors.green.shade600;
|
||||||
|
} else {
|
||||||
|
dotColor = isFilled
|
||||||
|
? Theme.of(context).colorScheme.onSurfaceVariant
|
||||||
|
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Transform.scale(
|
||||||
|
scale: bounceScale * waveScale,
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.all(8),
|
||||||
|
width: 25,
|
||||||
|
height: 25,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
color: dotColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,9 +291,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: row.map((key) {
|
children: row.map((key) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(1.0),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
if (key == '<') {
|
if (key == '<') {
|
||||||
deleteDigit();
|
deleteDigit();
|
||||||
} else if (key == 'Enter') {
|
} else if (key == 'Enter') {
|
||||||
@@ -184,11 +312,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 70,
|
width: 80,
|
||||||
height: 70,
|
height: 80,
|
||||||
decoration: BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: Colors.grey[200],
|
|
||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: key == 'Enter'
|
child: key == 'Enter'
|
||||||
@@ -196,8 +323,10 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
: Text(
|
: Text(
|
||||||
key == '<' ? '⌫' : key,
|
key == '<' ? '⌫' : key,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 30,
|
||||||
color: key == 'Enter' ? Theme.of(context).primaryColor : Colors.black,
|
color: key == 'Enter'
|
||||||
|
? Theme.of(context).primaryColor
|
||||||
|
: Theme.of(context).colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -226,7 +355,7 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const Spacer(),
|
const SizedBox(height: 50),
|
||||||
// Logo
|
// Logo
|
||||||
Image.asset('assets/images/logo.png', height: 100),
|
Image.asset('assets/images/logo.png', height: 100),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
@@ -234,19 +363,18 @@ class _MPinScreenState extends State<MPinScreen> {
|
|||||||
getTitle(),
|
getTitle(),
|
||||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const Spacer(),
|
||||||
buildMPinDots(),
|
buildMPinDots(context),
|
||||||
if (errorText != null)
|
if (errorText != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
errorText!,
|
errorText!,
|
||||||
style: const TextStyle(color: Colors.red),
|
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
buildNumberPad(),
|
buildNumberPad(),
|
||||||
const Spacer(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
296
lib/features/auth/screens/set_password_screen.dart
Normal file
@@ -0,0 +1,296 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/api/services/auth_service.dart';
|
||||||
|
import 'package:kmobile/di/injection.dart';
|
||||||
|
import 'package:kmobile/features/auth/screens/login_screen.dart';
|
||||||
|
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
class SetPasswordScreen extends StatefulWidget {
|
||||||
|
final String customerNo;
|
||||||
|
const SetPasswordScreen({super.key, required this.customerNo});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SetPasswordScreen> createState() => _SetPasswordScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SetPasswordStep { initial, otp, setPassword, success }
|
||||||
|
|
||||||
|
class _SetPasswordScreenState extends State<SetPasswordScreen> {
|
||||||
|
final _authService = getIt<AuthService>();
|
||||||
|
SetPasswordStep _currentStep = SetPasswordStep.initial;
|
||||||
|
bool _isLoading = false;
|
||||||
|
String? _error;
|
||||||
|
String? _otpToken;
|
||||||
|
|
||||||
|
final _otpController = TextEditingController();
|
||||||
|
final _passwordController = TextEditingController();
|
||||||
|
final _confirmPasswordController = TextEditingController();
|
||||||
|
|
||||||
|
bool _obscurePassword = true;
|
||||||
|
bool _obscureConfirmPassword = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_otpController.dispose();
|
||||||
|
_passwordController.dispose();
|
||||||
|
_confirmPasswordController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _sendOtp() async {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await _authService.sendOtpForSettingPassword(widget.customerNo);
|
||||||
|
setState(() {
|
||||||
|
_currentStep = SetPasswordStep.otp;
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_error = e.toString();
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _verifyOtp() async {
|
||||||
|
if (_otpController.text.isEmpty) {
|
||||||
|
setState(() {
|
||||||
|
_error = 'Please enter OTP';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
final token = await _authService.verifyOtpForSettingPassword(
|
||||||
|
widget.customerNo, _otpController.text);
|
||||||
|
setState(() {
|
||||||
|
_otpToken = token;
|
||||||
|
_currentStep = SetPasswordStep.setPassword;
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_error = AppLocalizations.of(context).invalidOtp;
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _setPassword() async {
|
||||||
|
if (_passwordController.text.isEmpty ||
|
||||||
|
_confirmPasswordController.text.isEmpty) {
|
||||||
|
setState(() {
|
||||||
|
_error = 'Please fill both password fields';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_passwordController.text != _confirmPasswordController.text) {
|
||||||
|
setState(() {
|
||||||
|
_error = 'Passwords do not match';
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_otpToken == null) {
|
||||||
|
setState(() {
|
||||||
|
_error = 'OTP token is missing. Please restart the process.';
|
||||||
|
_currentStep = SetPasswordStep.initial;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await _authService.changePassword(_passwordController.text, _otpToken!);
|
||||||
|
setState(() {
|
||||||
|
_currentStep = SetPasswordStep.success;
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_error = e.toString();
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Set New Password'),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(24.0),
|
||||||
|
child: Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
if (_error != null) ...[
|
||||||
|
Text(
|
||||||
|
_error!,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 20),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
|
if (_isLoading)
|
||||||
|
const CircularProgressIndicator()
|
||||||
|
else
|
||||||
|
_buildStepContent(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStepContent() {
|
||||||
|
switch (_currentStep) {
|
||||||
|
case SetPasswordStep.initial:
|
||||||
|
return _buildInitialStep();
|
||||||
|
case SetPasswordStep.otp:
|
||||||
|
return _buildOtpStep();
|
||||||
|
case SetPasswordStep.setPassword:
|
||||||
|
return _buildSetPasswordStep();
|
||||||
|
case SetPasswordStep.success:
|
||||||
|
return _buildSuccessStep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildInitialStep() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'You need to set a new password to continue. We will send an OTP to your registered mobile number.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _sendOtp,
|
||||||
|
child: const Text('Proceed'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildOtpStep() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'An OTP has been sent to your registered mobile number. Please enter it below.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextField(
|
||||||
|
controller: _otpController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Enter OTP',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _verifyOtp,
|
||||||
|
child: const Text('Verify OTP'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSetPasswordStep() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _passwordController,
|
||||||
|
obscureText: _obscurePassword,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'New Password',
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_obscurePassword ? Icons.visibility : Icons.visibility_off,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_obscurePassword = !_obscurePassword;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextFormField(
|
||||||
|
controller: _confirmPasswordController,
|
||||||
|
obscureText: _obscureConfirmPassword,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Confirm New Password',
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
_obscureConfirmPassword
|
||||||
|
? Icons.visibility
|
||||||
|
: Icons.visibility_off,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_obscureConfirmPassword = !_obscureConfirmPassword;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _setPassword,
|
||||||
|
child: const Text('Set Password'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSuccessStep() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.check_circle, color: Colors.green, size: 80),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
const Text(
|
||||||
|
'Password set successfully!',
|
||||||
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Text(
|
||||||
|
'You can now log in with your new password.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushAndRemoveUntil(
|
||||||
|
MaterialPageRoute(builder: (_) => const LoginScreen()),
|
||||||
|
(route) => false,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Back to Login'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
103
lib/features/auth/screens/splash_screen.dart
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'package:kmobile/api/services/send_sms_service.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class SplashScreen extends StatefulWidget {
|
||||||
|
const SplashScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SplashScreen> createState() => _SplashScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SplashScreenState extends State<SplashScreen> {
|
||||||
|
String _version = '';
|
||||||
|
final SmsService _smsService = SmsService();
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadVersion();
|
||||||
|
_sendInitialSms();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _sendInitialSms() async {
|
||||||
|
await _smsService.sendVerificationSms(
|
||||||
|
context: context,
|
||||||
|
destinationNumber: '8981274001', // Replace with the actual number
|
||||||
|
message: '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadVersion() async {
|
||||||
|
final PackageInfo info = await PackageInfo.fromPlatform();
|
||||||
|
if (mounted) {
|
||||||
|
// Check if the widget is still in the tree
|
||||||
|
setState(() {
|
||||||
|
_version = 'Version ${info.version} (${info.buildNumber})';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: <Widget>[
|
||||||
|
Positioned.fill(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/kconnect2.webp',
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context).kccbMobile,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 36,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Color(0xFFFFFFFF),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context).kccBankFull,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 18,
|
||||||
|
color: Color(0xFFFFFFFF),
|
||||||
|
letterSpacing: 1.2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Positioned(
|
||||||
|
bottom: 40,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Center(
|
||||||
|
child: CircularProgressIndicator(color: Color(0xFFFFFFFF)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 90,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
child: Text(
|
||||||
|
_version,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Color(0xFFFFFFFF),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
import '../../../l10n/app_localizations.dart';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
class WelcomeScreen extends StatefulWidget {
|
|
||||||
final VoidCallback onContinue;
|
|
||||||
|
|
||||||
const WelcomeScreen({super.key, required this.onContinue});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<WelcomeScreen> createState() => _WelcomeScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _WelcomeScreenState extends State<WelcomeScreen> {
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
// Automatically go to logizn after 4 seconds
|
|
||||||
Timer(const Duration(seconds: 4), () {
|
|
||||||
|
|
||||||
widget.onContinue();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: Stack(
|
|
||||||
children: [
|
|
||||||
/// 🔹 Background Image
|
|
||||||
Positioned.fill(
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/images/kconnect2.webp',
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
/// 🔹 Centered Text Overlay
|
|
||||||
Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context).kconnect,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 36,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Theme.of(context).dialogBackgroundColor,
|
|
||||||
letterSpacing: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context).kccBankFull,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
color: Theme.of(context).dialogBackgroundColor,
|
|
||||||
letterSpacing: 1.2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
/// 🔹 Loading Spinner at Bottom
|
|
||||||
Positioned(
|
|
||||||
bottom: 40,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Center(
|
|
||||||
child: CircularProgressIndicator(color: Theme.of(context).scaffoldBackgroundColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class WelcomeScreen extends StatelessWidget {
|
|
||||||
final VoidCallback onContinue;
|
|
||||||
|
|
||||||
const WelcomeScreen({super.key, required this.onContinue});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
body: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(32.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Spacer(),
|
|
||||||
const Text(
|
|
||||||
'Welcome to',
|
|
||||||
style: TextStyle(fontSize: 28, color: Colors.black87),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
const Text(
|
|
||||||
'KCCB',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 42,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.indigo,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40),
|
|
||||||
Image.asset(
|
|
||||||
'assets/images/logo.png',
|
|
||||||
width: 150,
|
|
||||||
height: 150,
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: onContinue,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.indigo,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 28, vertical: 20),
|
|
||||||
),
|
|
||||||
child: const Text('Proceed to Login'),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@@ -1,22 +1,20 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
import 'package:kmobile/data/models/ifsc.dart';
|
|
||||||
import 'package:kmobile/data/models/beneficiary.dart';
|
import 'package:kmobile/data/models/beneficiary.dart';
|
||||||
import 'package:kmobile/data/models/user.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 'beneficiary_result_page.dart';
|
||||||
import '../../../di/injection.dart';
|
import '../../../di/injection.dart';
|
||||||
import '../../../l10n/app_localizations.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 {
|
||||||
final List<User>? users;
|
final String customerName;
|
||||||
final int? selectedIndex;
|
|
||||||
|
|
||||||
const AddBeneficiaryScreen({
|
const AddBeneficiaryScreen({
|
||||||
super.key,
|
super.key,
|
||||||
this.users,
|
required this.customerName,
|
||||||
this.selectedIndex,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -25,8 +23,9 @@ class AddBeneficiaryScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _accountNumberFieldKey = GlobalKey<FormFieldState>();
|
||||||
late User selectedUser = (widget.users ?? [])[widget.selectedIndex!];
|
final _confirmAccountNumberFieldKey = GlobalKey<FormFieldState>();
|
||||||
|
final _ifscFieldKey = GlobalKey<FormFieldState>();
|
||||||
final TextEditingController accountNumberController = TextEditingController();
|
final TextEditingController accountNumberController = TextEditingController();
|
||||||
final TextEditingController confirmAccountNumberController =
|
final TextEditingController confirmAccountNumberController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
@@ -35,216 +34,234 @@ 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 _ifscFocusNode = FocusNode();
|
||||||
String? _beneficiaryName;
|
final service = getIt<BeneficiaryService>();
|
||||||
|
|
||||||
bool _isValidating = false;
|
bool _isValidating = false;
|
||||||
bool _isBeneficiaryValidated = false;
|
bool _isBeneficiaryValidated = false;
|
||||||
|
// ignore: unused_field
|
||||||
String? _validationError;
|
String? _validationError;
|
||||||
|
|
||||||
late String accountType;
|
late String accountType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_ifscFocusNode.addListener(() {
|
||||||
|
if (!_ifscFocusNode.hasFocus && ifscController.text.trim().length == 11) {
|
||||||
|
_validateIFSC();
|
||||||
|
}
|
||||||
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
accountType = AppLocalizations.of(context).savings;
|
accountType = 'Savings';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
ifsc? _ifscData;
|
accountNumberController.dispose();
|
||||||
bool _isLoading = false; //for validateIFSC()
|
confirmAccountNumberController.dispose();
|
||||||
|
nameController.dispose();
|
||||||
void _validateIFSC() async {
|
bankNameController.dispose();
|
||||||
var beneficiaryService = getIt<BeneficiaryService>();
|
branchNameController.dispose();
|
||||||
final ifsc = ifscController.text.trim().toUpperCase();
|
ifscController.dispose();
|
||||||
if (ifsc.isEmpty) return;
|
phoneController.dispose();
|
||||||
setState(() {
|
_ifscFocusNode.dispose();
|
||||||
_isLoading = true;
|
super.dispose();
|
||||||
_ifscData = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
final result = await beneficiaryService.validateIFSC(ifsc);
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
_ifscData = result;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result == null) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
|
||||||
);
|
|
||||||
bankNameController.clear();
|
|
||||||
branchNameController.clear();
|
|
||||||
} else {
|
|
||||||
print("${AppLocalizations.of(context).validIfsc}: ${result.bankName}, ${result.branchName}");
|
|
||||||
bankNameController.text = result.bankName;
|
|
||||||
branchNameController.text = result.branchName;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
void _validateIFSC() async {
|
||||||
Future<void> _validateBeneficiary() async {
|
var beneficiaryService = getIt<BeneficiaryService>();
|
||||||
// start spinner / disable button
|
final ifsc = ifscController.text.trim().toUpperCase();
|
||||||
setState(() {
|
if (ifsc.isEmpty) return;
|
||||||
_isValidating = true;
|
|
||||||
_validationError = null;
|
|
||||||
_isBeneficiaryValidated = false;
|
|
||||||
nameController.text = ''; // clear previous name
|
|
||||||
});
|
|
||||||
|
|
||||||
final String accountNo = accountNumberController.text.trim();
|
try {
|
||||||
final String ifsc = ifscController.text.trim();
|
final result = await beneficiaryService.validateIFSC(ifsc);
|
||||||
final String remitter = selectedUser.name ?? '';
|
|
||||||
|
|
||||||
final service = getIt<BeneficiaryService>();
|
if (mounted) {
|
||||||
try {
|
if (result.bankName.isEmpty) {
|
||||||
// Step 1: call validate API -> get refNo
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
final String? refNo = await service.validateBeneficiary(
|
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||||
accountNo: accountNo,
|
);
|
||||||
ifscCode: ifsc,
|
bankNameController.clear();
|
||||||
remitterName: remitter,
|
branchNameController.clear();
|
||||||
);
|
} else {
|
||||||
|
bankNameController.text = result.bankName;
|
||||||
|
branchNameController.text = result.branchName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
final errorMessage = e.toString().toUpperCase();
|
||||||
|
String snackbarMessage =
|
||||||
|
AppLocalizations.of(context).somethingWentWrong;
|
||||||
|
|
||||||
if (refNo == null || refNo.isEmpty) {
|
if (errorMessage.contains('INVALID') && errorMessage.contains('IFSC')) {
|
||||||
setState(() {
|
snackbarMessage = AppLocalizations.of(context).invalidIfsc;
|
||||||
_validationError = 'Validation request failed. Please check details.';
|
}
|
||||||
_isBeneficiaryValidated = false;
|
|
||||||
});
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
return;
|
SnackBar(content: Text(snackbarMessage)),
|
||||||
|
);
|
||||||
|
bankNameController.clear();
|
||||||
|
branchNameController.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Step 2: poll checkValidationStatus for up to 30 seconds
|
void _validateBeneficiary() async {
|
||||||
const int timeoutSeconds = 30;
|
FocusScope.of(context).unfocus();
|
||||||
const int intervalSeconds = 2;
|
setState(() {
|
||||||
int elapsed = 0;
|
_isValidating = true;
|
||||||
String? foundName;
|
_validationError = null;
|
||||||
|
_isBeneficiaryValidated = false;
|
||||||
|
nameController.text = ''; // clear previous name
|
||||||
|
});
|
||||||
|
|
||||||
while (elapsed < timeoutSeconds) {
|
final String accountNo = accountNumberController.text.trim();
|
||||||
final String? name = await service.checkValidationStatus(refNo);
|
final String ifsc = ifscController.text.trim();
|
||||||
|
final String remitter = widget.customerName;
|
||||||
|
|
||||||
if (name != null && name.trim().isNotEmpty) {
|
final service = getIt<BeneficiaryService>();
|
||||||
foundName = name.trim();
|
try {
|
||||||
break;
|
String beneficiaryName;
|
||||||
|
if (ifsc.toLowerCase().contains('kace')) {
|
||||||
|
beneficiaryName =
|
||||||
|
await service.validateBeneficiaryWithinBank(accountNo);
|
||||||
|
} else {
|
||||||
|
beneficiaryName = await service.validateBeneficiary(
|
||||||
|
accountNo: accountNo,
|
||||||
|
ifscCode: ifsc,
|
||||||
|
remitterName: remitter,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Future.delayed(const Duration(seconds: intervalSeconds));
|
|
||||||
elapsed += intervalSeconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundName != null) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
nameController.text = foundName!;
|
nameController.text = beneficiaryName;
|
||||||
_isBeneficiaryValidated = true;
|
_isBeneficiaryValidated = true;
|
||||||
_validationError = null;
|
_validationError = null;
|
||||||
});
|
});
|
||||||
} else {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_validationError = 'Beneficiary not found within timeout.';
|
_validationError = e.toString();
|
||||||
_isBeneficiaryValidated = false;
|
_isBeneficiaryValidated = false;
|
||||||
});
|
});
|
||||||
}
|
} finally {
|
||||||
} catch (e, st) {
|
if (mounted) {
|
||||||
// handle unexpected errors
|
setState(() {
|
||||||
// print or log if you want
|
_isValidating = false;
|
||||||
debugPrint('Error validating beneficiary: $e\n$st');
|
});
|
||||||
setState(() {
|
}
|
||||||
_validationError = 'Something went wrong. Please try again.';
|
|
||||||
_isBeneficiaryValidated = false;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_isValidating = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
void validateAndAddBeneficiary() async {
|
||||||
|
// First, validate the form fields (account number, confirm account, ifsc, etc.)
|
||||||
String _selectedAccountType = 'Savings'; // default value
|
if (!_formKey.currentState!.validate()) {
|
||||||
|
return;
|
||||||
void validateAndAddBeneficiary() async {
|
|
||||||
// Show spinner and disable UI
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false, // Prevent dismiss on tap outside
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return WillPopScope(
|
|
||||||
onWillPop: () async => false, // Disable back button
|
|
||||||
child: const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
final beneficiary = Beneficiary(
|
|
||||||
accountNo: accountNumberController.text.trim(),
|
|
||||||
accountType: _selectedAccountType,
|
|
||||||
name: nameController.text.trim(),
|
|
||||||
ifscCode: ifscController.text.trim(),
|
|
||||||
);
|
|
||||||
|
|
||||||
var service = getIt<BeneficiaryService>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
await service.sendForValidation(beneficiary);
|
|
||||||
bool isFound = await service.checkIfFound(beneficiary.accountNo);
|
|
||||||
|
|
||||||
if (context.mounted) {
|
|
||||||
Navigator.pop(context); // Close the spinner
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => BeneficiaryResultPage(isSuccess: isFound),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
Navigator.pop(context); // Close the spinner
|
// Ensure beneficiary is validated before proceeding to TPIN
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
if (!_isBeneficiaryValidated) {
|
||||||
SnackBar(content: Text(AppLocalizations.of(context).somethingWentWrong)),
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(AppLocalizations.of(context)
|
||||||
|
.pleaseValidateBeneficiaryDetailsFirst)),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the beneficiary object without TPIN for now
|
||||||
|
final beneficiaryWithoutTpin = Beneficiary(
|
||||||
|
accountNo: accountNumberController.text.trim(),
|
||||||
|
accountType: accountType,
|
||||||
|
name: nameController.text.trim(),
|
||||||
|
ifscCode: ifscController.text.trim(),
|
||||||
|
bankName: bankNameController.text.trim(),
|
||||||
|
branchName: branchNameController.text.trim(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Navigate to TPIN screen
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => TransactionPinScreen(
|
||||||
|
onPinCompleted: (pinScreenContext, tpin) async {
|
||||||
|
// Show loading spinner while processing
|
||||||
|
showDialog(
|
||||||
|
context: pinScreenContext,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext ctx) {
|
||||||
|
// ignore: deprecated_member_use
|
||||||
|
return WillPopScope(
|
||||||
|
onWillPop: () async => false,
|
||||||
|
child: const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a new Beneficiary object with the TPIN
|
||||||
|
final beneficiaryWithTpin = Beneficiary(
|
||||||
|
accountNo: beneficiaryWithoutTpin.accountNo,
|
||||||
|
accountType: beneficiaryWithoutTpin.accountType,
|
||||||
|
name: beneficiaryWithoutTpin.name,
|
||||||
|
ifscCode: beneficiaryWithoutTpin.ifscCode,
|
||||||
|
bankName: beneficiaryWithoutTpin.bankName,
|
||||||
|
branchName: beneficiaryWithoutTpin.branchName,
|
||||||
|
tpin: tpin,
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final isSuccess =
|
||||||
|
await service.sendForValidation(beneficiaryWithTpin);
|
||||||
|
|
||||||
|
if (pinScreenContext.mounted) {
|
||||||
|
Navigator.pop(pinScreenContext); // Close the spinner
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
pinScreenContext,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (ctx) =>
|
||||||
|
BeneficiaryResultPage(isSuccess: isSuccess),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
if (pinScreenContext.mounted) {
|
||||||
|
Navigator.pop(pinScreenContext); // Close the spinner
|
||||||
|
ScaffoldMessenger.of(pinScreenContext).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(e.response?.statusCode == 409
|
||||||
|
? 'Beneficiary already exists'
|
||||||
|
: 'Something went Wrong')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (pinScreenContext.mounted) {
|
||||||
|
Navigator.pop(pinScreenContext); // Close the spinner
|
||||||
|
ScaffoldMessenger.of(pinScreenContext).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
AppLocalizations.of(context).somethingWentWrong)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
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).addBeneficiary,
|
AppLocalizations.of(context).addBeneficiary,
|
||||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
actions: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 10.0),
|
|
||||||
child: CircleAvatar(
|
|
||||||
backgroundColor: Colors.grey[200],
|
|
||||||
radius: 20,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
'assets/images/avatar_male.svg',
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Form(
|
child: Form(
|
||||||
@@ -259,29 +276,25 @@ void validateAndAddBeneficiary() async {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
key: _accountNumberFieldKey,
|
||||||
controller: accountNumberController,
|
controller: accountNumberController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(
|
labelText: AppLocalizations.of(
|
||||||
context,
|
context,
|
||||||
).accountNumber,
|
).accountNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
obscureText: true,
|
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(
|
return AppLocalizations.of(
|
||||||
@@ -294,25 +307,15 @@ void validateAndAddBeneficiary() async {
|
|||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// Confirm Account Number
|
// Confirm Account Number
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
key: _confirmAccountNumberFieldKey,
|
||||||
controller: confirmAccountNumberController,
|
controller: confirmAccountNumberController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(
|
labelText: AppLocalizations.of(
|
||||||
context,
|
context,
|
||||||
).confirmAccountNumber,
|
).confirmAccountNumber,
|
||||||
// prefixIcon: Icon(Icons.person),
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
@@ -331,37 +334,30 @@ void validateAndAddBeneficiary() async {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 🔹 IFSC Code Field
|
|
||||||
TextFormField(
|
TextFormField(
|
||||||
|
focusNode: _ifscFocusNode,
|
||||||
|
key: _ifscFieldKey,
|
||||||
controller: ifscController,
|
controller: ifscController,
|
||||||
|
maxLength: 11,
|
||||||
|
inputFormatters: [
|
||||||
|
LengthLimitingTextInputFormatter(11),
|
||||||
|
],
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).ifscCode,
|
labelText: AppLocalizations.of(context).ifscCode,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
textCapitalization: TextCapitalization.characters,
|
textCapitalization: TextCapitalization.characters,
|
||||||
textInputAction: TextInputAction.next,
|
textInputAction: TextInputAction.next,
|
||||||
onFieldSubmitted: (_) {
|
|
||||||
_validateIFSC();
|
|
||||||
},
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
final trimmed = value.trim().toUpperCase();
|
setState(() {
|
||||||
if (trimmed.length < 11) {
|
final trimmed = value.trim().toUpperCase();
|
||||||
// clear bank/branch if backspace or changed
|
if (trimmed.length < 11) {
|
||||||
bankNameController.clear();
|
// clear bank/branch if backspace or changed
|
||||||
branchNameController.clear();
|
bankNameController.clear();
|
||||||
}
|
branchNameController.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
final pattern = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$');
|
final pattern = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$');
|
||||||
@@ -377,9 +373,8 @@ void validateAndAddBeneficiary() async {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 🔹 Bank Name (Disabled)
|
// Bank Name (Disabled)
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: bankNameController,
|
controller: bankNameController,
|
||||||
enabled: false, // changed from readOnly to disabled
|
enabled: false, // changed from readOnly to disabled
|
||||||
@@ -387,20 +382,8 @@ void validateAndAddBeneficiary() async {
|
|||||||
labelText: AppLocalizations.of(context).bankName,
|
labelText: AppLocalizations.of(context).bankName,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).dialogBackgroundColor, // disabled color
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 🔹 Branch Name (Disabled)
|
// 🔹 Branch Name (Disabled)
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -410,73 +393,79 @@ void validateAndAddBeneficiary() async {
|
|||||||
labelText: AppLocalizations.of(context).branchName,
|
labelText: AppLocalizations.of(context).branchName,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
),
|
||||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
),
|
||||||
enabledBorder: const OutlineInputBorder(
|
if (_isBeneficiaryValidated)
|
||||||
borderSide: BorderSide(color: Colors.black),
|
Column(
|
||||||
),
|
children: [
|
||||||
focusedBorder: const OutlineInputBorder(
|
const SizedBox(height: 24),
|
||||||
borderSide: BorderSide(
|
TextFormField(
|
||||||
color: Colors.black,
|
controller: nameController,
|
||||||
width: 2,
|
enabled: false,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
suffixIcon: _isBeneficiaryValidated
|
||||||
|
? const Icon(
|
||||||
|
Symbols.verified,
|
||||||
|
size: 25,
|
||||||
|
fill: 1,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
suffixIconColor:
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
labelText: AppLocalizations.of(context)
|
||||||
|
.beneficiaryName,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
validator: (value) => value == null ||
|
||||||
|
value.isEmpty
|
||||||
|
? AppLocalizations.of(context).nameRequired
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
if (!_isBeneficiaryValidated)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 24),
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: _isValidating ||
|
||||||
|
ifscController.text.length != 11
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
|
final isAccountValid =
|
||||||
|
_accountNumberFieldKey.currentState!
|
||||||
|
.validate();
|
||||||
|
final isConfirmAccountValid =
|
||||||
|
_confirmAccountNumberFieldKey
|
||||||
|
.currentState!
|
||||||
|
.validate();
|
||||||
|
final isIfscValid = _ifscFieldKey
|
||||||
|
.currentState!
|
||||||
|
.validate();
|
||||||
|
|
||||||
|
if (isAccountValid &&
|
||||||
|
isConfirmAccountValid &&
|
||||||
|
isIfscValid) {
|
||||||
|
_validateBeneficiary();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: _isValidating
|
||||||
|
? const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2),
|
||||||
|
)
|
||||||
|
: Text(AppLocalizations.of(context)
|
||||||
|
.validateBeneficiary),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
//Validate Beneficiary Name
|
|
||||||
if (!_isBeneficiaryValidated)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 12.0),
|
|
||||||
child: SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: _isValidating
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
if (
|
|
||||||
confirmAccountNumberController.text ==
|
|
||||||
accountNumberController.text) {
|
|
||||||
_validateBeneficiary();
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_validationError =
|
|
||||||
'Please enter a valid and matching account number.';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: _isValidating
|
|
||||||
? const SizedBox(
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
)
|
|
||||||
: const Text('Validate Beneficiary'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
//Beneficiary Name (Disabled)
|
//Beneficiary Name (Disabled)
|
||||||
TextFormField(
|
|
||||||
controller: nameController,
|
|
||||||
enabled: false,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: AppLocalizations.of(context).beneficiaryName,
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
isDense: true,
|
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
textInputAction: TextInputAction.next,
|
|
||||||
validator: (value) => value == null || value.isEmpty
|
|
||||||
? AppLocalizations.of(context).nameRequired
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
// 🔹 Account Type Dropdown
|
// 🔹 Account Type Dropdown
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
value: accountType,
|
value: accountType,
|
||||||
@@ -484,30 +473,18 @@ if (!_isBeneficiaryValidated)
|
|||||||
labelText: AppLocalizations.of(context).accountType,
|
labelText: AppLocalizations.of(context).accountType,
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
items:
|
items: [
|
||||||
[
|
'Savings',
|
||||||
AppLocalizations.of(context).savings,
|
'Current',
|
||||||
AppLocalizations.of(context).current,
|
]
|
||||||
]
|
.map(
|
||||||
.map(
|
(type) => DropdownMenuItem(
|
||||||
(type) => DropdownMenuItem(
|
value: type,
|
||||||
value: type,
|
child: Text(type),
|
||||||
child: Text(type),
|
),
|
||||||
),
|
)
|
||||||
)
|
.toList(),
|
||||||
.toList(),
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
setState(() {
|
setState(() {
|
||||||
accountType = value!;
|
accountType = value!;
|
||||||
@@ -524,23 +501,12 @@ if (!_isBeneficiaryValidated)
|
|||||||
prefixIcon: const Icon(Icons.phone),
|
prefixIcon: const Icon(Icons.phone),
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
|
||||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
enabledBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Colors.black),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
validator: (value) =>
|
validator: (value) =>
|
||||||
value == null || value.length != 10
|
value == null || value.length != 10
|
||||||
? AppLocalizations.of(context).enterValidPhone
|
? AppLocalizations.of(context).enterValidPhone
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 35),
|
const SizedBox(height: 35),
|
||||||
],
|
],
|
||||||
@@ -549,19 +515,22 @@ if (!_isBeneficiaryValidated)
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 250,
|
width: 250,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed:
|
onPressed: validateAndAddBeneficiary,
|
||||||
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: Theme.of(context).primaryColorDark,
|
backgroundColor:
|
||||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
Theme.of(context).colorScheme.primaryContainer,
|
||||||
|
foregroundColor:
|
||||||
|
Theme.of(context).colorScheme.onPrimaryContainer),
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).validateAndAdd,
|
||||||
|
style: const TextStyle(fontSize: 16),
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).validateAndAdd),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
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: () {
|
||||||
|
_deleteBeneficiary(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(AppLocalizations.of(context).beneficiarydetails),
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 24,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
child: getBankLogo(beneficiary.bankName, context),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Text(
|
||||||
|
beneficiary.name,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
_buildDetailRow('${AppLocalizations.of(context).bankName} ',
|
||||||
|
beneficiary.bankName ?? 'N/A'),
|
||||||
|
_buildDetailRow('${AppLocalizations.of(context).accountNumber} ',
|
||||||
|
beneficiary.accountNo),
|
||||||
|
_buildDetailRow('${AppLocalizations.of(context).accountType} ',
|
||||||
|
beneficiary.accountType),
|
||||||
|
_buildDetailRow('${AppLocalizations.of(context).ifscCode} ',
|
||||||
|
beneficiary.ifscCode),
|
||||||
|
_buildDetailRow('${AppLocalizations.of(context).branchName} ',
|
||||||
|
beneficiary.branchName ?? 'N/A'),
|
||||||
|
const Spacer(),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: [
|
||||||
|
// ElevatedButton.icon(
|
||||||
|
// onPressed: () {
|
||||||
|
// // Set Transaction Limit for this beneficiary
|
||||||
|
// },
|
||||||
|
// icon: const Icon(Icons.currency_rupee),
|
||||||
|
// label: const Text('Set Limit'),
|
||||||
|
// ),
|
||||||
|
ElevatedButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
// Delete beneficiary option
|
||||||
|
_showDeleteConfirmationDialog(context);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.delete),
|
||||||
|
label: Text(AppLocalizations.of(context).delete),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDetailRow(String label, String value) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(label, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
value,
|
||||||
|
textAlign: TextAlign.end,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,8 +35,8 @@ class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final successAnimation = 'assets/animations/done.json';
|
const successAnimation = 'assets/animations/done.json';
|
||||||
final errorAnimation = 'assets/animations/error.json';
|
const errorAnimation = 'assets/animations/error.json';
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: widget.isSuccess ? Colors.green[50] : Colors.red[50],
|
backgroundColor: widget.isSuccess ? Colors.green[50] : Colors.red[50],
|
||||||
@@ -66,34 +66,38 @@ class _BeneficiaryResultPageState extends State<BeneficiaryResultPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 20, // keep it slightly above the very bottom
|
bottom: 20, // keep it slightly above the very bottom
|
||||||
left: 16,
|
left: 16,
|
||||||
right: 16,
|
right: 16,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 56, // larger button height
|
height: 56, // larger button height
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushReplacement( // ensures back goes to ScaffoldScreen
|
Navigator.pushReplacement(
|
||||||
context,
|
// ensures back goes to ScaffoldScreen
|
||||||
MaterialPageRoute(
|
context,
|
||||||
builder: (context) => const NavigationScaffold(),
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const NavigationScaffold(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
shape: const StadiumBorder(),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
backgroundColor: Theme.of(context).primaryColorDark,
|
||||||
|
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context).done,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onPrimaryContainer), // slightly bigger text
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
|
||||||
},
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
shape: const StadiumBorder(),
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
||||||
backgroundColor: Theme.of(context).primaryColorDark,
|
|
||||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
AppLocalizations.of(context).done,
|
|
||||||
style: const TextStyle(fontSize: 18), // slightly bigger text
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.isSuccess)
|
if (widget.isSuccess)
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
@@ -112,4 +116,4 @@ Positioned(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kmobile/data/models/beneficiary.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 '../../../data/models/user.dart';
|
import 'package:kmobile/features/beneficiaries/screens/beneficiary_details_screen.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import '../../../di/injection.dart';
|
import '../../../di/injection.dart';
|
||||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
import 'package:shimmer/shimmer.dart';
|
import 'package:shimmer/shimmer.dart';
|
||||||
//import 'package:kmobile/data/models/user.dart';
|
import 'package:kmobile/widgets/bank_logos.dart';
|
||||||
|
|
||||||
class ManageBeneficiariesScreen extends StatefulWidget {
|
class ManageBeneficiariesScreen extends StatefulWidget {
|
||||||
// final List<User> users;
|
final String customerName;
|
||||||
// final int selectedIndex;
|
const ManageBeneficiariesScreen({super.key, required this.customerName});
|
||||||
|
|
||||||
const ManageBeneficiariesScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ManageBeneficiariesScreen> createState() =>
|
State<ManageBeneficiariesScreen> createState() =>
|
||||||
@@ -21,12 +19,8 @@ class ManageBeneficiariesScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||||
var service = getIt<BeneficiaryService>();
|
var service = getIt<BeneficiaryService>();
|
||||||
// late User selectedUser = widget.users[widget.selectedIndex];
|
|
||||||
//final BeneficiaryService _service = BeneficiaryService();
|
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
int selectedAccountIndex = 0;
|
|
||||||
List<Beneficiary> _beneficiaries = [];
|
List<Beneficiary> _beneficiaries = [];
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -37,7 +31,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
Future<void> _loadBeneficiaries() async {
|
Future<void> _loadBeneficiaries() async {
|
||||||
final data = await service.fetchBeneficiaryList();
|
final data = await service.fetchBeneficiaryList();
|
||||||
setState(() {
|
setState(() {
|
||||||
_beneficiaries = data ;
|
_beneficiaries = data;
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -70,7 +64,8 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
|
|
||||||
Widget _buildBeneficiaryList() {
|
Widget _buildBeneficiaryList() {
|
||||||
if (_beneficiaries.isEmpty) {
|
if (_beneficiaries.isEmpty) {
|
||||||
return Center(child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
return Center(
|
||||||
|
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||||
}
|
}
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
itemCount: _beneficiaries.length,
|
itemCount: _beneficiaries.length,
|
||||||
@@ -79,16 +74,29 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
return ListTile(
|
return ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
radius: 24,
|
radius: 24,
|
||||||
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
backgroundColor: Colors.transparent,
|
||||||
child: Text(
|
child: getBankLogo(item.bankName, context),
|
||||||
item.name.isNotEmpty
|
|
||||||
? item.name[0].toUpperCase()
|
|
||||||
: '?',
|
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
title: Text(item.name ?? 'Unknown'),
|
title: Text(item.name),
|
||||||
subtitle: Text(item.accountNo ?? 'No account number'),
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(item.accountNo),
|
||||||
|
if (item.bankName != null && item.bankName!.isNotEmpty)
|
||||||
|
Text(
|
||||||
|
item.bankName!,
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => BeneficiaryDetailsScreen(beneficiary: item),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -96,6 +104,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
String customerName = widget.customerName;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(AppLocalizations.of(context).beneficiaries),
|
title: Text(AppLocalizations.of(context).beneficiaries),
|
||||||
@@ -108,16 +117,15 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AddBeneficiaryScreen(),
|
builder: (context) =>
|
||||||
|
AddBeneficiaryScreen(customerName: customerName),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
foregroundColor: Theme.of(context).primaryColor,
|
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
|
||||||
|
|
||||||
class BlockCardScreen extends StatefulWidget {
|
class BlockCardScreen extends StatefulWidget {
|
||||||
const BlockCardScreen({super.key});
|
const BlockCardScreen({super.key});
|
||||||
@@ -56,32 +54,12 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
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).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: [
|
|
||||||
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(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
@@ -94,14 +72,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: Theme.of(context).scaffoldBackgroundColor,
|
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 +97,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: Theme.of(context).scaffoldBackgroundColor,
|
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 +124,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: Theme.of(context).scaffoldBackgroundColor,
|
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 +148,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: Theme.of(context).scaffoldBackgroundColor,
|
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),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -199,7 +177,8 @@ class _BlockCardScreen extends State<BlockCardScreen> {
|
|||||||
shape: const StadiumBorder(),
|
shape: const StadiumBorder(),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||