Compare commits
6 Commits
8f8fdb70e6
...
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
@@ -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)
|
||||||
|
|||||||
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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>()));
|
||||||
@@ -71,13 +69,12 @@ Dio _createDioClient() {
|
|||||||
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,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) {
|
||||||
|
|||||||
@@ -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,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,7 +3,6 @@ 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/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';
|
||||||
@@ -156,17 +155,6 @@ 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,
|
||||||
|
|||||||
@@ -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());
|
||||||
}
|
}
|
||||||
26
pubspec.lock
26
pubspec.lock
@@ -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:
|
||||||
@@ -813,6 +829,14 @@ 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
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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