Localization changes #4
This commit is contained in:
@@ -46,7 +46,7 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
accountType = AppLocalizations.of(context).savings;
|
||||
accountType = 'Savings';
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -87,18 +87,16 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
try {
|
||||
|
||||
String beneficiaryName;
|
||||
if(ifsc.toLowerCase().contains('kace')){
|
||||
beneficiaryName = await service.validateBeneficiaryWithinBank(accountNo);
|
||||
}
|
||||
|
||||
else{
|
||||
beneficiaryName = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
if (ifsc.toLowerCase().contains('kace')) {
|
||||
beneficiaryName =
|
||||
await service.validateBeneficiaryWithinBank(accountNo);
|
||||
} else {
|
||||
beneficiaryName = await service.validateBeneficiary(
|
||||
accountNo: accountNo,
|
||||
ifscCode: ifsc,
|
||||
remitterName: remitter,
|
||||
);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
@@ -129,8 +127,9 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
// Ensure beneficiary is validated before proceeding to TPIN
|
||||
if (!_isBeneficiaryValidated) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Please validate beneficiary details first.')),
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.pleaseValidateBeneficiaryDetailsFirst)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -517,8 +516,8 @@ class _AddBeneficiaryScreen extends State<AddBeneficiaryScreen> {
|
||||
),
|
||||
),
|
||||
items: [
|
||||
AppLocalizations.of(context).savings,
|
||||
AppLocalizations.of(context).current,
|
||||
'Savings',
|
||||
'Current',
|
||||
]
|
||||
.map(
|
||||
(type) => DropdownMenuItem(
|
||||
|
@@ -4,6 +4,8 @@ import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/widgets/bank_logos.dart';
|
||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
class BeneficiaryDetailsScreen extends StatelessWidget {
|
||||
final Beneficiary beneficiary;
|
||||
|
||||
@@ -11,68 +13,73 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
|
||||
|
||||
final service = getIt<BeneficiaryService>();
|
||||
|
||||
void _deleteBeneficiary(BuildContext context) async {
|
||||
try {
|
||||
await service.deleteBeneficiary(beneficiary.accountNo);
|
||||
_showSuccessDialog(context);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Failed to delete beneficiary: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _showSuccessDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Success'),
|
||||
content: const Text('Beneficiary deleted successfully.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteConfirmationDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Delete Beneficiary'),
|
||||
content:
|
||||
const Text('Are you sure you want to delete this beneficiary?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Delete'),
|
||||
onPressed: () {
|
||||
//Navigator.of(context).pop();
|
||||
_deleteBeneficiary(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
} @override
|
||||
void _deleteBeneficiary(BuildContext context) async {
|
||||
try {
|
||||
await service.deleteBeneficiary(beneficiary.accountNo);
|
||||
_showSuccessDialog(context);
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'${AppLocalizations.of(context).failedToDeleteBeneficiary}: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _showSuccessDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).success),
|
||||
content:
|
||||
Text(AppLocalizations.of(context).beneficiaryDeletedSuccessfully),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).ok),
|
||||
onPressed: () {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteConfirmationDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).deleteBeneficiary),
|
||||
content: Text(AppLocalizations.of(context)
|
||||
.areYouSureYouWantToDeleteThisBeneficiary),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(AppLocalizations.of(context).delete),
|
||||
onPressed: () {
|
||||
//Navigator.of(context).pop();
|
||||
_deleteBeneficiary(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Beneficiary Details'),
|
||||
title: Text(AppLocalizations.of(context).beneficiarydetails),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -95,11 +102,16 @@ void _showDeleteConfirmationDialog(BuildContext context) {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
_buildDetailRow('Beneficiary Name', beneficiary.bankName ?? 'N/A'),
|
||||
_buildDetailRow('Account No.', beneficiary.accountNo),
|
||||
_buildDetailRow('Account Type', beneficiary.accountType),
|
||||
_buildDetailRow('IFSC Code', beneficiary.ifscCode),
|
||||
_buildDetailRow('Branch Name', beneficiary.branchName ?? 'N/A'),
|
||||
_buildDetailRow('${AppLocalizations.of(context).bankName} ',
|
||||
beneficiary.bankName ?? 'N/A'),
|
||||
_buildDetailRow('${AppLocalizations.of(context).accountNumber} ',
|
||||
beneficiary.accountNo),
|
||||
_buildDetailRow('${AppLocalizations.of(context).accountType} ',
|
||||
beneficiary.accountType),
|
||||
_buildDetailRow('${AppLocalizations.of(context).ifscCode} ',
|
||||
beneficiary.ifscCode),
|
||||
_buildDetailRow('${AppLocalizations.of(context).branchName} ',
|
||||
beneficiary.branchName ?? 'N/A'),
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
@@ -114,10 +126,10 @@ void _showDeleteConfirmationDialog(BuildContext context) {
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
// Delete beneficiary option
|
||||
_showDeleteConfirmationDialog(context);
|
||||
_showDeleteConfirmationDialog(context);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
label: const Text('Delete'),
|
||||
label: Text(AppLocalizations.of(context).delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user