feat: Implement major features and fix theming bug
This commit introduces several new features and a critical bug fix. - Implemented a full "Quick Pay" flow for both within and outside the bank, including IFSC validation, beneficiary verification, and a TPIN-based payment process. - Added a date range filter to the Account Statement screen and streamlined the UI by removing the amount filters. - Fixed a major bug that prevented dynamic theme changes from being applied. The app now correctly switches between color themes. - Refactored and improved beneficiary management, transaction models, and the fund transfer flow to support NEFT/RTGS.
This commit is contained in:
@@ -36,7 +36,11 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
});
|
||||
try {
|
||||
final repo = getIt<TransactionRepository>();
|
||||
final txs = await repo.fetchTransactions(widget.accountNo);
|
||||
final txs = await repo.fetchTransactions(
|
||||
widget.accountNo,
|
||||
fromDate: fromDate,
|
||||
toDate: toDate,
|
||||
);
|
||||
setState(() => _transactions = txs);
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
@@ -115,7 +119,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).accountStatement,
|
||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
@@ -181,56 +186,28 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _minAmountController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).minAmount,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loadTransactions,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
child: Text(
|
||||
"Search",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
controller: _maxAmountController,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).maxAmount,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(
|
||||
width: 70,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loadTransactions,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
child: Icon(
|
||||
Symbols.arrow_forward,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 35),
|
||||
if (!_txLoading && _transactions.isNotEmpty)
|
||||
if (!_txLoading &&
|
||||
_transactions.isNotEmpty &&
|
||||
fromDate == null &&
|
||||
toDate == null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12.0),
|
||||
child: Text(
|
||||
@@ -252,7 +229,8 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: CircleAvatar(
|
||||
radius: 12,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
title: Shimmer.fromColors(
|
||||
@@ -298,7 +276,7 @@ class _AccountStatementScreen extends State<AccountStatementScreen> {
|
||||
title: Text(
|
||||
tx.name != null
|
||||
? (tx.name!.length > 18
|
||||
? tx.name!.substring(0, 20)
|
||||
? tx.name!.substring(0, 22)
|
||||
: tx.name!)
|
||||
: '',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
|
@@ -1,48 +1,25 @@
|
||||
import 'dart:developer';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'theme_state.dart';
|
||||
import 'package:kmobile/config/theme_type.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'theme_state.dart';
|
||||
|
||||
class ThemeCubit extends Cubit<ThemeState> {
|
||||
ThemeCubit(): super(ThemeViolet()) {
|
||||
ThemeCubit() : super(const ThemeState(themeType: ThemeType.violet)) {
|
||||
loadTheme();
|
||||
}
|
||||
|
||||
Future<void> loadTheme() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final themeIndex = prefs.getInt('theme_type') ?? 0;
|
||||
// final isDark = prefs.getBool('is_dark_mode') ?? false;
|
||||
|
||||
final type = ThemeType.values[themeIndex];
|
||||
switch(type) {
|
||||
case ThemeType.blue:
|
||||
emit(ThemeBlue());
|
||||
case ThemeType.violet:
|
||||
emit(ThemeViolet());
|
||||
default:
|
||||
emit(ThemeViolet());
|
||||
}
|
||||
emit(ThemeState(themeType: type));
|
||||
}
|
||||
|
||||
Future<void> changeTheme(ThemeType type) async {
|
||||
print("Attempting to change theme to: ${type.toString()}");
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt('theme_type', type.index);
|
||||
log("Mode Change");
|
||||
print("mode changed");
|
||||
switch(type) {
|
||||
case ThemeType.blue:
|
||||
emit(ThemeBlue());
|
||||
print('blue matched');
|
||||
break;
|
||||
case ThemeType.violet:
|
||||
emit(ThemeViolet());
|
||||
print('violet matched');
|
||||
break;
|
||||
default:
|
||||
emit(ThemeBlue());
|
||||
print('default macthed');
|
||||
}
|
||||
emit(ThemeState(themeType: type));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,27 +1,17 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/config/theme_type.dart';
|
||||
import 'package:kmobile/config/themes.dart';
|
||||
|
||||
class ThemeState extends Equatable {
|
||||
final ThemeType themeType;
|
||||
|
||||
abstract class ThemeState extends Equatable {
|
||||
getThemeData();
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
const ThemeState({required this.themeType});
|
||||
|
||||
class ThemeBlue extends ThemeState {
|
||||
|
||||
@override
|
||||
getThemeData() {
|
||||
print('returning blue theme');
|
||||
return AppThemes.getLightTheme(ThemeType.blue);
|
||||
ThemeData getThemeData() {
|
||||
return AppThemes.getLightTheme(themeType);
|
||||
}
|
||||
}
|
||||
|
||||
class ThemeViolet extends ThemeState {
|
||||
@override
|
||||
getThemeData() {
|
||||
print('returning violet theme');
|
||||
return AppThemes.getLightTheme(ThemeType.violet);
|
||||
}
|
||||
}
|
||||
List<Object?> get props => [themeType];
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
@@ -8,15 +9,14 @@ import 'beneficiary_result_page.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../di/injection.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||
|
||||
class AddBeneficiaryScreen extends StatefulWidget {
|
||||
final List<User>? users;
|
||||
final int? selectedIndex;
|
||||
final String customerName;
|
||||
|
||||
const AddBeneficiaryScreen({
|
||||
super.key,
|
||||
this.users,
|
||||
this.selectedIndex,
|
||||
required this.customerName,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,7 +26,6 @@ class AddBeneficiaryScreen extends StatefulWidget {
|
||||
class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
late User selectedUser = (widget.users ?? [])[widget.selectedIndex!];
|
||||
final TextEditingController accountNumberController = TextEditingController();
|
||||
final TextEditingController confirmAccountNumberController =
|
||||
TextEditingController();
|
||||
@@ -35,13 +34,14 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
final TextEditingController branchNameController = TextEditingController();
|
||||
final TextEditingController ifscController = TextEditingController();
|
||||
final TextEditingController phoneController = TextEditingController();
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
|
||||
String? _beneficiaryName;
|
||||
bool _isValidating = false;
|
||||
bool _isBeneficiaryValidated = false;
|
||||
String? _validationError;
|
||||
|
||||
late String accountType;
|
||||
final String _selectedAccountType = 'Savings'; // default value
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -53,167 +53,159 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
ifsc? _ifscData;
|
||||
bool _isLoading = false; //for validateIFSC()
|
||||
|
||||
void _validateIFSC() async {
|
||||
var beneficiaryService = getIt<BeneficiaryService>();
|
||||
final ifsc = ifscController.text.trim().toUpperCase();
|
||||
if (ifsc.isEmpty) return;
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_ifscData = null;
|
||||
});
|
||||
void _validateIFSC() async {
|
||||
var beneficiaryService = getIt<BeneficiaryService>();
|
||||
final ifsc = ifscController.text.trim().toUpperCase();
|
||||
if (ifsc.isEmpty) return;
|
||||
|
||||
final result = await beneficiaryService.validateIFSC(ifsc);
|
||||
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_ifscData = result;
|
||||
});
|
||||
|
||||
if (result == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||
);
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
} else {
|
||||
print("${AppLocalizations.of(context).validIfsc}: ${result.bankName}, ${result.branchName}");
|
||||
bankNameController.text = result.bankName;
|
||||
branchNameController.text = result.branchName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _validateBeneficiary() async {
|
||||
// start spinner / disable button
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
_validationError = null;
|
||||
_isBeneficiaryValidated = false;
|
||||
nameController.text = ''; // clear previous name
|
||||
});
|
||||
|
||||
final String accountNo = accountNumberController.text.trim();
|
||||
final String ifsc = ifscController.text.trim();
|
||||
final String remitter = selectedUser.name ?? '';
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
// Step 1: call validate API -> get refNo
|
||||
final String? refNo = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
|
||||
if (refNo == null || refNo.isEmpty) {
|
||||
setState(() {
|
||||
_validationError = 'Validation request failed. Please check details.';
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2: poll checkValidationStatus for up to 30 seconds
|
||||
const int timeoutSeconds = 30;
|
||||
const int intervalSeconds = 2;
|
||||
int elapsed = 0;
|
||||
String? foundName;
|
||||
|
||||
while (elapsed < timeoutSeconds) {
|
||||
final String? name = await service.checkValidationStatus(refNo);
|
||||
|
||||
if (name != null && name.trim().isNotEmpty) {
|
||||
foundName = name.trim();
|
||||
break;
|
||||
if (mounted) {
|
||||
if (result.bankName == '') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||
);
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
} else {
|
||||
bankNameController.text = result.bankName;
|
||||
branchNameController.text = result.branchName;
|
||||
}
|
||||
|
||||
await Future.delayed(const Duration(seconds: intervalSeconds));
|
||||
elapsed += intervalSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
void _validateBeneficiary() async {
|
||||
FocusScope.of(context).unfocus();
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
_validationError = null;
|
||||
_isBeneficiaryValidated = false;
|
||||
nameController.text = ''; // clear previous name
|
||||
});
|
||||
|
||||
final String accountNo = accountNumberController.text.trim();
|
||||
final String ifsc = ifscController.text.trim();
|
||||
final String remitter = widget.customerName;
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
final String beneficiaryName = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
|
||||
if (foundName != null) {
|
||||
setState(() {
|
||||
nameController.text = foundName!;
|
||||
nameController.text = beneficiaryName;
|
||||
_isBeneficiaryValidated = true;
|
||||
_validationError = null;
|
||||
});
|
||||
} else {
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_validationError = 'Beneficiary not found within timeout.';
|
||||
_validationError = e.toString();
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
}
|
||||
} catch (e, st) {
|
||||
// handle unexpected errors
|
||||
// print or log if you want
|
||||
debugPrint('Error validating beneficiary: $e\n$st');
|
||||
setState(() {
|
||||
_validationError = 'Something went wrong. Please try again.';
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isValidating = false;
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isValidating = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String _selectedAccountType = 'Savings'; // default value
|
||||
|
||||
void validateAndAddBeneficiary() async {
|
||||
// Show spinner and disable UI
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false, // Prevent dismiss on tap outside
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false, // Disable back button
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
final beneficiary = Beneficiary(
|
||||
accountNo: accountNumberController.text.trim(),
|
||||
accountType: _selectedAccountType,
|
||||
name: nameController.text.trim(),
|
||||
ifscCode: ifscController.text.trim(),
|
||||
);
|
||||
|
||||
var service = getIt<BeneficiaryService>();
|
||||
|
||||
try {
|
||||
await service.sendForValidation(beneficiary);
|
||||
bool isFound = await service.checkIfFound(beneficiary.accountNo);
|
||||
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context); // Close the spinner
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BeneficiaryResultPage(isSuccess: isFound),
|
||||
),
|
||||
);
|
||||
void validateAndAddBeneficiary() async {
|
||||
// First, validate the form fields (account number, confirm account, ifsc, etc.)
|
||||
if (!_formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
Navigator.pop(context); // Close the spinner
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).somethingWentWrong)),
|
||||
|
||||
// Ensure beneficiary is validated before proceeding to TPIN
|
||||
if (!_isBeneficiaryValidated) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Please validate beneficiary details first.')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the beneficiary object without TPIN for now
|
||||
final beneficiaryWithoutTpin = Beneficiary(
|
||||
accountNo: accountNumberController.text.trim(),
|
||||
accountType: accountType,
|
||||
name: nameController.text.trim(),
|
||||
ifscCode: ifscController.text.trim(),
|
||||
bankName: bankNameController.text.trim(),
|
||||
branchName: branchNameController.text.trim(),
|
||||
);
|
||||
|
||||
// Navigate to TPIN screen
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
// Show loading spinner while processing
|
||||
showDialog(
|
||||
context: pinScreenContext,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext ctx) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// Create a new Beneficiary object with the TPIN
|
||||
final beneficiaryWithTpin = Beneficiary(
|
||||
accountNo: beneficiaryWithoutTpin.accountNo,
|
||||
accountType: beneficiaryWithoutTpin.accountType,
|
||||
name: beneficiaryWithoutTpin.name,
|
||||
ifscCode: beneficiaryWithoutTpin.ifscCode,
|
||||
bankName: beneficiaryWithoutTpin.bankName,
|
||||
branchName: beneficiaryWithoutTpin.branchName,
|
||||
tpin: tpin,
|
||||
);
|
||||
|
||||
try {
|
||||
final isSuccess = await service.sendForValidation(beneficiaryWithTpin);
|
||||
|
||||
if (pinScreenContext.mounted) {
|
||||
Navigator.pop(pinScreenContext); // Close the spinner
|
||||
Navigator.pushReplacement(
|
||||
pinScreenContext,
|
||||
MaterialPageRoute(
|
||||
builder: (ctx) => BeneficiaryResultPage(isSuccess: isSuccess),
|
||||
),
|
||||
);
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
if (pinScreenContext.mounted) {
|
||||
Navigator.pop(pinScreenContext); // Close the spinner
|
||||
ScaffoldMessenger.of(pinScreenContext).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(e.response?.statusCode == 409
|
||||
? 'Beneficiary already exists'
|
||||
: 'Something went Wrong')),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (pinScreenContext.mounted) {
|
||||
Navigator.pop(pinScreenContext); // Close the spinner
|
||||
ScaffoldMessenger.of(pinScreenContext).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).somethingWentWrong)),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -227,7 +219,8 @@ void validateAndAddBeneficiary() async {
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).addBeneficiary,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style:
|
||||
const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
actions: [
|
||||
@@ -265,10 +258,11 @@ void validateAndAddBeneficiary() async {
|
||||
context,
|
||||
).accountNumber,
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
fillColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
@@ -282,6 +276,12 @@ void validateAndAddBeneficiary() async {
|
||||
obscureText: true,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onChanged: (value) {
|
||||
nameController.clear();
|
||||
setState(() {
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.length < 10) {
|
||||
return AppLocalizations.of(
|
||||
@@ -300,10 +300,11 @@ void validateAndAddBeneficiary() async {
|
||||
context,
|
||||
).confirmAccountNumber,
|
||||
// prefixIcon: Icon(Icons.person),
|
||||
border: OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
fillColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
@@ -339,7 +340,8 @@ void validateAndAddBeneficiary() async {
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
fillColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
@@ -377,7 +379,6 @@ void validateAndAddBeneficiary() async {
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 Bank Name (Disabled)
|
||||
TextFormField(
|
||||
@@ -388,7 +389,8 @@ void validateAndAddBeneficiary() async {
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor, // disabled color
|
||||
fillColor: Theme.of(context)
|
||||
.dialogBackgroundColor, // disabled color
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
@@ -400,7 +402,6 @@ void validateAndAddBeneficiary() async {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 Branch Name (Disabled)
|
||||
TextFormField(
|
||||
@@ -423,59 +424,62 @@ void validateAndAddBeneficiary() async {
|
||||
),
|
||||
),
|
||||
),
|
||||
//Validate Beneficiary Name
|
||||
if (!_isBeneficiaryValidated)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12.0),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isValidating
|
||||
? null
|
||||
: () {
|
||||
if (
|
||||
confirmAccountNumberController.text ==
|
||||
accountNumberController.text) {
|
||||
_validateBeneficiary();
|
||||
} else {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Please enter a valid and matching account number.';
|
||||
});
|
||||
}
|
||||
},
|
||||
child: _isValidating
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Text('Validate Beneficiary'),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!_isBeneficiaryValidated)
|
||||
Padding(
|
||||
padding: const EdgeInsetsGeometry.only(bottom: 24),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isValidating
|
||||
? null
|
||||
: () {
|
||||
if (confirmAccountNumberController
|
||||
.text ==
|
||||
accountNumberController.text) {
|
||||
_validateBeneficiary();
|
||||
} else {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Please enter a valid and matching account number.';
|
||||
});
|
||||
}
|
||||
},
|
||||
child: _isValidating
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2),
|
||||
)
|
||||
: const Text('Validate Beneficiary'),
|
||||
),
|
||||
),
|
||||
),
|
||||
//Beneficiary Name (Disabled)
|
||||
TextFormField(
|
||||
controller: nameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).beneficiaryName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? AppLocalizations.of(context).nameRequired
|
||||
: null,
|
||||
),
|
||||
controller: nameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText:
|
||||
AppLocalizations.of(context).beneficiaryName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) => value == null || value.isEmpty
|
||||
? AppLocalizations.of(context).nameRequired
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
// 🔹 Account Type Dropdown
|
||||
DropdownButtonFormField<String>(
|
||||
@@ -485,7 +489,8 @@ if (!_isBeneficiaryValidated)
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
fillColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
@@ -496,18 +501,17 @@ if (!_isBeneficiaryValidated)
|
||||
),
|
||||
),
|
||||
),
|
||||
items:
|
||||
[
|
||||
AppLocalizations.of(context).savings,
|
||||
AppLocalizations.of(context).current,
|
||||
]
|
||||
.map(
|
||||
(type) => DropdownMenuItem(
|
||||
value: type,
|
||||
child: Text(type),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
items: [
|
||||
AppLocalizations.of(context).savings,
|
||||
AppLocalizations.of(context).current,
|
||||
]
|
||||
.map(
|
||||
(type) => DropdownMenuItem(
|
||||
value: type,
|
||||
child: Text(type),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
accountType = value!;
|
||||
@@ -525,7 +529,8 @@ if (!_isBeneficiaryValidated)
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
fillColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
@@ -539,8 +544,8 @@ if (!_isBeneficiaryValidated)
|
||||
textInputAction: TextInputAction.done,
|
||||
validator: (value) =>
|
||||
value == null || value.length != 10
|
||||
? AppLocalizations.of(context).enterValidPhone
|
||||
: null,
|
||||
? AppLocalizations.of(context).enterValidPhone
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 35),
|
||||
],
|
||||
@@ -553,13 +558,13 @@ if (!_isBeneficiaryValidated)
|
||||
child: SizedBox(
|
||||
width: 250,
|
||||
child: ElevatedButton(
|
||||
onPressed:
|
||||
validateAndAddBeneficiary,
|
||||
onPressed: validateAndAddBeneficiary,
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
backgroundColor: Theme.of(context).primaryColorDark,
|
||||
foregroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).validateAndAdd),
|
||||
),
|
||||
|
@@ -1,18 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||
import '../../../data/models/user.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../../di/injection.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
//import 'package:kmobile/data/models/user.dart';
|
||||
|
||||
class ManageBeneficiariesScreen extends StatefulWidget {
|
||||
// final List<User> users;
|
||||
// final int selectedIndex;
|
||||
|
||||
const ManageBeneficiariesScreen({super.key});
|
||||
final String customerName;
|
||||
const ManageBeneficiariesScreen({super.key, required this.customerName});
|
||||
|
||||
@override
|
||||
State<ManageBeneficiariesScreen> createState() =>
|
||||
@@ -21,12 +17,8 @@ class ManageBeneficiariesScreen extends StatefulWidget {
|
||||
|
||||
class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
var service = getIt<BeneficiaryService>();
|
||||
// late User selectedUser = widget.users[widget.selectedIndex];
|
||||
//final BeneficiaryService _service = BeneficiaryService();
|
||||
bool _isLoading = true;
|
||||
int selectedAccountIndex = 0;
|
||||
List<Beneficiary> _beneficiaries = [];
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -37,7 +29,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
Future<void> _loadBeneficiaries() async {
|
||||
final data = await service.fetchBeneficiaryList();
|
||||
setState(() {
|
||||
_beneficiaries = data ;
|
||||
_beneficiaries = data;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -68,9 +60,26 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getBankLogo(String? bankName) {
|
||||
if (bankName != null && bankName.toLowerCase().contains('state bank of india')) {
|
||||
return Image.asset(
|
||||
'assets/images/sbi_logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
);
|
||||
} else {
|
||||
return const Icon(
|
||||
Icons.account_balance,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBeneficiaryList() {
|
||||
if (_beneficiaries.isEmpty) {
|
||||
return Center(child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
return Center(
|
||||
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: _beneficiaries.length,
|
||||
@@ -79,16 +88,21 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
||||
child: Text(
|
||||
item.name.isNotEmpty
|
||||
? item.name[0].toUpperCase()
|
||||
: '?',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
child: _getBankLogo(item.bankName),
|
||||
),
|
||||
title: Text(item.name ?? 'Unknown'),
|
||||
subtitle: Text(item.accountNo ?? 'No account number'),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(item.accountNo ?? 'No account number'),
|
||||
if (item.bankName != null && item.bankName!.isNotEmpty)
|
||||
Text(
|
||||
item.bankName!,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -96,6 +110,7 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String customerName = widget.customerName;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context).beneficiaries),
|
||||
@@ -108,7 +123,8 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AddBeneficiaryScreen(),
|
||||
builder: (context) =>
|
||||
AddBeneficiaryScreen(customerName: customerName),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -120,4 +136,4 @@ class _ManageBeneficiariesScreen extends State<ManageBeneficiariesScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -95,7 +95,10 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
return Shimmer.fromColors(
|
||||
baseColor: Theme.of(context).dialogBackgroundColor,
|
||||
highlightColor: Theme.of(context).dialogBackgroundColor,
|
||||
child: Container(width: 100, height: 32, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: Container(
|
||||
width: 100,
|
||||
height: 32,
|
||||
color: Theme.of(context).scaffoldBackgroundColor),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -199,7 +202,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
appBar: AppBar(
|
||||
backgroundColor:Theme.of(context).scaffoldBackgroundColor,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Text(
|
||||
AppLocalizations.of(context).kconnect,
|
||||
@@ -291,7 +294,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Text(
|
||||
"${AppLocalizations.of(context).accountNumber}: ",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color:
|
||||
Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
@@ -300,9 +304,11 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
dropdownColor: Theme.of(context).primaryColor,
|
||||
underline: const SizedBox(),
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
iconEnabledColor:Theme.of(context).dialogBackgroundColor,
|
||||
iconEnabledColor:
|
||||
Theme.of(context).dialogBackgroundColor,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color:
|
||||
Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
items: List.generate(users.length, (index) {
|
||||
@@ -311,7 +317,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
child: Text(
|
||||
users[index].accountNo ?? 'N/A',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: Theme.of(context)
|
||||
.dialogBackgroundColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
@@ -351,13 +358,15 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: Theme.of(context)
|
||||
.dialogBackgroundColor,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
: Icon(
|
||||
Icons.refresh,
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: Theme.of(context)
|
||||
.dialogBackgroundColor,
|
||||
),
|
||||
onPressed: isRefreshing
|
||||
? null
|
||||
@@ -380,7 +389,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
Text(
|
||||
"₹ ",
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color:
|
||||
Theme.of(context).dialogBackgroundColor,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -393,7 +403,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
'0.00'
|
||||
: '********',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor,
|
||||
color: Theme.of(context)
|
||||
.dialogBackgroundColor,
|
||||
fontSize: 40,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -423,7 +434,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
isVisible
|
||||
? Symbols.visibility_lock
|
||||
: Symbols.visibility,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -473,21 +485,21 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildQuickLink(Symbols.send_money,
|
||||
AppLocalizations.of(context).fundTransfer, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
FundTransferBeneficiaryScreen(creditAccountNo: users[selectedAccountIndex].accountNo!, remitterName: users[selectedAccountIndex].name!)));
|
||||
}, disable: false),
|
||||
_buildQuickLink(
|
||||
Symbols.send_money,
|
||||
AppLocalizations.of(context).fundTransfer,
|
||||
Symbols.server_person,
|
||||
AppLocalizations.of(context).accountInfo,
|
||||
() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const FundTransferBeneficiaryScreen()));
|
||||
}, disable: true),
|
||||
_buildQuickLink(Symbols.server_person,
|
||||
AppLocalizations.of(context).accountInfo, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AccountInfoScreen(
|
||||
users: users,
|
||||
selectedIndex: selectedAccountIndex,
|
||||
@@ -496,39 +508,42 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
);
|
||||
},
|
||||
),
|
||||
_buildQuickLink(
|
||||
Symbols.receipt_long,
|
||||
AppLocalizations.of(context).accountStatement,
|
||||
() {
|
||||
Navigator.push(
|
||||
_buildQuickLink(Symbols.receipt_long,
|
||||
AppLocalizations.of(context).accountStatement,
|
||||
() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AccountStatementScreen(
|
||||
accountNo: users[selectedAccountIndex]
|
||||
.accountNo!,
|
||||
)));
|
||||
}),
|
||||
_buildQuickLink(Symbols.checkbook,
|
||||
AppLocalizations.of(context).handleCheque, () {},
|
||||
disable: true),
|
||||
_buildQuickLink(Icons.group,
|
||||
AppLocalizations.of(context).manageBeneficiary, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const ManageBeneficiariesScreen()));
|
||||
}, disable: false),
|
||||
_buildQuickLink(Symbols.support_agent,
|
||||
AppLocalizations.of(context).contactUs, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const EnquiryScreen()));
|
||||
}),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
builder: (context) =>
|
||||
AccountStatementScreen(
|
||||
accountNo: users[selectedAccountIndex]
|
||||
.accountNo!,
|
||||
)));
|
||||
}),
|
||||
_buildQuickLink(Symbols.checkbook,
|
||||
AppLocalizations.of(context).handleCheque, () {},
|
||||
disable: true),
|
||||
_buildQuickLink(Icons.group,
|
||||
AppLocalizations.of(context).manageBeneficiary,
|
||||
() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ManageBeneficiariesScreen(
|
||||
customerName: currAccount.name!)));
|
||||
}, disable: false),
|
||||
_buildQuickLink(Symbols.support_agent,
|
||||
AppLocalizations.of(context).contactUs, () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const EnquiryScreen()));
|
||||
}),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
|
||||
// Recent Transactions
|
||||
Text(
|
||||
@@ -599,17 +614,25 @@ class _DashboardScreenState extends State<DashboardScreen> {
|
||||
leading: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: CircleAvatar(radius: 12, backgroundColor: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: CircleAvatar(
|
||||
radius: 12,
|
||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor),
|
||||
),
|
||||
title: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(height: 10, width: 100, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: Container(
|
||||
height: 10,
|
||||
width: 100,
|
||||
color: Theme.of(context).scaffoldBackgroundColor),
|
||||
),
|
||||
subtitle: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: Container(height: 8, width: 60, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
child: Container(
|
||||
height: 8,
|
||||
width: 60,
|
||||
color: Theme.of(context).scaffoldBackgroundColor),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
@@ -13,14 +13,15 @@ class AccountCard extends StatelessWidget {
|
||||
width: 300,
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Theme.of(context).primaryColor,
|
||||
Theme.of(context).primaryColor.withBlue(200),
|
||||
],
|
||||
),
|
||||
// gradient: LinearGradient(
|
||||
// begin: Alignment.topLeft,
|
||||
// end: Alignment.bottomRight,
|
||||
// colors: [
|
||||
// Theme.of(context).primaryColor,
|
||||
// Theme.of(context).primaryColor.withBlue(200),
|
||||
// ],
|
||||
// ),
|
||||
color: Theme.of(context).primaryColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
@@ -56,12 +57,13 @@ class AccountCard extends StatelessWidget {
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
account.accountNumber,
|
||||
style: TextStyle(color: Theme.of(context).dialogBackgroundColor, fontSize: 16),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor, fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
'${account.currency} ${account.balance.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -70,7 +72,8 @@ class AccountCard extends StatelessWidget {
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
AppLocalizations.of(context).availableBalance,
|
||||
style: TextStyle(color: Theme.of(context).dialogBackgroundColor, fontSize: 12),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).dialogBackgroundColor, fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@@ -0,0 +1,309 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:kmobile/api/services/neft_service.dart';
|
||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
enum TransactionMode { neft, rtgs }
|
||||
|
||||
class FundTransferAmountScreen extends StatefulWidget {
|
||||
final String debitAccountNo;
|
||||
final Beneficiary creditBeneficiary;
|
||||
final String remitterName;
|
||||
|
||||
const FundTransferAmountScreen({
|
||||
super.key,
|
||||
required this.debitAccountNo,
|
||||
required this.creditBeneficiary,
|
||||
required this.remitterName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<FundTransferAmountScreen> createState() =>
|
||||
_FundTransferAmountScreenState();
|
||||
}
|
||||
|
||||
class _FundTransferAmountScreenState extends State<FundTransferAmountScreen> {
|
||||
final _amountController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
TransactionMode _selectedMode = TransactionMode.neft;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_amountController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _getBankLogo(String? bankName) {
|
||||
if (bankName != null && bankName.toLowerCase().contains('state bank of india')) {
|
||||
return Image.asset(
|
||||
'assets/images/sbi_logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
);
|
||||
} else {
|
||||
return const Icon(
|
||||
Icons.account_balance,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _onProceed() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
final amount = double.tryParse(_amountController.text) ?? 0;
|
||||
|
||||
if (_selectedMode == TransactionMode.rtgs && amount < 200000) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Invalid Amount for RTGS'),
|
||||
content: const Text(
|
||||
'RTGS transactions require a minimum amount of 200,000. Please enter a higher amount or select NEFT as the transaction mode.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return; // Stop further execution
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
if (_selectedMode == TransactionMode.neft) {
|
||||
final neftTx = NeftTransaction(
|
||||
fromAccount: widget.debitAccountNo,
|
||||
toAccount: widget.creditBeneficiary.accountNo,
|
||||
amount: _amountController.text,
|
||||
ifscCode: widget.creditBeneficiary.ifscCode,
|
||||
remitterName: widget.remitterName,
|
||||
beneficiaryName: widget.creditBeneficiary.name,
|
||||
tpin: tpin,
|
||||
);
|
||||
final neftService = getIt<NeftService>();
|
||||
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final neftResponse =
|
||||
await neftService.processNeftTransaction(neftTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: neftTx.toAccount,
|
||||
amount: neftTx.amount,
|
||||
currency: 'INR',
|
||||
utr: neftResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
} else {
|
||||
final rtgsTx = RtgsTransaction(
|
||||
fromAccount: widget.debitAccountNo,
|
||||
toAccount: widget.creditBeneficiary.accountNo,
|
||||
amount: _amountController.text,
|
||||
ifscCode: widget.creditBeneficiary.ifscCode,
|
||||
remitterName: widget.remitterName,
|
||||
beneficiaryName: widget.creditBeneficiary.name,
|
||||
tpin: tpin,
|
||||
);
|
||||
final rtgsService = getIt<RtgsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final rtgsResponse =
|
||||
await rtgsService.processRtgsTransaction(rtgsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: rtgsResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: rtgsTx.toAccount,
|
||||
amount: rtgsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: rtgsResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(loc.fundTransfer),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Debit Account (User)
|
||||
Text(
|
||||
loc.debitFrom,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ListTile(
|
||||
leading: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
title: Text(widget.remitterName),
|
||||
subtitle: Text(widget.debitAccountNo),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Credit Account (Beneficiary)
|
||||
Text(
|
||||
"Credit To",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ListTile(
|
||||
leading: _getBankLogo(widget.creditBeneficiary.bankName),
|
||||
title: Text(widget.creditBeneficiary.name),
|
||||
subtitle: Text(widget.creditBeneficiary.accountNo),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Transaction Mode Selection
|
||||
Text(
|
||||
"Select Transaction Mode",
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
),
|
||||
child: ToggleButtons(
|
||||
isSelected: [
|
||||
_selectedMode == TransactionMode.neft,
|
||||
_selectedMode == TransactionMode.rtgs
|
||||
],
|
||||
onPressed: (index) {
|
||||
setState(() {
|
||||
_selectedMode = TransactionMode.values[index];
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
selectedColor: Theme.of(context).colorScheme.onPrimary,
|
||||
fillColor: Theme.of(context).primaryColor,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
borderColor: Colors.transparent,
|
||||
selectedBorderColor: Colors.transparent,
|
||||
splashColor: Theme.of(context).primaryColor.withOpacity(0.1),
|
||||
highlightColor: Theme.of(context).primaryColor.withOpacity(0.05),
|
||||
children: const [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
|
||||
child: Text('NEFT'),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0),
|
||||
child: Text('RTGS'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Amount
|
||||
TextFormField(
|
||||
controller: _amountController,
|
||||
keyboardType: TextInputType.number,
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.amount,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.currency_rupee),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return loc.amountRequired;
|
||||
}
|
||||
if (double.tryParse(value) == null ||
|
||||
double.parse(value) <= 0) {
|
||||
return loc.validAmount;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
|
||||
// Proceed Button
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _onProceed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
),
|
||||
child: const Text("Proceed"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -90,24 +90,26 @@ class _FundTransferBeneficiaryScreen
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/data/models/beneficiary.dart';
|
||||
//import 'package:kmobile/features/beneficiaries/screens/add_beneficiary_screen.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_amount_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../../di/injection.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
|
||||
class FundTransferBeneficiaryScreen extends StatefulWidget {
|
||||
const FundTransferBeneficiaryScreen({super.key});
|
||||
final String creditAccountNo;
|
||||
final String remitterName;
|
||||
const FundTransferBeneficiaryScreen(
|
||||
{super.key, required this.creditAccountNo, required this.remitterName});
|
||||
|
||||
@override
|
||||
State<FundTransferBeneficiaryScreen> createState() =>
|
||||
_ManageBeneficiariesScreen();
|
||||
_FundTransferBeneficiaryScreenState();
|
||||
}
|
||||
|
||||
class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
class _FundTransferBeneficiaryScreenState
|
||||
extends State<FundTransferBeneficiaryScreen> {
|
||||
var service = getIt<BeneficiaryService>();
|
||||
//final BeneficiaryService _service = BeneficiaryService();
|
||||
bool _isLoading = true;
|
||||
List<Beneficiary> _beneficiaries = [];
|
||||
|
||||
@@ -120,7 +122,7 @@ class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
Future<void> _loadBeneficiaries() async {
|
||||
final data = await service.fetchBeneficiaryList();
|
||||
setState(() {
|
||||
_beneficiaries = data ;
|
||||
_beneficiaries = data;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -132,7 +134,7 @@ class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
baseColor: Colors.grey.shade300,
|
||||
highlightColor: Colors.grey.shade100,
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
leading: const CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
@@ -151,27 +153,61 @@ class _ManageBeneficiariesScreen extends State<FundTransferBeneficiaryScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _getBankLogo(String? bankName) {
|
||||
if (bankName != null && bankName.toLowerCase().contains('state bank of india')) {
|
||||
return Image.asset(
|
||||
'assets/images/sbi_logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
);
|
||||
} else {
|
||||
return const Icon(
|
||||
Icons.account_balance,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBeneficiaryList() {
|
||||
if (_beneficiaries.isEmpty) {
|
||||
return Center(child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
return Center(
|
||||
child: Text(AppLocalizations.of(context).noBeneficiaryFound));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: _beneficiaries.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = _beneficiaries[index];
|
||||
final beneficiary = _beneficiaries[index];
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: Theme.of(context).primaryColor.withOpacity(0.2),
|
||||
child: Text(
|
||||
item.name.isNotEmpty
|
||||
? item.name[0].toUpperCase()
|
||||
: '?',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
child: _getBankLogo(beneficiary.bankName),
|
||||
),
|
||||
title: Text(item.name ?? 'Unknown'),
|
||||
subtitle: Text(item.accountNo ?? 'No account number'),
|
||||
title: Text(beneficiary.name),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(beneficiary.accountNo),
|
||||
if (beneficiary.bankName != null && beneficiary.bankName!.isNotEmpty)
|
||||
Text(
|
||||
beneficiary.bankName!,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FundTransferAmountScreen(
|
||||
debitAccountNo: widget.creditAccountNo,
|
||||
creditBeneficiary: beneficiary,
|
||||
remitterName: widget.remitterName,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@@ -375,6 +375,14 @@ class _PaymentAnimationScreenState extends State<PaymentAnimationScreen> {
|
||||
"Date: ${response.date!.toLocal().toIso8601String()}",
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
if (response.utr != null && response.utr!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
'UTR: ${response.utr}',
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
|
@@ -1,27 +1,24 @@
|
||||
// ignore_for_file: unused_field
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:kmobile/api/services/auth_service.dart';
|
||||
import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/tpin_prompt_screen.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class TransactionPinScreen extends StatefulWidget {
|
||||
final Transfer transactionData;
|
||||
const TransactionPinScreen({super.key, required this.transactionData});
|
||||
final Future<void> Function(BuildContext, String) onPinCompleted;
|
||||
|
||||
const TransactionPinScreen({super.key, required this.onPinCompleted});
|
||||
|
||||
@override
|
||||
State<TransactionPinScreen> createState() => _TransactionPinScreen();
|
||||
State<TransactionPinScreen> createState() => _TransactionPinScreenState();
|
||||
}
|
||||
|
||||
class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
class _TransactionPinScreenState extends State<TransactionPinScreen> {
|
||||
final List<String> _pin = [];
|
||||
bool _loading = true;
|
||||
bool _isSubmitting = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -55,6 +52,7 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
}
|
||||
|
||||
void _onKeyPressed(String value) {
|
||||
if (_isSubmitting) return;
|
||||
setState(() {
|
||||
if (value == 'back') {
|
||||
if (_pin.isNotEmpty) _pin.removeLast();
|
||||
@@ -64,6 +62,27 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _submitPin() async {
|
||||
if (_isSubmitting) return;
|
||||
|
||||
if (_pin.length == 6) {
|
||||
setState(() => _isSubmitting = true);
|
||||
try {
|
||||
await widget.onPinCompleted(context, _pin.join());
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _isSubmitting = false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).enter6DigitTpin),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildPinIndicators() {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -75,7 +94,9 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Theme.of(context).primaryColor, width: 2),
|
||||
color: index < _pin.length ? Theme.of(context).primaryColor : Colors.transparent,
|
||||
color: index < _pin.length
|
||||
? Theme.of(context).primaryColor
|
||||
: Colors.transparent,
|
||||
),
|
||||
);
|
||||
}),
|
||||
@@ -85,30 +106,15 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
Widget _buildKey(String label, {IconData? icon}) {
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
if (label == 'back') {
|
||||
_onKeyPressed('back');
|
||||
} else if (label == 'done') {
|
||||
// Handle submit if needed
|
||||
if (_pin.length == 6) {
|
||||
await sendTransaction();
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context).enter6DigitTpin),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
_onKeyPressed(label);
|
||||
}
|
||||
},
|
||||
onTap: () => label == 'done' ? _submitPin() : _onKeyPressed(label),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: Center(
|
||||
child: icon != null
|
||||
? Icon(icon, size: 28)
|
||||
: Text(label, style: const TextStyle(fontSize: 24)),
|
||||
child: _isSubmitting && label == 'done'
|
||||
? const CircularProgressIndicator()
|
||||
: icon != null
|
||||
? Icon(icon, size: 28)
|
||||
: Text(label, style: const TextStyle(fontSize: 24)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -133,30 +139,6 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> sendTransaction() async {
|
||||
final paymentService = getIt<PaymentService>();
|
||||
final transfer = widget.transactionData;
|
||||
transfer.tpin = _pin.join();
|
||||
try {
|
||||
final paymentResponse = paymentService.processQuickPayWithinBank(
|
||||
transfer,
|
||||
);
|
||||
|
||||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
PaymentAnimationScreen(paymentResponse: paymentResponse),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -169,26 +151,28 @@ class _TransactionPinScreen extends State<TransactionPinScreen> {
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).tpin,
|
||||
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
style: const TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
|
||||
),
|
||||
centerTitle: false,
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
AppLocalizations.of(context).enterTpin,
|
||||
style: TextStyle(fontSize: 18),
|
||||
body: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20.0),
|
||||
child: Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
AppLocalizations.of(context).enterTpin,
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPinIndicators(),
|
||||
const Spacer(),
|
||||
_buildKeypad(),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildPinIndicators(),
|
||||
const Spacer(),
|
||||
_buildKeypad(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -20,22 +20,22 @@ class ColorThemeDialog extends StatelessWidget {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
// ListTile(
|
||||
// leading: const CircleAvatar(backgroundColor: Colors.green),
|
||||
// title: const Text('Green'),
|
||||
// onTap: () {
|
||||
// context.read<ThemeCubit>().changeTheme(ThemeType.green);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
// ListTile(
|
||||
// leading: const CircleAvatar(backgroundColor: Colors.orange),
|
||||
// title: const Text('Orange'),
|
||||
// onTap: () {
|
||||
// context.read<ThemeCubit>().changeTheme(ThemeType.orange);
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
ListTile(
|
||||
leading: const CircleAvatar(backgroundColor: Colors.green),
|
||||
title: const Text('Green'),
|
||||
onTap: () {
|
||||
context.read<ThemeCubit>().changeTheme(ThemeType.green);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const CircleAvatar(backgroundColor: Colors.orange),
|
||||
title: const Text('Orange'),
|
||||
onTap: () {
|
||||
context.read<ThemeCubit>().changeTheme(ThemeType.orange);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const CircleAvatar(backgroundColor: Colors.blue),
|
||||
title: Text(AppLocalizations.of(context).blue),
|
||||
@@ -48,4 +48,3 @@ class ColorThemeDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,19 @@
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:kmobile/api/services/neft_service.dart';
|
||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../../di/injection.dart';
|
||||
import '../../../../api/services/beneficiary_service.dart';
|
||||
|
||||
class QuickPayOutsideBankScreen extends StatefulWidget {
|
||||
final String debitAccount;
|
||||
@@ -26,9 +36,12 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
final ifscController = TextEditingController();
|
||||
final phoneController = TextEditingController();
|
||||
final amountController = TextEditingController();
|
||||
final service = getIt<BeneficiaryService>();
|
||||
|
||||
//String accountType = 'Savings';
|
||||
late String accountType;
|
||||
bool _isValidating = false;
|
||||
bool _isBeneficiaryValidated = false;
|
||||
String? _validationError;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -40,12 +53,71 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
//final List<String> transactionModes = ['NEFT', 'RTGS', 'IMPS'];
|
||||
void _validateIFSC() async {
|
||||
final ifsc = ifscController.text.trim().toUpperCase();
|
||||
if (ifsc.isEmpty) return;
|
||||
|
||||
final result = await service.validateIFSC(ifsc);
|
||||
|
||||
if (mounted) {
|
||||
if (result.bankName == '') {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(AppLocalizations.of(context).invalidIfsc)),
|
||||
);
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
} else {
|
||||
bankNameController.text = result.bankName;
|
||||
branchNameController.text = result.branchName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _validateBeneficiary() async {
|
||||
FocusScope.of(context).unfocus();
|
||||
setState(() {
|
||||
_isValidating = true;
|
||||
_validationError = null;
|
||||
_isBeneficiaryValidated = false;
|
||||
nameController.text = ''; // clear previous name
|
||||
});
|
||||
|
||||
final String accountNo = accountNumberController.text.trim();
|
||||
final String ifsc = ifscController.text.trim();
|
||||
// TODO: Replace with actual remitter name
|
||||
final String remitter = "Unknown";
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
final String beneficiaryName = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
nameController.text = beneficiaryName;
|
||||
_isBeneficiaryValidated = true;
|
||||
_validationError = null;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_validationError = e.toString();
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isValidating = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> transactionModes(BuildContext context) {
|
||||
return [
|
||||
AppLocalizations.of(context).neft,
|
||||
AppLocalizations.of(context).rtgs,
|
||||
AppLocalizations.of(context).imps,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -65,6 +137,131 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onProceedToPay() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
if (!_isBeneficiaryValidated) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Please validate beneficiary details first.')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final amount = double.tryParse(amountController.text) ?? 0;
|
||||
final selectedMode = transactionModes(context)[selectedTransactionIndex];
|
||||
final isRtgs = selectedMode == AppLocalizations.of(context).rtgs;
|
||||
|
||||
if (isRtgs && amount < 200000) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Invalid Amount for RTGS'),
|
||||
content: const Text(
|
||||
'RTGS transactions require a minimum amount of 200,000. Please enter a higher amount or select NEFT as the transaction mode.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(ctx).pop(),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
if (!isRtgs) {
|
||||
// NEFT
|
||||
final neftTx = NeftTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown", // TODO: Get actual remitter name
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
final neftService = getIt<NeftService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
PaymentAnimationScreen(paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final neftResponse =
|
||||
await neftService.processNeftTransaction(neftTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: neftTx.toAccount,
|
||||
amount: neftTx.amount,
|
||||
currency: 'INR',
|
||||
utr: neftResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
} else {
|
||||
// RTGS
|
||||
final rtgsTx = RtgsTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown", // TODO: Get actual remitter name
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
final rtgsService = getIt<RtgsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
PaymentAnimationScreen(paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final rtgsResponse =
|
||||
await rtgsService.processRtgsTransaction(rtgsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: rtgsResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: rtgsTx.toAccount,
|
||||
amount: rtgsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: rtgsResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -103,19 +300,24 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
child: ListView(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
children: [
|
||||
Text(AppLocalizations.of(context).debitFrom),
|
||||
Text(
|
||||
widget.debitAccount,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
AppLocalizations.of(context).debitFrom,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Card(
|
||||
elevation: 0,
|
||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: ListTile(
|
||||
leading: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
title: Text(widget.debitAccount),
|
||||
subtitle: Text(AppLocalizations.of(context).ownBank),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).accountNumber,
|
||||
@@ -134,11 +336,17 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
keyboardType: TextInputType.number,
|
||||
obscureText: true,
|
||||
textInputAction: TextInputAction.next,
|
||||
onChanged: (value) {
|
||||
nameController.clear();
|
||||
setState(() {
|
||||
_isBeneficiaryValidated = false;
|
||||
});
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).accountNumberRequired;
|
||||
} else if (value.length != 11) {
|
||||
return AppLocalizations.of(context).validAccountNumber;
|
||||
} else if (value.length < 7 || value.length > 20) {
|
||||
return 'Account number must be between 7 and 20 digits';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -173,79 +381,6 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).name,
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: nameController,
|
||||
keyboardType: TextInputType.name,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).nameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).bankName,
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: bankNameController,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).bankNameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).branchName,
|
||||
border: OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
controller: branchNameController,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).branchNameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -265,9 +400,27 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
),
|
||||
controller: ifscController,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
_validateIFSC();
|
||||
},
|
||||
onChanged: (value) {
|
||||
final trimmed = value.trim().toUpperCase();
|
||||
if (trimmed.length < 11) {
|
||||
// clear bank/branch if backspace or changed
|
||||
bankNameController.clear();
|
||||
branchNameController.clear();
|
||||
}
|
||||
},
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).ifscRequired;
|
||||
final pattern = RegExp(r'^[A-Z]{4}0[A-Z0-9]{6}$');
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return AppLocalizations.of(context).enterIfsc;
|
||||
} else if (!pattern.hasMatch(
|
||||
value.trim().toUpperCase(),
|
||||
)) {
|
||||
return AppLocalizations.of(
|
||||
context,
|
||||
).invalidIfscFormat;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
@@ -307,6 +460,113 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
controller: bankNameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).bankName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
TextFormField(
|
||||
controller: branchNameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).branchName,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!_isBeneficiaryValidated)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isValidating
|
||||
? null
|
||||
: () {
|
||||
if (confirmAccountNumberController
|
||||
.text ==
|
||||
accountNumberController.text) {
|
||||
_validateBeneficiary();
|
||||
} else {
|
||||
setState(() {
|
||||
_validationError =
|
||||
'Account numbers do not match.';
|
||||
});
|
||||
}
|
||||
},
|
||||
child: _isValidating
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2),
|
||||
)
|
||||
: const Text('Validate Beneficiary'),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_validationError != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 24.0),
|
||||
child: Text(
|
||||
_validationError!,
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
controller: nameController,
|
||||
enabled: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context).name,
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).dialogBackgroundColor,
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.black),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Colors.black, width: 2),
|
||||
),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return AppLocalizations.of(context).nameRequired;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Row(
|
||||
children: [
|
||||
@@ -382,38 +642,16 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: SwipeButton.expand(
|
||||
thumb: Icon(Icons.arrow_forward, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
activeThumbColor: Theme.of(context).primaryColorDark,
|
||||
activeTrackColor: Theme.of(context).primaryColorLight,
|
||||
thumb: Icon(Icons.arrow_forward, color: Theme.of(context).dialogBackgroundColor),
|
||||
activeThumbColor: Theme.of(context).primaryColor,
|
||||
activeTrackColor: Theme.of(context).colorScheme.secondary.withAlpha(100),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
height: 56,
|
||||
onSwipe: _onProceedToPay,
|
||||
child: Text(
|
||||
AppLocalizations.of(context).swipeToPay,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
onSwipe: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
// Perform payment logic
|
||||
final selectedMode = transactionModes(
|
||||
context,
|
||||
)[selectedTransactionIndex];
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'${AppLocalizations.of(context).payingVia} $selectedMode...',
|
||||
),
|
||||
),
|
||||
);
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) =>
|
||||
// const TransactionPinScreen(
|
||||
// transactionData: {},
|
||||
// transactionCode: 'PAYMENT',
|
||||
// )));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -457,4 +695,4 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@@ -64,7 +64,6 @@ class _QuickPayScreen extends State<QuickPayScreen> {
|
||||
),
|
||||
const Divider(height: 1),
|
||||
QuickPayManagementTile(
|
||||
disable: true,
|
||||
icon: Symbols.output_circle,
|
||||
label: AppLocalizations.of(context).outsideBank,
|
||||
onTap: () {
|
||||
|
@@ -1,9 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
import 'package:kmobile/api/services/payment_service.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/transfer.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/features/fund_transfer/screens/payment_animation.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../fund_transfer/screens/transaction_pin_screen.dart';
|
||||
@@ -363,12 +367,26 @@ class _QuickPayWithinBankScreen extends State<QuickPayWithinBankScreen> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
transactionData: Transfer(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
toAccountType: _selectedAccountType!,
|
||||
amount: amountController.text,
|
||||
),
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
final transfer = Transfer(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
toAccountType: _selectedAccountType!,
|
||||
amount: amountController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
|
||||
final paymentService = getIt<PaymentService>();
|
||||
final paymentResponseFuture = paymentService
|
||||
.processQuickPayWithinBank(transfer);
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: paymentResponseFuture),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user