Compare commits
6 Commits
5c8df8ace3
...
security
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a314ee2bd | |||
| 2743f92283 | |||
| 72a9d5711a | |||
| 1edb2804f1 | |||
| c9c52b39fa | |||
| 7a0265ad8d |
@@ -2,6 +2,8 @@
|
|||||||
<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}"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
BIN
flutter_01.png
BIN
flutter_01.png
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
@@ -141,25 +141,4 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future setTncflag() async{
|
|
||||||
try {
|
|
||||||
final response = await _dio.post(
|
|
||||||
'/api/auth/tnc',
|
|
||||||
data: {"flag": 'Y'},
|
|
||||||
);
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
throw AuthException('Failed to proceed with T&C');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
on DioException catch (e) {
|
|
||||||
if (kDebugMode) {
|
|
||||||
print(e.toString());
|
|
||||||
}
|
|
||||||
throw NetworkException('Network error during T&C Setup');
|
|
||||||
} catch (e) {
|
|
||||||
throw UnexpectedException(
|
|
||||||
'Unexpected error: ${e.toString()}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -67,21 +67,4 @@ class ChangePasswordService {
|
|||||||
}
|
}
|
||||||
return response.toString();
|
return response.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future validateChangeTpin({
|
|
||||||
required String oldTpin,
|
|
||||||
required String newTpin,
|
|
||||||
}) async {
|
|
||||||
final response = await _dio.post(
|
|
||||||
'/api/auth/change/tpin',
|
|
||||||
data: {
|
|
||||||
'oldTpin': oldTpin,
|
|
||||||
'newTpin': newTpin,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (response.statusCode != 200) {
|
|
||||||
throw Exception("Wrong OTP");
|
|
||||||
}
|
|
||||||
return response.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
// ignore_for_file: collection_methods_unrelated_type
|
|
||||||
import 'dart:developer';
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
|
|
||||||
class Limit {
|
|
||||||
final double dailyLimit;
|
|
||||||
final double usedLimit;
|
|
||||||
|
|
||||||
Limit({
|
|
||||||
required this.dailyLimit,
|
|
||||||
required this.usedLimit,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Limit.fromJson(Map<String, dynamic> json) {
|
|
||||||
return Limit(
|
|
||||||
dailyLimit: json['dailyLimit']!,
|
|
||||||
usedLimit: json['usedLimit']!,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class LimitService {
|
|
||||||
final Dio _dio;
|
|
||||||
LimitService(this._dio);
|
|
||||||
|
|
||||||
Future<Limit> getLimit() async {
|
|
||||||
try {
|
|
||||||
final response = await _dio.get('/api/customer/daily-limit');
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
log('Response: ${response.data}');
|
|
||||||
return Limit.fromJson(response.data);
|
|
||||||
} else {
|
|
||||||
throw Exception('Failed to load');
|
|
||||||
}
|
|
||||||
} on DioException catch (e) {
|
|
||||||
throw Exception('Network error: ${e.message}');
|
|
||||||
} catch (e) {
|
|
||||||
throw Exception('Unexpected error: ${e.toString()}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void editLimit( double newLimit) async {
|
|
||||||
try {
|
|
||||||
final response = await _dio.post('/api/customer/daily-limit',
|
|
||||||
data: '{"amount": $newLimit}');
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
log('Response: ${response.data}');
|
|
||||||
} else {
|
|
||||||
throw Exception('Failed to load');
|
|
||||||
}
|
|
||||||
} on DioException catch (e) {
|
|
||||||
throw Exception('Network error: ${e.message}');
|
|
||||||
} catch (e) {
|
|
||||||
throw Exception('Unexpected error: ${e.toString()}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
129
lib/api/services/send_sms_service.dart
Normal file
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ class UserService {
|
|||||||
|
|
||||||
Future<List<User>> getUserDetails() async {
|
Future<List<User>> getUserDetails() async {
|
||||||
try {
|
try {
|
||||||
final response = await _dio.get('/api/customer');
|
final response = await _dio.get('/api/customer/details');
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
log('Response: ${response.data}');
|
log('Response: ${response.data}');
|
||||||
return (response.data as List)
|
return (response.data as List)
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import '../features/dashboard/screens/dashboard_screen.dart';
|
|||||||
// import '../features/transactions/screens/transactions_screen.dart';
|
// import '../features/transactions/screens/transactions_screen.dart';
|
||||||
// import '../features/payments/screens/payments_screen.dart';
|
// import '../features/payments/screens/payments_screen.dart';
|
||||||
// import '../features/settings/screens/settings_screen.dart';
|
// import '../features/settings/screens/settings_screen.dart';
|
||||||
import 'package:kmobile/features/auth/screens/tnc_required_screen.dart';
|
|
||||||
|
|
||||||
class AppRoutes {
|
class AppRoutes {
|
||||||
// Private constructor to prevent instantiation
|
// Private constructor to prevent instantiation
|
||||||
@@ -35,8 +34,7 @@ class AppRoutes {
|
|||||||
return MaterialPageRoute(builder: (_) => const SplashScreen());
|
return MaterialPageRoute(builder: (_) => const SplashScreen());
|
||||||
case login:
|
case login:
|
||||||
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
return MaterialPageRoute(builder: (_) => const LoginScreen());
|
||||||
case TncRequiredScreen.routeName: // Renamed class
|
|
||||||
return MaterialPageRoute(builder: (_) => const TncRequiredScreen()); // Renamed class
|
|
||||||
case mPin:
|
case mPin:
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => const MPinScreen(
|
builder: (_) => const MPinScreen(
|
||||||
|
|||||||
15
lib/core/logger.dart
Normal file
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
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,11 +13,10 @@ class AuthRepository {
|
|||||||
|
|
||||||
static const _accessTokenKey = 'access_token';
|
static const _accessTokenKey = 'access_token';
|
||||||
static const _tokenExpiryKey = 'token_expiry';
|
static const _tokenExpiryKey = 'token_expiry';
|
||||||
static const _tncKey = 'tnc';
|
|
||||||
|
|
||||||
AuthRepository(this._authService, this._userService, this._secureStorage);
|
AuthRepository(this._authService, this._userService, this._secureStorage);
|
||||||
|
|
||||||
Future<(List<User>, AuthToken)> 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 =
|
final credentials =
|
||||||
AuthCredentials(customerNo: customerNo, password: password);
|
AuthCredentials(customerNo: customerNo, password: password);
|
||||||
@@ -28,7 +27,7 @@ class AuthRepository {
|
|||||||
|
|
||||||
// Get and save user profile
|
// Get and save user profile
|
||||||
final users = await _userService.getUserDetails();
|
final users = await _userService.getUserDetails();
|
||||||
return (users, authToken);
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isLoggedIn() async {
|
Future<bool> isLoggedIn() async {
|
||||||
@@ -48,7 +47,6 @@ class AuthRepository {
|
|||||||
await _secureStorage.write(_accessTokenKey, token.accessToken);
|
await _secureStorage.write(_accessTokenKey, token.accessToken);
|
||||||
await _secureStorage.write(
|
await _secureStorage.write(
|
||||||
_tokenExpiryKey, token.expiresAt.toIso8601String());
|
_tokenExpiryKey, token.expiresAt.toIso8601String());
|
||||||
await _secureStorage.write(_tncKey, token.tnc.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clearAuthTokens() async {
|
Future<void> clearAuthTokens() async {
|
||||||
@@ -58,27 +56,13 @@ class AuthRepository {
|
|||||||
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);
|
||||||
final tncString = await _secureStorage.read(_tncKey);
|
|
||||||
|
|
||||||
if (accessToken != null && expiryString != null) {
|
if (accessToken != null && expiryString != null) {
|
||||||
final authToken = AuthToken(
|
return AuthToken(
|
||||||
accessToken: accessToken,
|
accessToken: accessToken,
|
||||||
expiresAt: DateTime.parse(expiryString),
|
expiresAt: DateTime.parse(expiryString),
|
||||||
tnc: tncString == 'true', // Parse 'true' string to true, otherwise false
|
|
||||||
);
|
);
|
||||||
return authToken;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> acceptTnc() async {
|
|
||||||
// This method calls the setTncFlag function
|
|
||||||
try {
|
|
||||||
await _authService.setTncflag();
|
|
||||||
} catch (e) {
|
|
||||||
// Handle or rethrow the error as needed
|
|
||||||
print('Error setting TNC flag: $e');
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:kmobile/api/services/limit_service.dart';
|
|
||||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
import 'package:kmobile/api/services/imps_service.dart';
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
@@ -47,7 +46,6 @@ 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<LimitService>(LimitService(getIt<Dio>()));
|
|
||||||
getIt.registerSingleton<NeftService>(NeftService(getIt<Dio>()));
|
getIt.registerSingleton<NeftService>(NeftService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<RtgsService>(RtgsService(getIt<Dio>()));
|
getIt.registerSingleton<RtgsService>(RtgsService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<ImpsService>(ImpsService(getIt<Dio>()));
|
getIt.registerSingleton<ImpsService>(ImpsService(getIt<Dio>()));
|
||||||
@@ -62,22 +60,21 @@ Future<void> setupDependencies() async {
|
|||||||
|
|
||||||
// Register controllers/cubits
|
// Register controllers/cubits
|
||||||
getIt.registerFactory<AuthCubit>(
|
getIt.registerFactory<AuthCubit>(
|
||||||
() => AuthCubit(getIt<AuthRepository>(), getIt<UserService>(), getIt<SecureStorage>()));
|
() => 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', //test
|
'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com:8080', //test
|
||||||
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
|
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
|
||||||
//'https://kccbmbnk.net', //prod small
|
//'https://kccbmbnk.net',
|
||||||
connectTimeout: const Duration(seconds: 60),
|
connectTimeout: const Duration(seconds: 60),
|
||||||
receiveTimeout: 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',
|
||||||
'X-Login-Type': 'MB',
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,20 +1,14 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:kmobile/api/services/user_service.dart';
|
import 'package:kmobile/api/services/user_service.dart';
|
||||||
import 'package:kmobile/core/errors/exceptions.dart';
|
import 'package:kmobile/core/errors/exceptions.dart';
|
||||||
import 'package:kmobile/data/models/user.dart';
|
|
||||||
import 'package:kmobile/features/auth/models/auth_token.dart';
|
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
|
||||||
import '../../../data/repositories/auth_repository.dart';
|
import '../../../data/repositories/auth_repository.dart';
|
||||||
import 'auth_state.dart';
|
import 'auth_state.dart';
|
||||||
|
|
||||||
class AuthCubit extends Cubit<AuthState> {
|
class AuthCubit extends Cubit<AuthState> {
|
||||||
final AuthRepository _authRepository;
|
final AuthRepository _authRepository;
|
||||||
final UserService _userService;
|
final UserService _userService;
|
||||||
final SecureStorage _secureStorage;
|
|
||||||
|
|
||||||
AuthCubit(this._authRepository, this._userService, this._secureStorage)
|
AuthCubit(this._authRepository, this._userService) : super(AuthInitial()) {
|
||||||
: super(AuthInitial()) {
|
|
||||||
checkAuthStatus();
|
checkAuthStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,64 +29,22 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
|
|
||||||
Future<void> refreshUserData() async {
|
Future<void> refreshUserData() async {
|
||||||
try {
|
try {
|
||||||
|
// emit(AuthLoading());
|
||||||
final users = await _userService.getUserDetails();
|
final users = await _userService.getUserDetails();
|
||||||
emit(Authenticated(users));
|
emit(Authenticated(users));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(AuthError('Failed to refresh user data: ${e.toString()}'));
|
emit(AuthError('Failed to refresh user data: ${e.toString()}'));
|
||||||
|
// Optionally, re-emit the previous state or handle as needed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> login(String customerNo, String password) async {
|
Future<void> login(String customerNo, String password) async {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
try {
|
try {
|
||||||
final (users, authToken) = await _authRepository.login(customerNo, password);
|
final users = await _authRepository.login(customerNo, password);
|
||||||
|
emit(Authenticated(users));
|
||||||
if (authToken.tnc == false) {
|
} catch (e) {
|
||||||
emit(ShowTncDialog(authToken, users));
|
emit(AuthError(e is AuthException ? e.message : e.toString()));
|
||||||
} else {
|
}
|
||||||
await _checkMpinAndNavigate(users);
|
}
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
emit(AuthError(e is AuthException ? e.message : e.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> onTncDialogResult(
|
|
||||||
bool agreed, AuthToken authToken, List<User> users) async {
|
|
||||||
if (agreed) {
|
|
||||||
try {
|
|
||||||
await _authRepository.acceptTnc();
|
|
||||||
// The user is NOT fully authenticated yet. Just check for MPIN.
|
|
||||||
await _checkMpinAndNavigate(users);
|
|
||||||
} catch (e) {
|
|
||||||
emit(AuthError('Failed to accept TNC: $e'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
emit(NavigateToTncRequiredScreen());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mpinSetupCompleted() {
|
|
||||||
if (state is NavigateToMpinSetupScreen) {
|
|
||||||
final users = (state as NavigateToMpinSetupScreen).users;
|
|
||||||
emit(Authenticated(users));
|
|
||||||
} else {
|
|
||||||
// Handle unexpected state if necessary
|
|
||||||
emit(AuthError("Invalid state during MPIN setup completion."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _checkMpinAndNavigate(List<User> users) async {
|
|
||||||
final mpin = await _secureStorage.read('mpin');
|
|
||||||
if (mpin == null) {
|
|
||||||
// No MPIN, tell UI to navigate to MPIN setup, carrying user data
|
|
||||||
emit(NavigateToMpinSetupScreen(users));
|
|
||||||
} else {
|
|
||||||
// MPIN exists, user is authenticated
|
|
||||||
emit(Authenticated(users));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:kmobile/data/models/user.dart';
|
import '../../../data/models/user.dart';
|
||||||
import 'package:kmobile/features/auth/models/auth_token.dart';
|
|
||||||
|
|
||||||
abstract class AuthState extends Equatable {
|
abstract class AuthState extends Equatable {
|
||||||
const AuthState();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object?> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthInitial extends AuthState {}
|
class AuthInitial extends AuthState {}
|
||||||
@@ -15,44 +12,20 @@ class AuthLoading extends AuthState {}
|
|||||||
|
|
||||||
class Authenticated extends AuthState {
|
class Authenticated extends AuthState {
|
||||||
final List<User> users;
|
final List<User> users;
|
||||||
const Authenticated(this.users);
|
|
||||||
|
Authenticated(this.users);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [users];
|
List<Object?> get props => [users];
|
||||||
}
|
}
|
||||||
|
|
||||||
class Unauthenticated extends AuthState {}
|
class Unauthenticated extends AuthState {}
|
||||||
|
|
||||||
class AuthError extends AuthState {
|
class AuthError extends AuthState {
|
||||||
final String message;
|
final String message;
|
||||||
const AuthError(this.message);
|
|
||||||
|
AuthError(this.message);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [message];
|
List<Object?> get props => [message];
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- New States for Navigation and Dialog ---
|
|
||||||
|
|
||||||
// State to indicate that the TNC dialog needs to be shown
|
|
||||||
class ShowTncDialog extends AuthState {
|
|
||||||
final AuthToken authToken;
|
|
||||||
final List<User> users;
|
|
||||||
const ShowTncDialog(this.authToken, this.users);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [authToken, users];
|
|
||||||
}
|
|
||||||
|
|
||||||
// States to trigger specific navigations from the UI
|
|
||||||
class NavigateToTncRequiredScreen extends AuthState {}
|
|
||||||
|
|
||||||
class NavigateToMpinSetupScreen extends AuthState {
|
|
||||||
final List<User> users;
|
|
||||||
|
|
||||||
const NavigateToMpinSetupScreen(this.users);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [users];
|
|
||||||
}
|
|
||||||
|
|
||||||
class NavigateToDashboardScreen extends AuthState {}
|
|
||||||
@@ -6,22 +6,18 @@ 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;
|
||||||
final bool tnc;
|
|
||||||
|
|
||||||
const AuthToken({
|
const AuthToken({
|
||||||
required this.accessToken,
|
required this.accessToken,
|
||||||
required this.expiresAt,
|
required this.expiresAt,
|
||||||
required this.tnc,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
factory AuthToken.fromJson(Map<String, dynamic> json) {
|
factory AuthToken.fromJson(Map<String, dynamic> json) {
|
||||||
final token = json['token'];
|
return AuthToken(
|
||||||
return AuthToken(
|
accessToken: json['token'],
|
||||||
accessToken: token,
|
expiresAt: _decodeExpiryFromToken(json['token']),
|
||||||
expiresAt: _decodeExpiryFromToken(token), // Keep existing method for expiry
|
);
|
||||||
tnc: _decodeTncFromToken(token), // Use new method for tnc
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DateTime _decodeExpiryFromToken(String token) {
|
static DateTime _decodeExpiryFromToken(String token) {
|
||||||
try {
|
try {
|
||||||
@@ -46,45 +42,8 @@ class AuthToken extends Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _decodeTncFromToken(String token) {
|
|
||||||
try {
|
|
||||||
final parts = token.split('.');
|
|
||||||
if (parts.length != 3) {
|
|
||||||
throw Exception('Invalid JWT format for TNC decoding');
|
|
||||||
}
|
|
||||||
final payload = parts[1];
|
|
||||||
String normalized = base64Url.normalize(payload);
|
|
||||||
final payloadMap = json.decode(utf8.decode(base64Url.decode(normalized)));
|
|
||||||
|
|
||||||
if (payloadMap is! Map<String, dynamic> || !payloadMap.containsKey('tnc')) {
|
|
||||||
// If 'tnc' is not present in the payload, default to false
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final tncValue = payloadMap['tnc'];
|
|
||||||
|
|
||||||
// Handle different representations of 'true'
|
|
||||||
if (tncValue is bool) {
|
|
||||||
return tncValue;
|
|
||||||
}
|
|
||||||
if (tncValue is String) {
|
|
||||||
return tncValue.toLowerCase() == 'true';
|
|
||||||
}
|
|
||||||
if (tncValue is int) {
|
|
||||||
return tncValue == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default to false for any other case
|
|
||||||
return false;
|
|
||||||
} catch (e) {
|
|
||||||
log('Error decoding tnc from token: $e');
|
|
||||||
// Default to false if decoding fails or 'tnc' is not found/invalid
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
bool get isExpired => DateTime.now().isAfter(expiresAt);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [accessToken, expiresAt, tnc];
|
List<Object> get props => [accessToken, expiresAt];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:kmobile/app.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/features/auth/screens/set_password_screen.dart';
|
||||||
import 'package:kmobile/features/auth/screens/tnc_required_screen.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import 'package:kmobile/widgets/tnc_dialog.dart';
|
import '../../../app.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import '../controllers/auth_cubit.dart';
|
import '../controllers/auth_cubit.dart';
|
||||||
import '../controllers/auth_state.dart';
|
import '../controllers/auth_state.dart';
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
final _customerNumberController = TextEditingController();
|
final _customerNumberController = TextEditingController();
|
||||||
final _passwordController = TextEditingController();
|
final _passwordController = TextEditingController();
|
||||||
bool _obscurePassword = true;
|
bool _obscurePassword = true;
|
||||||
|
//bool _showWelcome = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@@ -41,237 +43,37 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// return Scaffold(
|
return Scaffold(
|
||||||
// body: BlocConsumer<AuthCubit, AuthState>(
|
// appBar: AppBar(title: const Text('Login')),
|
||||||
// listener: (context, state) async {
|
|
||||||
// if (state is ShowTncDialog) {
|
|
||||||
// // The dialog now returns a boolean for the 'disagree' case,
|
|
||||||
// // or it completes when the 'proceed' action is finished.
|
|
||||||
// final agreed = await showDialog<bool>(
|
|
||||||
// context: context,
|
|
||||||
// barrierDismissible: false,
|
|
||||||
// builder: (dialogContext) => TncDialog(
|
|
||||||
// onProceed: () async {
|
|
||||||
// // This function is passed to the dialog.
|
|
||||||
// // It calls the cubit and completes when the cubit's work is done.
|
|
||||||
// await context
|
|
||||||
// .read<AuthCubit>()
|
|
||||||
// .onTncDialogResult(true, state.authToken, state.users);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
|
|
||||||
// // If 'agreed' is false, it means the user clicked 'Disagree'.
|
|
||||||
// if (agreed == false) {
|
|
||||||
// if (!context.mounted) return;
|
|
||||||
// context
|
|
||||||
// .read<AuthCubit>()
|
|
||||||
// .onTncDialogResult(false, state.authToken, state.users);
|
|
||||||
// }
|
|
||||||
// } else if (state is NavigateToTncRequiredScreen) {
|
|
||||||
// Navigator.of(context).pushNamed(TncRequiredScreen.routeName);
|
|
||||||
// } else if (state is NavigateToMpinSetupScreen) {
|
|
||||||
// Navigator.of(context).push( // Use push, NOT pushReplacement
|
|
||||||
// MaterialPageRoute(
|
|
||||||
// builder: (_) => MPinScreen(
|
|
||||||
// mode: MPinMode.set,
|
|
||||||
// onCompleted: (_) {
|
|
||||||
// // This clears the entire stack and pushes the dashboard
|
|
||||||
// Navigator.of(context, rootNavigator: true).pushAndRemoveUntil(
|
|
||||||
// MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
|
||||||
// (route) => false,
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// } else if (state is NavigateToDashboardScreen) {
|
|
||||||
// Navigator.of(context).pushReplacement(
|
|
||||||
// MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
|
||||||
// );
|
|
||||||
// } else if (state is AuthError) {
|
|
||||||
// if (state.message == 'MIGRATED_USER_HAS_NO_PASSWORD') {
|
|
||||||
// Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
// builder: (_) => SetPasswordScreen(
|
|
||||||
// customerNo: _customerNumberController.text.trim(),
|
|
||||||
// )));
|
|
||||||
// } else {
|
|
||||||
// ScaffoldMessenger.of(context)
|
|
||||||
// .showSnackBar(SnackBar(content: Text(state.message)));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// builder: (context, state) {
|
|
||||||
// // The commented out section is removed for clarity, the logic is now above.
|
|
||||||
// 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 Icon(
|
|
||||||
// Icons.account_balance,
|
|
||||||
// size: 100,
|
|
||||||
// color: Theme.of(context).primaryColor,
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// const SizedBox(height: 16),
|
|
||||||
// Text(
|
|
||||||
// AppLocalizations.of(context).kccb,
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontSize: 32,
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// color: Theme.of(context).primaryColor,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(height: 48),
|
|
||||||
// TextFormField(
|
|
||||||
// controller: _customerNumberController,
|
|
||||||
// decoration: InputDecoration(
|
|
||||||
// labelText: AppLocalizations.of(context).customerNumber,
|
|
||||||
// border: const OutlineInputBorder(),
|
|
||||||
// isDense: true,
|
|
||||||
// filled: true,
|
|
||||||
// fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
// enabledBorder: OutlineInputBorder(
|
|
||||||
// borderSide: BorderSide(
|
|
||||||
// color: Theme.of(context).colorScheme.outline),
|
|
||||||
// ),
|
|
||||||
// focusedBorder: OutlineInputBorder(
|
|
||||||
// borderSide: BorderSide(
|
|
||||||
// color: Theme.of(context).colorScheme.primary,
|
|
||||||
// width: 2),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// keyboardType: TextInputType.number,
|
|
||||||
// textInputAction: TextInputAction.next,
|
|
||||||
// validator: (value) {
|
|
||||||
// if (value == null || value.isEmpty) {
|
|
||||||
// return AppLocalizations.of(context).pleaseEnterUsername;
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// const SizedBox(height: 24),
|
|
||||||
// TextFormField(
|
|
||||||
// controller: _passwordController,
|
|
||||||
// obscureText: _obscurePassword,
|
|
||||||
// textInputAction: TextInputAction.done,
|
|
||||||
// onFieldSubmitted: (_) => _submitForm(),
|
|
||||||
// decoration: InputDecoration(
|
|
||||||
// labelText: AppLocalizations.of(context).password,
|
|
||||||
// border: const OutlineInputBorder(),
|
|
||||||
// isDense: true,
|
|
||||||
// filled: true,
|
|
||||||
// fillColor: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
// enabledBorder: OutlineInputBorder(
|
|
||||||
// borderSide: BorderSide(
|
|
||||||
// color: Theme.of(context).colorScheme.outline),
|
|
||||||
// ),
|
|
||||||
// focusedBorder: OutlineInputBorder(
|
|
||||||
// borderSide: BorderSide(
|
|
||||||
// color: Theme.of(context).colorScheme.primary,
|
|
||||||
// width: 2),
|
|
||||||
// ),
|
|
||||||
// suffixIcon: IconButton(
|
|
||||||
// icon: Icon(
|
|
||||||
// _obscurePassword
|
|
||||||
// ? Icons.visibility
|
|
||||||
// : Icons.visibility_off,
|
|
||||||
// ),
|
|
||||||
// onPressed: () {
|
|
||||||
// setState(() {
|
|
||||||
// _obscurePassword = !_obscurePassword;
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// validator: (value) {
|
|
||||||
// if (value == null || value.isEmpty) {
|
|
||||||
// return AppLocalizations.of(context).pleaseEnterPassword;
|
|
||||||
// }
|
|
||||||
// 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:
|
|
||||||
// Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
// foregroundColor: Theme.of(context).primaryColorDark,
|
|
||||||
// side: BorderSide(
|
|
||||||
// color: Theme.of(context).colorScheme.outline,
|
|
||||||
// width: 1),
|
|
||||||
// elevation: 0,
|
|
||||||
// ),
|
|
||||||
// child: state is AuthLoading
|
|
||||||
// ? const CircularProgressIndicator()
|
|
||||||
// : Text(
|
|
||||||
// AppLocalizations.of(context).login,
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: Theme.of(context)
|
|
||||||
// .colorScheme
|
|
||||||
// .onPrimaryContainer),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(height: 25),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
return Scaffold(
|
|
||||||
body: BlocConsumer<AuthCubit, AuthState>(
|
body: BlocConsumer<AuthCubit, AuthState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) async {
|
||||||
if (state is ShowTncDialog) {
|
if (state is Authenticated) {
|
||||||
showDialog<bool>(
|
final storage = getIt<SecureStorage>();
|
||||||
context: context,
|
final mpin = await storage.read('mpin');
|
||||||
barrierDismissible: false,
|
if (!context.mounted) return;
|
||||||
builder: (dialogContext) => TncDialog(
|
if (mpin == null) {
|
||||||
onProceed: () async {
|
Navigator.of(context).pushReplacement(
|
||||||
// Pop the dialog before the cubit action
|
MaterialPageRoute(
|
||||||
Navigator.of(dialogContext).pop();
|
builder: (_) => MPinScreen(
|
||||||
await context
|
mode: MPinMode.set,
|
||||||
.read<AuthCubit>()
|
onCompleted: (_) {
|
||||||
.onTncDialogResult(true, state.authToken, state.users);
|
Navigator.of(
|
||||||
},
|
context,
|
||||||
),
|
rootNavigator: true,
|
||||||
);
|
).pushReplacement(
|
||||||
} else if (state is NavigateToTncRequiredScreen) {
|
MaterialPageRoute(
|
||||||
Navigator.of(context).pushNamed(TncRequiredScreen.routeName);
|
builder: (_) => const NavigationScaffold(),
|
||||||
} else if (state is NavigateToMpinSetupScreen) {
|
),
|
||||||
Navigator.of(context).push( // Use push, NOT pushReplacement
|
);
|
||||||
MaterialPageRoute(
|
},
|
||||||
builder: (_) => MPinScreen(
|
),
|
||||||
mode: MPinMode.set,
|
|
||||||
onCompleted: (_) {
|
|
||||||
// Call the cubit to signal MPIN setup is complete
|
|
||||||
context.read<AuthCubit>().mpinSetupCompleted();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
} else {
|
||||||
} else if (state is Authenticated) {
|
Navigator.of(context).pushReplacement(
|
||||||
// This is the single source of truth for navigating to the dashboard
|
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
||||||
Navigator.of(context, rootNavigator: true).pushAndRemoveUntil(
|
);
|
||||||
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
}
|
||||||
(route) => false,
|
|
||||||
);
|
|
||||||
} else if (state is AuthError) {
|
} else if (state is AuthError) {
|
||||||
if (state.message == 'MIGRATED_USER_HAS_NO_PASSWORD') {
|
if (state.message == 'MIGRATED_USER_HAS_NO_PASSWORD') {
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
@@ -285,7 +87,6 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
// The builder part remains largely the same, focusing on UI display
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(24.0),
|
padding: const EdgeInsets.all(24.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
@@ -306,6 +107,7 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
// Title
|
||||||
Text(
|
Text(
|
||||||
AppLocalizations.of(context).kccb,
|
AppLocalizations.of(context).kccb,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -315,10 +117,12 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 48),
|
const SizedBox(height: 48),
|
||||||
|
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _customerNumberController,
|
controller: _customerNumberController,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).customerNumber,
|
labelText: AppLocalizations.of(context).customerNumber,
|
||||||
|
// prefixIcon: Icon(Icons.person),
|
||||||
border: const OutlineInputBorder(),
|
border: const OutlineInputBorder(),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
filled: true,
|
filled: true,
|
||||||
@@ -343,6 +147,7 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
// Password
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
obscureText: _obscurePassword,
|
obscureText: _obscurePassword,
|
||||||
@@ -384,6 +189,7 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
//Login Button
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 250,
|
width: 250,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
@@ -410,7 +216,40 @@ class LoginScreenState extends State<LoginScreen>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
// child: Row(
|
||||||
|
// children: [
|
||||||
|
// const Expanded(child: Divider()),
|
||||||
|
// Padding(
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
// child: Text(AppLocalizations.of(context).or),
|
||||||
|
// ),
|
||||||
|
// //const Expanded(child: Divider()),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
|
||||||
const SizedBox(height: 25),
|
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: Theme.of(context).colorScheme.primary,
|
||||||
|
// foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
// ),
|
||||||
|
// child: Text(AppLocalizations.of(context).register,
|
||||||
|
// style: TextStyle(color: Theme.of(context).colorScheme.onPrimary),),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -185,16 +185,19 @@ class _MPinScreenState extends State<MPinScreen> with TickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case MPinMode.confirm:
|
case MPinMode.confirm:
|
||||||
if (widget.initialPin == pin) {
|
if (widget.initialPin == pin) {
|
||||||
// 1) persist the pin
|
// 1) persist the pin
|
||||||
await storage.write('mpin', pin);
|
await storage.write('mpin', pin);
|
||||||
|
|
||||||
// 2) Call the onCompleted callback to let the parent handle navigation
|
// 3) now clear the entire navigation stack and go to your main scaffold
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
widget.onCompleted?.call(pin);
|
Navigator.of(context, rootNavigator: true).pushAndRemoveUntil(
|
||||||
}
|
MaterialPageRoute(builder: (_) => const NavigationScaffold()),
|
||||||
} else {
|
(route) => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isError = true;
|
_isError = true;
|
||||||
errorText = AppLocalizations.of(context).pinsDoNotMatch;
|
errorText = AppLocalizations.of(context).pinsDoNotMatch;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
import 'package:kmobile/api/services/send_sms_service.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SplashScreen extends StatefulWidget {
|
class SplashScreen extends StatefulWidget {
|
||||||
@@ -13,12 +12,22 @@ class SplashScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _SplashScreenState extends State<SplashScreen> {
|
class _SplashScreenState extends State<SplashScreen> {
|
||||||
String _version = '';
|
String _version = '';
|
||||||
|
final SmsService _smsService = SmsService();
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadVersion();
|
_loadVersion();
|
||||||
|
_sendInitialSms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _sendInitialSms() async {
|
||||||
|
await _smsService.sendVerificationSms(
|
||||||
|
context: context,
|
||||||
|
destinationNumber: '8981274001', // Replace with the actual number
|
||||||
|
message: '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _loadVersion() async {
|
Future<void> _loadVersion() async {
|
||||||
final PackageInfo info = await PackageInfo.fromPlatform();
|
final PackageInfo info = await PackageInfo.fromPlatform();
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class TncRequiredScreen extends StatelessWidget { // Renamed class
|
|
||||||
const TncRequiredScreen({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
static const routeName = '/tnc-required';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Terms and Conditions'),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'You must accept the Terms and Conditions to use the application.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(fontSize: 18),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
// This will take the user back to the previous screen
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
child: const Text('Go Back'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -147,8 +147,6 @@ class _DashboardScreenState extends State<DashboardScreen>
|
|||||||
return AppLocalizations.of(context).termDeposit;
|
return AppLocalizations.of(context).termDeposit;
|
||||||
case 'rd':
|
case 'rd':
|
||||||
return AppLocalizations.of(context).recurringDeposit;
|
return AppLocalizations.of(context).recurringDeposit;
|
||||||
case 'ca':
|
|
||||||
return "Current Account";
|
|
||||||
default:
|
default:
|
||||||
return AppLocalizations.of(context).unknownAccount;
|
return AppLocalizations.of(context).unknownAccount;
|
||||||
}
|
}
|
||||||
@@ -268,8 +266,6 @@ class _DashboardScreenState extends State<DashboardScreen>
|
|||||||
if (state is Authenticated) {
|
if (state is Authenticated) {
|
||||||
final users = state.users;
|
final users = state.users;
|
||||||
final currAccount = users[selectedAccountIndex];
|
final currAccount = users[selectedAccountIndex];
|
||||||
final accountType = currAccount.accountType?.toLowerCase();
|
|
||||||
final isPaymentDisabled = accountType != 'sa' && accountType != 'sb' && accountType != 'ca';
|
|
||||||
// first‐time load
|
// first‐time load
|
||||||
if (!_txInitialized) {
|
if (!_txInitialized) {
|
||||||
_txInitialized = true;
|
_txInitialized = true;
|
||||||
@@ -484,36 +480,33 @@ class _DashboardScreenState extends State<DashboardScreen>
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
_buildQuickLink(
|
_buildQuickLink(
|
||||||
Symbols.currency_rupee,
|
Symbols.currency_rupee,
|
||||||
AppLocalizations.of(context).quickPay,
|
AppLocalizations.of(context).quickPay,
|
||||||
() {
|
() {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => QuickPayScreen(
|
builder: (context) => QuickPayScreen(
|
||||||
debitAccount: currAccount.accountNo!,
|
debitAccount: currAccount.accountNo!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
disable: isPaymentDisabled,
|
),
|
||||||
),
|
|
||||||
_buildQuickLink(Symbols.send_money,
|
_buildQuickLink(Symbols.send_money,
|
||||||
AppLocalizations.of(context).fundTransfer, () {
|
AppLocalizations.of(context).fundTransfer, () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => FundTransferScreen(
|
builder: (context) => FundTransferScreen(
|
||||||
creditAccountNo:
|
creditAccountNo:
|
||||||
users[selectedAccountIndex]
|
users[selectedAccountIndex]
|
||||||
.accountNo!,
|
.accountNo!,
|
||||||
remitterName:
|
remitterName:
|
||||||
users[selectedAccountIndex]
|
users[selectedAccountIndex]
|
||||||
.name!,
|
.name!)));
|
||||||
// Pass the full list of accounts
|
}, disable: false),
|
||||||
accounts: users)));
|
|
||||||
}, disable: isPaymentDisabled),
|
|
||||||
_buildQuickLink(
|
_buildQuickLink(
|
||||||
Symbols.server_person,
|
Symbols.server_person,
|
||||||
AppLocalizations.of(context).accountInfo,
|
AppLocalizations.of(context).accountInfo,
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:kmobile/api/services/limit_service.dart';
|
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
import 'package:kmobile/api/services/imps_service.dart';
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
@@ -42,67 +40,13 @@ class FundTransferAmountScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
||||||
final _limitService = getIt<LimitService>();
|
|
||||||
Limit? _limit;
|
|
||||||
bool _isLoadingLimit = true;
|
|
||||||
bool _isAmountOverLimit = false;
|
|
||||||
final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|
||||||
final _amountController = TextEditingController();
|
final _amountController = TextEditingController();
|
||||||
final _remarksController = TextEditingController();
|
final _remarksController = TextEditingController();
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
TransactionMode _selectedMode = TransactionMode.neft;
|
TransactionMode _selectedMode = TransactionMode.neft;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadLimit(); // Call the new method
|
|
||||||
_amountController.addListener(_checkAmountLimit);
|
|
||||||
}
|
|
||||||
Future<void> _loadLimit() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
final limitData = await _limitService.getLimit();
|
|
||||||
setState(() {
|
|
||||||
_limit = limitData;
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// Handle error if needed
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this method to check the amount against the limit
|
|
||||||
void _checkAmountLimit() {
|
|
||||||
if (_limit == null) return;
|
|
||||||
|
|
||||||
final amount = double.tryParse(_amountController.text) ?? 0;
|
|
||||||
final remainingLimit = _limit!.dailyLimit - _limit!.usedLimit;
|
|
||||||
final bool isOverLimit = amount > remainingLimit;
|
|
||||||
|
|
||||||
if (isOverLimit) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isAmountOverLimit != isOverLimit) {
|
|
||||||
setState(() {
|
|
||||||
_isAmountOverLimit = isOverLimit;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_amountController.removeListener(_checkAmountLimit);
|
|
||||||
_amountController.dispose();
|
_amountController.dispose();
|
||||||
_remarksController.dispose();
|
_remarksController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -486,27 +430,19 @@ void _checkAmountLimit() {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
|
||||||
if (_isLoadingLimit)
|
|
||||||
const Text('Fetching daily limit...'),
|
|
||||||
if (!_isLoadingLimit && _limit != null)
|
|
||||||
Text(
|
|
||||||
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
|
||||||
// Proceed Button
|
// Proceed Button
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: _isAmountOverLimit ? null : _onProceed,
|
onPressed: _onProceed,
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
),
|
),
|
||||||
child: Text(AppLocalizations.of(context).proceed),
|
child: Text(AppLocalizations.of(context).proceed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,126 +1,90 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
||||||
import 'package:kmobile/data/models/user.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:kmobile/features/auth/controllers/auth_cubit.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:kmobile/features/auth/controllers/auth_state.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_beneficiary_screen.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_self_accounts_screen.dart';
|
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
|
||||||
import '../../../l10n/app_localizations.dart'; // Keep localizations
|
|
||||||
|
|
||||||
class FundTransferScreen extends StatelessWidget {
|
class FundTransferScreen extends StatelessWidget {
|
||||||
final String creditAccountNo;
|
final String creditAccountNo;
|
||||||
final String remitterName;
|
final String remitterName;
|
||||||
final List<User> accounts; // Continue to accept the list of accounts
|
|
||||||
|
|
||||||
const FundTransferScreen({
|
const FundTransferScreen({
|
||||||
super.key,
|
super.key,
|
||||||
required this.creditAccountNo,
|
required this.creditAccountNo,
|
||||||
required this.remitterName,
|
required this.remitterName,
|
||||||
required this.accounts, // It is passed from the dashboard
|
});
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
// Restore localization for the title
|
title: Text(AppLocalizations.of(context)
|
||||||
title: Text(AppLocalizations.of(context)
|
.fundTransfer
|
||||||
.fundTransfer
|
.replaceFirst(RegExp('\n'), '')),
|
||||||
.replaceFirst(RegExp('\n'), '')),
|
),
|
||||||
),
|
body: ListView(
|
||||||
// Wrap with BlocBuilder to check the authentication state
|
children: [
|
||||||
body: BlocBuilder<AuthCubit, AuthState>(
|
FundTransferManagementTile(
|
||||||
builder: (context, state) {
|
icon: Symbols.input_circle,
|
||||||
return ListView(
|
label: AppLocalizations.of(context).ownBank,
|
||||||
children: [
|
onTap: () {
|
||||||
FundTransferManagementTile(
|
Navigator.push(
|
||||||
icon: Symbols.person,
|
context,
|
||||||
// Restore localization for the label
|
MaterialPageRoute(
|
||||||
label: "Self Pay",
|
builder: (context) => FundTransferBeneficiaryScreen(
|
||||||
onTap: () {
|
creditAccountNo: creditAccountNo,
|
||||||
// The accounts list is passed directly from the constructor
|
remitterName: remitterName,
|
||||||
Navigator.push(
|
isOwnBank: true,
|
||||||
context,
|
),
|
||||||
MaterialPageRoute(
|
),
|
||||||
builder: (context) => FundTransferSelfAccountsScreen(
|
);
|
||||||
debitAccountNo: creditAccountNo,
|
},
|
||||||
remitterName: remitterName,
|
),
|
||||||
accounts: accounts,
|
const Divider(height: 1),
|
||||||
),
|
FundTransferManagementTile(
|
||||||
),
|
icon: Symbols.output_circle,
|
||||||
);
|
label: AppLocalizations.of(context).outsideBank,
|
||||||
},
|
onTap: () {
|
||||||
// Disable the tile if the state is not Authenticated
|
Navigator.push(
|
||||||
disable: state is! Authenticated,
|
context,
|
||||||
),
|
MaterialPageRoute(
|
||||||
const Divider(height: 1),
|
builder: (context) => FundTransferBeneficiaryScreen(
|
||||||
FundTransferManagementTile(
|
creditAccountNo: creditAccountNo,
|
||||||
icon: Symbols.input_circle,
|
remitterName: remitterName,
|
||||||
// Restore localization for the label
|
isOwnBank: false,
|
||||||
label: AppLocalizations.of(context).ownBank,
|
),
|
||||||
onTap: () {
|
),
|
||||||
Navigator.push(
|
);
|
||||||
context,
|
},
|
||||||
MaterialPageRoute(
|
),
|
||||||
builder: (context) => FundTransferBeneficiaryScreen(
|
const Divider(height: 1),
|
||||||
creditAccountNo: creditAccountNo,
|
],
|
||||||
remitterName: remitterName,
|
),
|
||||||
isOwnBank: true,
|
);
|
||||||
),
|
}
|
||||||
),
|
}
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Divider(height: 1),
|
|
||||||
FundTransferManagementTile(
|
|
||||||
icon: Symbols.output_circle,
|
|
||||||
// Restore localization for the label
|
|
||||||
label: AppLocalizations.of(context).outsideBank,
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => FundTransferBeneficiaryScreen(
|
|
||||||
creditAccountNo: creditAccountNo,
|
|
||||||
remitterName: remitterName,
|
|
||||||
isOwnBank: false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Divider(height: 1),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FundTransferManagementTile extends StatelessWidget {
|
class FundTransferManagementTile extends StatelessWidget {
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String label;
|
final String label;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
final bool disable;
|
final bool disable;
|
||||||
|
|
||||||
const FundTransferManagementTile({
|
const FundTransferManagementTile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
required this.label,
|
required this.label,
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
this.disable = false,
|
this.disable = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Icon(icon),
|
leading: Icon(icon),
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
trailing: const Icon(Symbols.arrow_right, size: 20),
|
trailing: const Icon(Symbols.arrow_right, size: 20),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
enabled: !disable,
|
enabled: !disable,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:kmobile/data/models/user.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_self_amount_screen.dart';
|
|
||||||
import 'package:kmobile/widgets/bank_logos.dart';
|
|
||||||
|
|
||||||
class FundTransferSelfAccountsScreen extends StatelessWidget {
|
|
||||||
final String debitAccountNo;
|
|
||||||
final String remitterName;
|
|
||||||
final List<User> accounts;
|
|
||||||
|
|
||||||
const FundTransferSelfAccountsScreen({
|
|
||||||
super.key,
|
|
||||||
required this.debitAccountNo,
|
|
||||||
required this.remitterName,
|
|
||||||
required this.accounts,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Helper function to get the full account type name from the short code
|
|
||||||
String _getFullAccountType(String? accountType) {
|
|
||||||
if (accountType == null || accountType.isEmpty) return 'N/A';
|
|
||||||
switch (accountType.toLowerCase()) {
|
|
||||||
case 'sa':
|
|
||||||
case 'sb':
|
|
||||||
return "Savings Account";
|
|
||||||
case 'ln':
|
|
||||||
return "Loan Account";
|
|
||||||
case 'td':
|
|
||||||
return "Term Deposit";
|
|
||||||
case 'rd':
|
|
||||||
return "Recurring Deposit";
|
|
||||||
case 'ca':
|
|
||||||
return "Current Account";
|
|
||||||
default:
|
|
||||||
return "Unknown Account";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// Filter out the account from which the transfer is being made
|
|
||||||
final filteredAccounts =
|
|
||||||
accounts.where((acc) => acc.accountNo != debitAccountNo).toList();
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text("Select Account"),
|
|
||||||
),
|
|
||||||
body: filteredAccounts.isEmpty
|
|
||||||
? const Center(
|
|
||||||
child: Text("No other accounts found"),
|
|
||||||
)
|
|
||||||
: ListView.builder(
|
|
||||||
itemCount: filteredAccounts.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final account = filteredAccounts[index];
|
|
||||||
return ListTile(
|
|
||||||
leading: CircleAvatar(
|
|
||||||
radius: 24,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
child:
|
|
||||||
getBankLogo('Kangra Central Co-operative Bank', context),
|
|
||||||
),
|
|
||||||
title: Text(account.name ?? 'N/A'),
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(account.accountNo ?? 'N/A'),
|
|
||||||
Text(
|
|
||||||
_getFullAccountType(account.accountType),
|
|
||||||
style:
|
|
||||||
TextStyle(fontSize: 12, color: Colors.grey[600]),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
// Navigate to the amount screen, passing the selected User object directly.
|
|
||||||
// No Beneficiary object is created.
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => FundTransferSelfAmountScreen(
|
|
||||||
debitAccountNo: debitAccountNo,
|
|
||||||
creditAccount: account, // Pass the User object
|
|
||||||
remitterName: remitterName,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:kmobile/api/services/limit_service.dart';
|
|
||||||
import 'package:kmobile/api/services/payment_service.dart';
|
|
||||||
import 'package:kmobile/data/models/transfer.dart';
|
|
||||||
import 'package:kmobile/data/models/user.dart';
|
|
||||||
import 'package:kmobile/di/injection.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
|
||||||
import 'package:kmobile/widgets/bank_logos.dart';
|
|
||||||
|
|
||||||
class FundTransferSelfAmountScreen extends StatefulWidget {
|
|
||||||
final String debitAccountNo;
|
|
||||||
final User creditAccount;
|
|
||||||
final String remitterName;
|
|
||||||
|
|
||||||
const FundTransferSelfAmountScreen({
|
|
||||||
super.key,
|
|
||||||
required this.debitAccountNo,
|
|
||||||
required this.creditAccount,
|
|
||||||
required this.remitterName,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<FundTransferSelfAmountScreen> createState() =>
|
|
||||||
_FundTransferSelfAmountScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FundTransferSelfAmountScreenState
|
|
||||||
extends State<FundTransferSelfAmountScreen> {
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
|
||||||
final _amountController = TextEditingController();
|
|
||||||
final _remarksController = TextEditingController();
|
|
||||||
|
|
||||||
// --- Limit Checking Variables ---
|
|
||||||
final _limitService = getIt<LimitService>();
|
|
||||||
Limit? _limit;
|
|
||||||
bool _isLoadingLimit = true;
|
|
||||||
bool _isAmountOverLimit = false;
|
|
||||||
final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadLimit(); // Fetch the daily limit
|
|
||||||
_amountController.addListener(_checkAmountLimit); // Listen for amount changes
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_amountController.removeListener(_checkAmountLimit);
|
|
||||||
_amountController.dispose();
|
|
||||||
_remarksController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadLimit() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
final limitData = await _limitService.getLimit();
|
|
||||||
setState(() {
|
|
||||||
_limit = limitData;
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _checkAmountLimit() {
|
|
||||||
if (_limit == null) return;
|
|
||||||
|
|
||||||
final amount = double.tryParse(_amountController.text) ?? 0;
|
|
||||||
final remainingLimit = _limit!.dailyLimit - _limit!.usedLimit;
|
|
||||||
final bool isOverLimit = amount > remainingLimit;
|
|
||||||
|
|
||||||
if (isOverLimit) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(
|
|
||||||
'Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isAmountOverLimit != isOverLimit) {
|
|
||||||
setState(() {
|
|
||||||
_isAmountOverLimit = isOverLimit;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onProceed() {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => TransactionPinScreen(
|
|
||||||
onPinCompleted: (pinScreenContext, tpin) async {
|
|
||||||
final transfer = Transfer(
|
|
||||||
fromAccount: widget.debitAccountNo,
|
|
||||||
toAccount: widget.creditAccount.accountNo!,
|
|
||||||
toAccountType: 'Savings', // Assuming 'SB' for savings
|
|
||||||
amount: _amountController.text,
|
|
||||||
tpin: tpin,
|
|
||||||
);
|
|
||||||
|
|
||||||
final paymentService = getIt<PaymentService>();
|
|
||||||
final paymentResponseFuture =
|
|
||||||
paymentService.processQuickPayWithinBank(transfer);
|
|
||||||
|
|
||||||
Navigator.of(pinScreenContext).pushReplacement(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (_) =>
|
|
||||||
PaymentAnimationScreen(paymentResponse: paymentResponseFuture),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text("Fund Transfer"),
|
|
||||||
),
|
|
||||||
body: SafeArea(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
// Debit Account (User)
|
|
||||||
Text(
|
|
||||||
"Debit From",
|
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
|
||||||
),
|
|
||||||
Card(
|
|
||||||
elevation: 0,
|
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: ListTile(
|
|
||||||
leading: Image.asset(
|
|
||||||
'assets/images/logo.png',
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
),
|
|
||||||
title: Text(widget.remitterName),
|
|
||||||
subtitle: Text(widget.debitAccountNo),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Credit Account (Self)
|
|
||||||
Text(
|
|
||||||
"Credited To",
|
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
|
||||||
),
|
|
||||||
Card(
|
|
||||||
elevation: 0,
|
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: ListTile(
|
|
||||||
leading:
|
|
||||||
getBankLogo('Kangra Central Co-operative Bank', context),
|
|
||||||
title: Text(widget.creditAccount.name ?? 'N/A'),
|
|
||||||
subtitle: Text(widget.creditAccount.accountNo ?? 'N/A'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Remarks
|
|
||||||
TextFormField(
|
|
||||||
controller: _remarksController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: "Remarks (Optional)",
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
// Amount
|
|
||||||
TextFormField(
|
|
||||||
controller: _amountController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: "Amount",
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
prefixIcon: Icon(Icons.currency_rupee),
|
|
||||||
),
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return "Amount is required";
|
|
||||||
}
|
|
||||||
if (double.tryParse(value) == null ||
|
|
||||||
double.parse(value) <= 0) {
|
|
||||||
return "Please enter a valid amount";
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
|
|
||||||
// Daily Limit Display
|
|
||||||
if (_isLoadingLimit)
|
|
||||||
const Text('Fetching daily limit...'),
|
|
||||||
if (!_isLoadingLimit && _limit != null)
|
|
||||||
Text(
|
|
||||||
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
|
|
||||||
// Proceed Button
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: _isAmountOverLimit ? null : _onProceed,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
||||||
),
|
|
||||||
child: const Text("Proceed"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,228 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:kmobile/api/services/limit_service.dart';
|
|
||||||
import 'package:kmobile/di/injection.dart';
|
|
||||||
import 'package:kmobile/l10n/app_localizations.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
|
|
||||||
class DailyLimitScreen extends StatefulWidget {
|
|
||||||
const DailyLimitScreen({super.key});
|
|
||||||
@override
|
|
||||||
State<DailyLimitScreen> createState() => _DailyLimitScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
|
||||||
double? _currentLimit;
|
|
||||||
double? _spentAmount = 0.0;
|
|
||||||
final _limitController = TextEditingController();
|
|
||||||
var service = getIt<LimitService>();
|
|
||||||
Limit? limit;
|
|
||||||
bool _isLoading = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadlimits();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadlimits() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
final limit_data = await service.getLimit();
|
|
||||||
setState(() {
|
|
||||||
limit = limit_data;
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_limitController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _showAddOrEditLimitDialog() async {
|
|
||||||
_limitController.text = _currentLimit?.toStringAsFixed(0) ?? '';
|
|
||||||
final newLimit = await showDialog<double>(
|
|
||||||
context: context,
|
|
||||||
builder: (dialogContext) {
|
|
||||||
final localizations = AppLocalizations.of(dialogContext);
|
|
||||||
final theme = Theme.of(dialogContext);
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(
|
|
||||||
_currentLimit == null
|
|
||||||
? localizations.addLimit
|
|
||||||
: localizations.editLimit,
|
|
||||||
),
|
|
||||||
content: TextField(
|
|
||||||
controller: _limitController,
|
|
||||||
autofocus: true,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.allow(RegExp(r'^\d+')),
|
|
||||||
],
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: localizations.limitAmount,
|
|
||||||
prefixText: '₹',
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
|
||||||
child: Text(localizations.cancel),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
final value = double.tryParse(_limitController.text);
|
|
||||||
if (value == null || value <= 0) return;
|
|
||||||
|
|
||||||
if (value > 200000) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: const Text("Limit To be Set must be less than 200000"),
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
backgroundColor: theme.colorScheme.error,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
service.editLimit(value);
|
|
||||||
Navigator.of(dialogContext).pop(value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(localizations.save),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (newLimit != null) {
|
|
||||||
_loadlimits();
|
|
||||||
if (!mounted) return;
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Text("Limit Updated"),
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void _removeLimit() {
|
|
||||||
setState(() {
|
|
||||||
_currentLimit = null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (_isLoading) {
|
|
||||||
final localizations = AppLocalizations.of(context);
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(localizations.dailylimit),
|
|
||||||
),
|
|
||||||
body: const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_currentLimit = limit?.dailyLimit;
|
|
||||||
_spentAmount = limit?.usedLimit;
|
|
||||||
final localizations = AppLocalizations.of(context);
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
final formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|
||||||
final remainingLimit = _currentLimit != null ? _currentLimit! - _spentAmount! : 0.0;
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(localizations.dailylimit),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
localizations.currentDailyLimit,
|
|
||||||
style: theme.textTheme.headlineSmall?.copyWith(
|
|
||||||
color: theme.colorScheme.onSurface.withOpacity(0.7),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Text(
|
|
||||||
_currentLimit == null
|
|
||||||
? localizations.noLimitSet
|
|
||||||
: formatCurrency.format(_currentLimit),
|
|
||||||
style: theme.textTheme.headlineMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: _currentLimit == null
|
|
||||||
? theme.colorScheme.secondary
|
|
||||||
: theme.colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_currentLimit != null) ...[
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
Text(
|
|
||||||
"Remaining Limit Today", // This should be localized
|
|
||||||
style: theme.textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
formatCurrency.format(remainingLimit),
|
|
||||||
style: theme.textTheme.headlineSmall?.copyWith(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: remainingLimit > 0
|
|
||||||
? Colors.green
|
|
||||||
: theme.colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const SizedBox(height: 48),
|
|
||||||
if (_currentLimit == null)
|
|
||||||
ElevatedButton.icon(
|
|
||||||
onPressed: _showAddOrEditLimitDialog,
|
|
||||||
icon: const Icon(Icons.add_circle_outline),
|
|
||||||
label: Text(localizations.addLimit),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 24, vertical: 12),
|
|
||||||
textStyle: theme.textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
ElevatedButton.icon(
|
|
||||||
onPressed: _showAddOrEditLimitDialog,
|
|
||||||
icon: const Icon(Icons.edit_outlined),
|
|
||||||
label: Text(localizations.editLimit),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 24, vertical: 12),
|
|
||||||
textStyle: theme.textTheme.titleMedium,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
// TextButton.icon(
|
|
||||||
// onPressed: _removeLimit,
|
|
||||||
// icon: const Icon(Icons.remove_circle_outline),
|
|
||||||
// label: Text(localizations.removeLimit),
|
|
||||||
// style: TextButton.styleFrom(
|
|
||||||
// foregroundColor: theme.colorScheme.error,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,9 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:kmobile/data/repositories/auth_repository.dart';
|
import 'package:kmobile/data/repositories/auth_repository.dart';
|
||||||
import 'package:kmobile/features/profile/change_password/change_password_screen.dart';
|
import 'package:kmobile/features/profile/change_password/change_password_screen.dart';
|
||||||
import 'package:kmobile/features/profile/daily_transaction_limit.dart';
|
|
||||||
import 'package:kmobile/features/profile/logout_dialog.dart';
|
import 'package:kmobile/features/profile/logout_dialog.dart';
|
||||||
import 'package:kmobile/features/profile/tpin/change_tpin_screen.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:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
@@ -13,9 +11,6 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
import '../../di/injection.dart';
|
import '../../di/injection.dart';
|
||||||
import '../../l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
import 'package:kmobile/features/profile/preferences/preference_screen.dart';
|
import 'package:kmobile/features/profile/preferences/preference_screen.dart';
|
||||||
import 'package:kmobile/api/services/auth_service.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/tpin_set_screen.dart';
|
|
||||||
|
|
||||||
|
|
||||||
class ProfileScreen extends StatefulWidget {
|
class ProfileScreen extends StatefulWidget {
|
||||||
final String mobileNumber;
|
final String mobileNumber;
|
||||||
@@ -38,12 +33,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
return 'Version ${info.version} (${info.buildNumber})';
|
return 'Version ${info.version} (${info.buildNumber})';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadBiometricStatus() async {
|
Future<void> _loadBiometricStatus() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final storage = getIt<SecureStorage>();
|
||||||
setState(() {
|
final isEnabled = await storage.read('biometric_enabled');
|
||||||
_isBiometricEnabled = prefs.getBool('biometric_enabled') ?? false;
|
setState(() {
|
||||||
});
|
_isBiometricEnabled = isEnabled == 'true';
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _handleLogout(BuildContext context) async {
|
Future<void> _handleLogout(BuildContext context) async {
|
||||||
final auth = getIt<AuthRepository>();
|
final auth = getIt<AuthRepository>();
|
||||||
@@ -54,90 +50,89 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
Navigator.pushNamedAndRemoveUntil(context, '/login', (route) => false);
|
Navigator.pushNamedAndRemoveUntil(context, '/login', (route) => false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _handleBiometricToggle(bool enable) async {
|
Future<void> _handleBiometricToggle(bool enable) async {
|
||||||
final localAuth = LocalAuthentication();
|
final localAuth = LocalAuthentication();
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final storage = getIt<SecureStorage>();
|
||||||
final canCheck = await localAuth.canCheckBiometrics;
|
final canCheck = await localAuth.canCheckBiometrics;
|
||||||
|
|
||||||
if (!canCheck) {
|
if (!canCheck) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// Optional: Show a snackbar or dialog if biometrics are not available
|
||||||
SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
content: Text(AppLocalizations.of(context).biometricsNotAvailable)),
|
SnackBar(
|
||||||
);
|
content: Text(AppLocalizations.of(context).biometricsNotAvailable)),
|
||||||
return;
|
);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
final optIn = await showDialog<bool>(
|
// Show "Enable" dialog
|
||||||
context: context,
|
final optIn = await showDialog<bool>(
|
||||||
barrierDismissible: false,
|
context: context,
|
||||||
builder: (ctx) => AlertDialog(
|
barrierDismissible: false,
|
||||||
title: Text(AppLocalizations.of(context).enableFingerprintLogin),
|
builder: (ctx) => AlertDialog(
|
||||||
content: Text(AppLocalizations.of(context).enableFingerprintMessage),
|
title: Text(AppLocalizations.of(context).enableFingerprintLogin),
|
||||||
actions: [
|
content: Text(AppLocalizations.of(context).enableFingerprintMessage),
|
||||||
TextButton(
|
actions: [
|
||||||
onPressed: () => Navigator.of(ctx).pop(false),
|
TextButton(
|
||||||
child: Text(AppLocalizations.of(context).no),
|
onPressed: () => Navigator.of(ctx).pop(false),
|
||||||
),
|
child: Text(AppLocalizations.of(context).no),
|
||||||
TextButton(
|
),
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
TextButton(
|
||||||
child: Text(AppLocalizations.of(context).yes),
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
),
|
child: Text(AppLocalizations.of(context).yes),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
if (optIn == true) {
|
if (optIn == true) {
|
||||||
try {
|
try {
|
||||||
final didAuth = await localAuth.authenticate(
|
final didAuth = await localAuth.authenticate(
|
||||||
localizedReason: AppLocalizations.of(context).authenticateToEnable,
|
localizedReason: AppLocalizations.of(context).authenticateToEnable,
|
||||||
options: const AuthenticationOptions(
|
options: const AuthenticationOptions(
|
||||||
stickyAuth: true,
|
stickyAuth: true,
|
||||||
biometricOnly: true,
|
biometricOnly: true,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (didAuth) {
|
if (didAuth) {
|
||||||
await prefs.setBool('biometric_enabled', true);
|
await storage.write('biometric_enabled', 'true');
|
||||||
if (mounted) {
|
setState(() {
|
||||||
setState(() {
|
_isBiometricEnabled = true;
|
||||||
_isBiometricEnabled = true;
|
});
|
||||||
});
|
}
|
||||||
}
|
} catch (e) {
|
||||||
}
|
// Handle authentication errors
|
||||||
} catch (e) {
|
}
|
||||||
// Handle exceptions, state remains unchanged.
|
}
|
||||||
}
|
} else {
|
||||||
}
|
// Show "Disable" dialog
|
||||||
} else {
|
final optOut = await showDialog<bool>(
|
||||||
final optOut = await showDialog<bool>(
|
context: context,
|
||||||
context: context,
|
barrierDismissible: false,
|
||||||
barrierDismissible: false,
|
builder: (ctx) => AlertDialog(
|
||||||
builder: (ctx) => AlertDialog(
|
title: Text(AppLocalizations.of(context).disableFingerprintLogin),
|
||||||
title: Text(AppLocalizations.of(context).disableFingerprintLogin),
|
content: Text(AppLocalizations.of(context).disableFingerprintMessage),
|
||||||
content: Text(AppLocalizations.of(context).disableFingerprintMessage),
|
actions: [
|
||||||
actions: [
|
TextButton(
|
||||||
TextButton(
|
onPressed: () => Navigator.of(ctx).pop(false),
|
||||||
onPressed: () => Navigator.of(ctx).pop(false),
|
child: Text(AppLocalizations.of(context).no),
|
||||||
child: Text(AppLocalizations.of(context).no),
|
),
|
||||||
),
|
TextButton(
|
||||||
TextButton(
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
child: Text(AppLocalizations.of(context).yes),
|
||||||
child: Text(AppLocalizations.of(context).yes),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (optOut == true) {
|
if (optOut == true) {
|
||||||
await prefs.setBool('biometric_enabled', false);
|
await storage.write('biometric_enabled', 'false');
|
||||||
if (mounted) {
|
setState(() {
|
||||||
setState(() {
|
_isBiometricEnabled = false;
|
||||||
_isBiometricEnabled = false;
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -160,26 +155,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
|
||||||
leading: const Icon(Icons.currency_rupee),
|
|
||||||
title: Text(AppLocalizations.of(context).dailylimit),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const DailyLimitScreen()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: Text(AppLocalizations.of(context).enableFingerprintLogin),
|
title: Text(AppLocalizations.of(context).enableFingerprintLogin),
|
||||||
value: _isBiometricEnabled,
|
value: _isBiometricEnabled,
|
||||||
onChanged: (bool value) {
|
onChanged: (bool value) {
|
||||||
// The state is now managed within _handleBiometricToggle
|
_handleBiometricToggle(value);
|
||||||
_handleBiometricToggle(value);
|
},
|
||||||
},
|
secondary: const Icon(Icons.fingerprint),
|
||||||
secondary: const Icon(Icons.fingerprint),
|
),
|
||||||
),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.password),
|
leading: const Icon(Icons.password),
|
||||||
title: Text(loc.changeLoginPassword),
|
title: Text(loc.changeLoginPassword),
|
||||||
@@ -193,57 +176,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
// ListTile(
|
||||||
leading: const Icon(Icons.password),
|
// leading: const Icon(Icons.password),
|
||||||
title: Text('Change TPIN'),
|
// title: const Text("Manage TPIN"),
|
||||||
onTap: () async {
|
// onTap: () async {
|
||||||
// 1. Get the AuthService instance
|
// },
|
||||||
final authService = getIt<AuthService>();
|
// ),
|
||||||
|
|
||||||
// 2. Call checkTpin() to see if TPIN is set
|
|
||||||
final isTpinSet = await authService.checkTpin();
|
|
||||||
|
|
||||||
// 3. If TPIN is not set, show the dialog
|
|
||||||
if (!isTpinSet) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text('TPIN Not Set'),
|
|
||||||
content: Text('You have not set a TPIN yet. Please set a TPIN to proceed.'),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('Back'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
child: Text('Proceed'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop(); // Dismiss the dialog
|
|
||||||
// Navigate to the TPIN set screen
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => TpinSetScreen(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Case 2: TPIN is set
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => ChangeTpinScreen(mobileNumber: widget.mobileNumber),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// ListTile(
|
// ListTile(
|
||||||
// leading: const Icon(Icons.password),
|
// leading: const Icon(Icons.password),
|
||||||
// title: const Text("Change Login MPIN"),
|
// title: const Text("Change Login MPIN"),
|
||||||
|
|||||||
@@ -1,125 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:kmobile/di/injection.dart';
|
|
||||||
import 'package:kmobile/widgets/pin_input_field.dart';
|
|
||||||
import '../../../api/services/change_password_service.dart';
|
|
||||||
|
|
||||||
class ChangeTpinOtpScreen extends StatefulWidget {
|
|
||||||
final String oldTpin;
|
|
||||||
final String newTpin;
|
|
||||||
final String mobileNumber;
|
|
||||||
|
|
||||||
const ChangeTpinOtpScreen({
|
|
||||||
super.key,
|
|
||||||
required this.oldTpin,
|
|
||||||
required this.newTpin,
|
|
||||||
required this.mobileNumber,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChangeTpinOtpScreen> createState() => _ChangeTpinOtpScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChangeTpinOtpScreenState extends State<ChangeTpinOtpScreen> {
|
|
||||||
final _otpController = TextEditingController();
|
|
||||||
final ChangePasswordService _changePasswordService =
|
|
||||||
getIt<ChangePasswordService>();
|
|
||||||
bool _isLoading = false;
|
|
||||||
|
|
||||||
void _handleVerifyOtp() async {
|
|
||||||
if (_otpController.text.length != 6) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Please enter a valid 6-digit OTP')),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 1. Validate the OTP first.
|
|
||||||
await _changePasswordService.validateOtp(
|
|
||||||
otp: _otpController.text,
|
|
||||||
mobileNumber: widget.mobileNumber,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 2. If OTP is valid, then call validateChangeTpin.
|
|
||||||
await _changePasswordService.validateChangeTpin(
|
|
||||||
oldTpin: widget.oldTpin,
|
|
||||||
newTpin: widget.newTpin,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 3. Show success message.
|
|
||||||
if (mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Text('TPIN changed successfully!'),
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// 4. Navigate back to the profile screen or home.
|
|
||||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('An error occurred: $e'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Verify OTP'),
|
|
||||||
),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
const Text(
|
|
||||||
'Enter the OTP sent to your registered mobile number.',
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(fontSize: 16),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
PinInputField(
|
|
||||||
controller: _otpController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: _isLoading ? null : _handleVerifyOtp,
|
|
||||||
child: _isLoading
|
|
||||||
? const SizedBox(
|
|
||||||
height: 24,
|
|
||||||
width: 24,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
strokeWidth: 2.5,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Text('Verify & Change TPIN'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,146 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:kmobile/di/injection.dart';
|
|
||||||
import 'package:kmobile/features/profile/tpin/change_tpin_otp_screen.dart';
|
|
||||||
import 'package:kmobile/widgets/pin_input_field.dart';
|
|
||||||
import '../../../api/services/change_password_service.dart';
|
|
||||||
|
|
||||||
class ChangeTpinScreen extends StatefulWidget {
|
|
||||||
final String mobileNumber;
|
|
||||||
const ChangeTpinScreen({super.key, required this.mobileNumber});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChangeTpinScreen> createState() => _ChangeTpinScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChangeTpinScreenState extends State<ChangeTpinScreen> {
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
|
||||||
final _oldTpinController = TextEditingController();
|
|
||||||
final _newTpinController = TextEditingController();
|
|
||||||
final _confirmTpinController = TextEditingController();
|
|
||||||
final ChangePasswordService _changePasswordService =
|
|
||||||
getIt<ChangePasswordService>();
|
|
||||||
bool _isLoading = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_oldTpinController.dispose();
|
|
||||||
_newTpinController.dispose();
|
|
||||||
_confirmTpinController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleChangeTpin() async {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
// 1. Get OTP for TPIN change.
|
|
||||||
await _changePasswordService.getOtpTpin(mobileNumber: widget.mobileNumber);
|
|
||||||
|
|
||||||
// 2. Navigate to the OTP screen on success.
|
|
||||||
if (mounted) {
|
|
||||||
Navigator.of(context).push(
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => ChangeTpinOtpScreen(
|
|
||||||
oldTpin: _oldTpinController.text,
|
|
||||||
newTpin: _newTpinController.text,
|
|
||||||
mobileNumber: widget.mobileNumber,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (mounted) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Failed to send OTP: $e')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Change TPIN'),
|
|
||||||
),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(16.0),
|
|
||||||
child: Form(
|
|
||||||
key: _formKey,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text('Current TPIN'),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
PinInputField(
|
|
||||||
controller: _oldTpinController,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.length != 6) {
|
|
||||||
return 'Please enter your 6-digit old TPIN';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
const Text('New TPIN'),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
PinInputField(
|
|
||||||
controller: _newTpinController,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.length != 6) {
|
|
||||||
return 'Please enter a 6-digit new TPIN';
|
|
||||||
}
|
|
||||||
if (value == _oldTpinController.text) {
|
|
||||||
return 'New TPIN must be different from the old one.';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
const Text('Confirm New TPIN'),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
PinInputField(
|
|
||||||
controller: _confirmTpinController,
|
|
||||||
validator: (value) {
|
|
||||||
if (value == null || value.length != 6) {
|
|
||||||
return 'Please confirm your new TPIN';
|
|
||||||
}
|
|
||||||
if (value != _newTpinController.text) {
|
|
||||||
return 'TPINs do not match';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 32),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: _isLoading ? null : _handleChangeTpin,
|
|
||||||
child: _isLoading
|
|
||||||
? const SizedBox(
|
|
||||||
height: 24,
|
|
||||||
width: 24,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
strokeWidth: 2.5,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Text('Proceed'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,9 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:kmobile/api/services/imps_service.dart';
|
import 'package:kmobile/api/services/imps_service.dart';
|
||||||
import 'package:kmobile/api/services/limit_service.dart';
|
|
||||||
import 'package:kmobile/api/services/neft_service.dart';
|
import 'package:kmobile/api/services/neft_service.dart';
|
||||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||||
import 'package:kmobile/data/models/imps_transaction.dart';
|
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||||
@@ -30,10 +28,7 @@ class QuickPayOutsideBankScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _limitService = getIt<LimitService>();
|
|
||||||
Limit? _limit;
|
|
||||||
bool _isLoadingLimit = true;
|
|
||||||
final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|
||||||
// Controllers
|
// Controllers
|
||||||
final accountNumberController = TextEditingController();
|
final accountNumberController = TextEditingController();
|
||||||
final confirmAccountNumberController = TextEditingController();
|
final confirmAccountNumberController = TextEditingController();
|
||||||
@@ -46,7 +41,6 @@ final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|||||||
final remarksController = TextEditingController();
|
final remarksController = TextEditingController();
|
||||||
final _ifscFocusNode = FocusNode();
|
final _ifscFocusNode = FocusNode();
|
||||||
final service = getIt<BeneficiaryService>();
|
final service = getIt<BeneficiaryService>();
|
||||||
bool _isAmountOverLimit = false;
|
|
||||||
|
|
||||||
late String accountType;
|
late String accountType;
|
||||||
bool _isValidating = false;
|
bool _isValidating = false;
|
||||||
@@ -56,7 +50,6 @@ final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadLimit();
|
|
||||||
_ifscFocusNode.addListener(() {
|
_ifscFocusNode.addListener(() {
|
||||||
if (!_ifscFocusNode.hasFocus && ifscController.text.trim().length == 11) {
|
if (!_ifscFocusNode.hasFocus && ifscController.text.trim().length == 11) {
|
||||||
_validateIFSC();
|
_validateIFSC();
|
||||||
@@ -67,51 +60,8 @@ final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|||||||
accountType = 'Savings';
|
accountType = 'Savings';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
amountController.addListener(_checkAmountLimit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadLimit() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
final limitData = await _limitService.getLimit();
|
|
||||||
setState(() {
|
|
||||||
_limit = limitData;
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// Handle error if needed
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this method to check the amount against the limit
|
|
||||||
void _checkAmountLimit() {
|
|
||||||
if (_limit == null) return;
|
|
||||||
|
|
||||||
final amount = double.tryParse(amountController.text) ?? 0;
|
|
||||||
final remainingLimit = _limit!.dailyLimit - _limit!.usedLimit;
|
|
||||||
final bool isOverLimit = amount > remainingLimit;
|
|
||||||
|
|
||||||
if (isOverLimit) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isAmountOverLimit != isOverLimit) {
|
|
||||||
setState(() {
|
|
||||||
_isAmountOverLimit = isOverLimit;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _validateIFSC() async {
|
void _validateIFSC() async {
|
||||||
final ifsc = ifscController.text.trim().toUpperCase();
|
final ifsc = ifscController.text.trim().toUpperCase();
|
||||||
if (ifsc.isEmpty) return;
|
if (ifsc.isEmpty) return;
|
||||||
@@ -768,9 +718,6 @@ Future<void> _loadLimit() async {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -836,22 +783,6 @@ Future<void> _loadLimit() async {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
if (_isLoadingLimit)
|
|
||||||
const Padding(
|
|
||||||
padding: EdgeInsets.only(left: 8.0),
|
|
||||||
child: Text('Fetching daily limit...'),
|
|
||||||
),
|
|
||||||
if (!_isLoadingLimit && _limit != null)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: Text(
|
|
||||||
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -864,31 +795,24 @@ if (!_isLoadingLimit && _limit != null)
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 45),
|
const SizedBox(height: 45),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SwipeButton.expand(
|
child: SwipeButton.expand(
|
||||||
thumb: Icon(Icons.arrow_forward,
|
thumb: Icon(Icons.arrow_forward,
|
||||||
color: _isAmountOverLimit ? Colors.grey : Theme.of(context).dialogBackgroundColor),
|
color: Theme.of(context).dialogBackgroundColor),
|
||||||
activeThumbColor: _isAmountOverLimit ? Colors.grey.shade700 :
|
activeThumbColor: Theme.of(context).colorScheme.primary,
|
||||||
Theme.of(context).colorScheme.primary,
|
activeTrackColor:
|
||||||
activeTrackColor: _isAmountOverLimit
|
Theme.of(context).colorScheme.secondary.withAlpha(100),
|
||||||
? Colors.grey.shade300
|
borderRadius: BorderRadius.circular(30),
|
||||||
: Theme.of(context).colorScheme.secondary.withAlpha(100),
|
height: 56,
|
||||||
borderRadius: BorderRadius.circular(30),
|
onSwipe: _onProceedToPay,
|
||||||
height: 56,
|
child: Text(
|
||||||
onSwipe: () {
|
AppLocalizations.of(context).swipeToPay,
|
||||||
if (_isAmountOverLimit) {
|
style: const TextStyle(
|
||||||
return; // Do nothing if amount is over the limit
|
fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
}
|
),
|
||||||
_onProceedToPay();
|
),
|
||||||
},
|
),
|
||||||
child: Text(
|
|
||||||
AppLocalizations.of(context).swipeToPay,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
import 'package:kmobile/api/services/limit_service.dart';
|
|
||||||
import 'package:kmobile/api/services/payment_service.dart';
|
import 'package:kmobile/api/services/payment_service.dart';
|
||||||
import 'package:kmobile/data/models/transfer.dart';
|
import 'package:kmobile/data/models/transfer.dart';
|
||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
@@ -21,17 +19,14 @@ class QuickPayWithinBankScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _limitService = getIt<LimitService>();
|
|
||||||
Limit? _limit;
|
|
||||||
bool _isLoadingLimit = true;
|
|
||||||
final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|
||||||
final TextEditingController accountNumberController = TextEditingController();
|
final TextEditingController accountNumberController = TextEditingController();
|
||||||
final TextEditingController confirmAccountNumberController =
|
final TextEditingController confirmAccountNumberController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
final TextEditingController amountController = TextEditingController();
|
final TextEditingController amountController = TextEditingController();
|
||||||
final TextEditingController remarksController = TextEditingController();
|
final TextEditingController remarksController = TextEditingController();
|
||||||
String? _selectedAccountType;
|
String? _selectedAccountType;
|
||||||
bool _isAmountOverLimit = false;
|
|
||||||
String? _beneficiaryName;
|
String? _beneficiaryName;
|
||||||
bool _isValidating = false;
|
bool _isValidating = false;
|
||||||
bool _isBeneficiaryValidated = false;
|
bool _isBeneficiaryValidated = false;
|
||||||
@@ -40,54 +35,10 @@ final _formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadLimit();
|
|
||||||
accountNumberController.addListener(_resetBeneficiaryValidation);
|
accountNumberController.addListener(_resetBeneficiaryValidation);
|
||||||
confirmAccountNumberController.addListener(_resetBeneficiaryValidation);
|
confirmAccountNumberController.addListener(_resetBeneficiaryValidation);
|
||||||
amountController.addListener(_checkAmountLimit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadLimit() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
final limitData = await _limitService.getLimit();
|
|
||||||
setState(() {
|
|
||||||
_limit = limitData;
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
// Handle error if needed
|
|
||||||
setState(() {
|
|
||||||
_isLoadingLimit = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _checkAmountLimit() {
|
|
||||||
if (_limit == null) return;
|
|
||||||
|
|
||||||
final amount = double.tryParse(amountController.text) ?? 0;
|
|
||||||
final remainingLimit = _limit!.dailyLimit - _limit!.usedLimit;
|
|
||||||
final bool isOverLimit = amount > remainingLimit;
|
|
||||||
|
|
||||||
if (isOverLimit) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('Amount exceeds remaining daily limit of ${_formatCurrency.format(remainingLimit)}'),
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update state only if it changes to avoid unnecessary rebuilds
|
|
||||||
if (_isAmountOverLimit != isOverLimit) {
|
|
||||||
setState(() {
|
|
||||||
_isAmountOverLimit = isOverLimit;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _resetBeneficiaryValidation() {
|
void _resetBeneficiaryValidation() {
|
||||||
if (_isBeneficiaryValidated ||
|
if (_isBeneficiaryValidated ||
|
||||||
_beneficiaryName != null ||
|
_beneficiaryName != null ||
|
||||||
@@ -102,7 +53,6 @@ void _checkAmountLimit() {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
amountController.removeListener(_checkAmountLimit);
|
|
||||||
accountNumberController.removeListener(_resetBeneficiaryValidation);
|
accountNumberController.removeListener(_resetBeneficiaryValidation);
|
||||||
confirmAccountNumberController.removeListener(_resetBeneficiaryValidation);
|
confirmAccountNumberController.removeListener(_resetBeneficiaryValidation);
|
||||||
accountNumberController.dispose();
|
accountNumberController.dispose();
|
||||||
@@ -152,8 +102,7 @@ void _checkAmountLimit() {
|
|||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: SingleChildScrollView(
|
child: Column(
|
||||||
child: Column(
|
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
@@ -348,7 +297,6 @@ void _checkAmountLimit() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
TextFormField(
|
TextFormField(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: AppLocalizations.of(context).amount,
|
labelText: AppLocalizations.of(context).amount,
|
||||||
@@ -379,81 +327,66 @@ void _checkAmountLimit() {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
|
||||||
if (_isLoadingLimit)
|
|
||||||
const Text('Fetching daily limit...'),
|
|
||||||
if (!_isLoadingLimit && _limit != null)
|
|
||||||
Text(
|
|
||||||
'Remaining Daily Limit: ${_formatCurrency.format(_limit!.dailyLimit - _limit!.usedLimit)}',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 45),
|
const SizedBox(height: 45),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SwipeButton.expand(
|
child: SwipeButton.expand(
|
||||||
thumb: Icon(Icons.arrow_forward,
|
thumb: Icon(Icons.arrow_forward,
|
||||||
color: _isAmountOverLimit ? Colors.grey : Theme.of(context).dialogBackgroundColor),
|
color: Theme.of(context).dialogBackgroundColor),
|
||||||
activeThumbColor: _isAmountOverLimit ? Colors.grey.shade700 :
|
activeThumbColor: Theme.of(context).colorScheme.primary,
|
||||||
Theme.of(context).colorScheme.primary,
|
activeTrackColor: Theme.of(
|
||||||
activeTrackColor: _isAmountOverLimit
|
context,
|
||||||
? Colors.grey.shade300
|
).colorScheme.secondary.withAlpha(100),
|
||||||
: Theme.of(
|
borderRadius: BorderRadius.circular(30),
|
||||||
context,
|
height: 56,
|
||||||
).colorScheme.secondary.withAlpha(100),
|
child: Text(
|
||||||
borderRadius: BorderRadius.circular(30),
|
AppLocalizations.of(context).swipeToPay,
|
||||||
height: 56,
|
style: const TextStyle(fontSize: 16),
|
||||||
child: Text(
|
),
|
||||||
AppLocalizations.of(context).swipeToPay,
|
onSwipe: () {
|
||||||
style: const TextStyle(fontSize: 16),
|
if (_formKey.currentState!.validate()) {
|
||||||
),
|
if (!_isBeneficiaryValidated) {
|
||||||
onSwipe: () {
|
setState(() {
|
||||||
if (_isAmountOverLimit) {
|
_validationError = AppLocalizations.of(context)
|
||||||
return; // Do nothing if amount is over limit
|
.validateBeneficiaryproceeding;
|
||||||
}
|
});
|
||||||
if (_formKey.currentState!.validate()) {
|
return;
|
||||||
if (!_isBeneficiaryValidated) {
|
}
|
||||||
setState(() {
|
// Perform payment logic
|
||||||
_validationError = AppLocalizations.of(context)
|
Navigator.push(
|
||||||
.validateBeneficiaryproceeding;
|
context,
|
||||||
});
|
MaterialPageRoute(
|
||||||
return;
|
builder: (context) => TransactionPinScreen(
|
||||||
}
|
onPinCompleted: (pinScreenContext, tpin) async {
|
||||||
// Perform payment logic
|
final transfer = Transfer(
|
||||||
Navigator.push(
|
fromAccount: widget.debitAccount,
|
||||||
context,
|
toAccount: accountNumberController.text,
|
||||||
MaterialPageRoute(
|
toAccountType: _selectedAccountType!,
|
||||||
builder: (context) => TransactionPinScreen(
|
amount: amountController.text,
|
||||||
onPinCompleted: (pinScreenContext, tpin) async {
|
tpin: tpin,
|
||||||
final transfer = Transfer(
|
remarks: remarksController.text,
|
||||||
fromAccount: widget.debitAccount,
|
);
|
||||||
toAccount: accountNumberController.text,
|
|
||||||
toAccountType: _selectedAccountType!,
|
|
||||||
amount: amountController.text,
|
|
||||||
tpin: tpin,
|
|
||||||
remarks: remarksController.text,
|
|
||||||
);
|
|
||||||
|
|
||||||
final paymentService = getIt<PaymentService>();
|
final paymentService = getIt<PaymentService>();
|
||||||
final paymentResponseFuture = paymentService
|
final paymentResponseFuture = paymentService
|
||||||
.processQuickPayWithinBank(transfer);
|
.processQuickPayWithinBank(transfer);
|
||||||
|
|
||||||
Navigator.of(pinScreenContext).pushReplacement(
|
Navigator.of(pinScreenContext).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => PaymentAnimationScreen(
|
builder: (_) => PaymentAnimationScreen(
|
||||||
paymentResponse: paymentResponseFuture),
|
paymentResponse: paymentResponseFuture),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
161
lib/features/service/screens/daily_transaction_limit.dart
Normal file
161
lib/features/service/screens/daily_transaction_limit.dart
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
class DailyLimitScreen extends StatefulWidget {
|
||||||
|
const DailyLimitScreen({super.key});
|
||||||
|
@override
|
||||||
|
State<DailyLimitScreen> createState() => _DailyLimitScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
||||||
|
double? _currentLimit;
|
||||||
|
final _limitController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// Now just taking null, but for real time limit will be fetched using API call
|
||||||
|
_currentLimit = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_limitController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _showAddOrEditLimitDialog() async {
|
||||||
|
_limitController.text = _currentLimit?.toStringAsFixed(0) ?? '';
|
||||||
|
final newLimit = await showDialog<double>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
final localizations = AppLocalizations.of(context);
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(
|
||||||
|
_currentLimit == null
|
||||||
|
? localizations.addLimit
|
||||||
|
: localizations.editLimit,
|
||||||
|
),
|
||||||
|
content: TextField(
|
||||||
|
controller: _limitController,
|
||||||
|
autofocus: true,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.allow(RegExp(r'^\d+')),
|
||||||
|
],
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: localizations.limitAmount,
|
||||||
|
prefixText: '₹',
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: Text(localizations.cancel),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
final value = double.tryParse(_limitController.text);
|
||||||
|
if (value != null && value > 0) {
|
||||||
|
Navigator.of(context).pop(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(localizations.save),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (newLimit != null) {
|
||||||
|
setState(() {
|
||||||
|
_currentLimit = newLimit;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _removeLimit() {
|
||||||
|
setState(() {
|
||||||
|
_currentLimit = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final localizations = AppLocalizations.of(context);
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(localizations.dailylimit),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
localizations.currentDailyLimit,
|
||||||
|
style: theme.textTheme.headlineSmall?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurface.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
_currentLimit == null
|
||||||
|
? localizations.noLimitSet
|
||||||
|
: formatCurrency.format(_currentLimit),
|
||||||
|
style: theme.textTheme.headlineMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: _currentLimit == null
|
||||||
|
? theme.colorScheme.secondary
|
||||||
|
: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 48),
|
||||||
|
if (_currentLimit == null)
|
||||||
|
ElevatedButton.icon(
|
||||||
|
onPressed: _showAddOrEditLimitDialog,
|
||||||
|
icon: const Icon(Icons.add_circle_outline),
|
||||||
|
label: Text(localizations.addLimit),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24, vertical: 12),
|
||||||
|
textStyle: theme.textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
ElevatedButton.icon(
|
||||||
|
onPressed: _showAddOrEditLimitDialog,
|
||||||
|
icon: const Icon(Icons.edit_outlined),
|
||||||
|
label: Text(localizations.editLimit),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24, vertical: 12),
|
||||||
|
textStyle: theme.textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: _removeLimit,
|
||||||
|
icon: const Icon(Icons.remove_circle_outline),
|
||||||
|
label: Text(localizations.removeLimit),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: theme.colorScheme.error,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:kmobile/features/service/screens/branch_locator_screen.dart';
|
import 'package:kmobile/features/service/screens/branch_locator_screen.dart';
|
||||||
|
import 'package:kmobile/features/service/screens/daily_transaction_limit.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
@@ -40,6 +40,18 @@ class _ServiceScreen extends State<ServiceScreen> {
|
|||||||
disabled: true,
|
disabled: true,
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
|
ServiceManagementTile(
|
||||||
|
icon: Symbols.currency_rupee,
|
||||||
|
label: AppLocalizations.of(context).dailylimit,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const DailyLimitScreen()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
disabled: true,
|
||||||
|
),
|
||||||
|
const Divider(height: 1),
|
||||||
ServiceManagementTile(
|
ServiceManagementTile(
|
||||||
icon: Symbols.captive_portal,
|
icon: Symbols.captive_portal,
|
||||||
label: AppLocalizations.of(context).quickLinks,
|
label: AppLocalizations.of(context).quickLinks,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// ignore_for_file: unused_import
|
// ignore_for_file: unused_import
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:kmobile/core/logger.dart';
|
||||||
import 'package:kmobile/features/security/security_error_screen.dart';
|
import 'package:kmobile/features/security/security_error_screen.dart';
|
||||||
import 'package:kmobile/security/security_service.dart';
|
import 'package:kmobile/security/security_service.dart';
|
||||||
import 'di/injection.dart';
|
import 'di/injection.dart';
|
||||||
@@ -8,6 +9,7 @@ import 'app.dart';
|
|||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
Logger.info("App starting...");
|
||||||
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
@@ -17,11 +19,14 @@ void main() async {
|
|||||||
// Check for device compromise
|
// Check for device compromise
|
||||||
// final compromisedMessage = await SecurityService.deviceCompromisedMessage;
|
// final compromisedMessage = await SecurityService.deviceCompromisedMessage;
|
||||||
// if (compromisedMessage != null) {
|
// if (compromisedMessage != null) {
|
||||||
|
// Logger.error("Device compromised: $compromisedMessage");
|
||||||
// runApp(MaterialApp(
|
// runApp(MaterialApp(
|
||||||
// home: SecurityErrorScreen(message: compromisedMessage),
|
// home: SecurityErrorScreen(message: compromisedMessage),
|
||||||
// ));
|
// ));
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
Logger.info("Setting up dependencies...");
|
||||||
await setupDependencies();
|
await setupDependencies();
|
||||||
|
Logger.info("Dependencies set up.");
|
||||||
runApp(const KMobile());
|
runApp(const KMobile());
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ Widget getBankLogo(String? bankName, BuildContext context) {
|
|||||||
height: 40,
|
height: 40,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (bankName != null && bankName.toLowerCase().contains('icici')) {
|
if (bankName != null && bankName.toLowerCase().contains('icici bank ltd')) {
|
||||||
return Image.asset(
|
return Image.asset(
|
||||||
'assets/images/icici_logo.png',
|
'assets/images/icici_logo.png',
|
||||||
width: 40,
|
width: 40,
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
class PinInputField extends StatelessWidget {
|
|
||||||
final TextEditingController controller;
|
|
||||||
final int length;
|
|
||||||
final FormFieldValidator<String>? validator;
|
|
||||||
|
|
||||||
const PinInputField({
|
|
||||||
super.key,
|
|
||||||
required this.controller,
|
|
||||||
this.length = 6,
|
|
||||||
this.validator,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return FormField<String>(
|
|
||||||
validator: validator,
|
|
||||||
builder: (FormFieldState<String> state) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
TextField(
|
|
||||||
controller: controller,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
|
||||||
LengthLimitingTextInputFormatter(length),
|
|
||||||
],
|
|
||||||
obscureText: true,
|
|
||||||
obscuringCharacter: '*',
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: const OutlineInputBorder(),
|
|
||||||
labelText: 'Enter $length-digit PIN',
|
|
||||||
counterText: '', // Hide the counter
|
|
||||||
),
|
|
||||||
onChanged: (value) {
|
|
||||||
state.didChange(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (state.hasError)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8.0, left: 12.0),
|
|
||||||
child: Text(
|
|
||||||
state.errorText!,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.error,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:kmobile/features/auth/screens/tnc_required_screen.dart';
|
|
||||||
|
|
||||||
class TncDialog extends StatefulWidget {
|
|
||||||
// Add a callback function for when the user proceeds
|
|
||||||
final Future<void> Function() onProceed;
|
|
||||||
|
|
||||||
const TncDialog({Key? key, required this.onProceed}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_TncDialogState createState() => _TncDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TncDialogState extends State<TncDialog> {
|
|
||||||
bool _isAgreed = false;
|
|
||||||
bool _isLoading = false;
|
|
||||||
|
|
||||||
void _handleProceed() async {
|
|
||||||
if (_isLoading) return;
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Call the provided onProceed function, which will trigger the cubit
|
|
||||||
await widget.onProceed();
|
|
||||||
|
|
||||||
// The dialog will be dismissed by the navigation that happens in the BlocListener
|
|
||||||
// so we don't need to pop here. If for some reason it's still visible,
|
|
||||||
// we can add a mounted check and pop.
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: const Text('Terms and Conditions'),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: _isLoading
|
|
||||||
? const Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(16.0),
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'Please read and accept our terms and conditions to continue. '
|
|
||||||
'This is a placeholder for the actual terms and conditions text.'),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
value: _isAgreed,
|
|
||||||
onChanged: (bool? value) {
|
|
||||||
setState(() {
|
|
||||||
_isAgreed = value ?? false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const Flexible(
|
|
||||||
child: Text('I agree to the Terms and Conditions')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
// Disable button while loading
|
|
||||||
onPressed: _isLoading
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(
|
|
||||||
content: Text(
|
|
||||||
'You must agree to the terms and conditions to proceed.'),
|
|
||||||
behavior: SnackBarBehavior.floating,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text('Disagree'),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
// Disable button if not agreed or while loading
|
|
||||||
onPressed: _isAgreed && !_isLoading ? _handleProceed : null,
|
|
||||||
child: const Text('Proceed'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
90
pubspec.lock
90
pubspec.lock
@@ -69,10 +69,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
|
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.3.0"
|
||||||
checked_yaml:
|
checked_yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -93,18 +93,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
|
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.2"
|
version: "1.1.1"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
|
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.19.1"
|
version: "1.18.0"
|
||||||
confetti:
|
confetti:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -181,10 +181,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
|
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.3"
|
version: "1.3.1"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -307,6 +307,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
|
flutter_sms:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_sms
|
||||||
|
sha256: "2fe5f584f02596343557eeca56348f9b82413fefe83a423fab880cdbdf54d8d8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.3"
|
||||||
flutter_svg:
|
flutter_svg:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -333,6 +341,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
fluttertoast:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: fluttertoast
|
||||||
|
sha256: "90778fe0497fe3a09166e8cf2e0867310ff434b794526589e77ec03cf08ba8e8"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "8.2.14"
|
||||||
get_it:
|
get_it:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -385,10 +401,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: intl
|
name: intl
|
||||||
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.20.2"
|
version: "0.19.0"
|
||||||
jailbreak_root_detection:
|
jailbreak_root_detection:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -417,26 +433,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
|
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "11.0.2"
|
version: "10.0.5"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_flutter_testing
|
name: leak_tracker_flutter_testing
|
||||||
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
|
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.10"
|
version: "3.0.5"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
|
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.2"
|
version: "3.0.1"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -497,10 +513,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
|
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.17"
|
version: "0.12.16+1"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -521,10 +537,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.15.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -561,10 +577,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
|
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.0"
|
||||||
path_parsing:
|
path_parsing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -813,11 +829,19 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.1"
|
||||||
|
simcards:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: simcards
|
||||||
|
sha256: b621cc265ebbb3e11009ca9be67063efbc011396c4224aff8b08edaba30fa5ae
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.0.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.99"
|
||||||
source_span:
|
source_span:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -838,18 +862,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
|
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.12.1"
|
version: "1.11.1"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
|
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.2"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -870,10 +894,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.6"
|
version: "0.7.2"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -947,7 +971,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.4"
|
version: "3.1.4"
|
||||||
uuid:
|
uuid:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: uuid
|
name: uuid
|
||||||
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
|
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
|
||||||
@@ -982,10 +1006,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.1.4"
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1043,5 +1067,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.8.0-0 <4.0.0"
|
dart: ">=3.5.0 <4.0.0"
|
||||||
flutter: ">=3.24.0"
|
flutter: ">=3.24.0"
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ dependencies:
|
|||||||
device_info_plus: ^11.3.0
|
device_info_plus: ^11.3.0
|
||||||
showcaseview: ^2.0.3
|
showcaseview: ^2.0.3
|
||||||
package_info_plus: ^4.2.0
|
package_info_plus: ^4.2.0
|
||||||
|
simcards: ^0.0.1
|
||||||
|
uuid: ^4.5.1
|
||||||
|
#send_message: ^1.0.0
|
||||||
|
flutter_sms: ^2.3.3
|
||||||
|
fluttertoast: ^8.2.6
|
||||||
# jailbreak_root_detection: "^1.1.6"
|
# jailbreak_root_detection: "^1.1.6"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user