Till PMSBY/JJBY test sim binded apk release

This commit is contained in:
2026-03-16 16:39:31 +05:30
parent dfdc293309
commit 298c0c199f
3 changed files with 150 additions and 36 deletions

View File

@@ -126,4 +126,27 @@ class BeneficiaryService {
throw Exception('Unexpected error: ${e.toString()}'); throw Exception('Unexpected error: ${e.toString()}');
} }
} }
Future<Response> updateLimit({
required String beneficiaryAccountNo,
required String newLimit,
}) async {
log('inside update limit of beneficiary service');
final response = await _dio.patch(
'/api/beneficiary/update-limit',
data: {
'beneficiaryAccountNo': beneficiaryAccountNo,
'newLimit': int.tryParse(newLimit),
},
options: Options(
sendTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 60),
),
);
if (response.statusCode != 200) {
throw Exception("INTERNAL SERVER ERROR");
}
return response;
}
} }

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kmobile/data/models/beneficiary.dart'; import 'package:kmobile/data/models/beneficiary.dart';
import 'package:kmobile/di/injection.dart'; import 'package:kmobile/di/injection.dart';
import 'package:kmobile/widgets/bank_logos.dart'; import 'package:kmobile/widgets/bank_logos.dart';
@@ -6,16 +7,39 @@ import 'package:kmobile/api/services/beneficiary_service.dart';
import '../../../l10n/app_localizations.dart'; import '../../../l10n/app_localizations.dart';
class BeneficiaryDetailsScreen extends StatelessWidget { class BeneficiaryDetailsScreen extends StatefulWidget {
final Beneficiary beneficiary; final Beneficiary beneficiary;
BeneficiaryDetailsScreen({super.key, required this.beneficiary}); const BeneficiaryDetailsScreen({super.key, required this.beneficiary});
@override
State<BeneficiaryDetailsScreen> createState() =>
_BeneficiaryDetailsScreenState();
}
class _BeneficiaryDetailsScreenState extends State<BeneficiaryDetailsScreen> {
final service = getIt<BeneficiaryService>(); final service = getIt<BeneficiaryService>();
late String _currentLimit;
final _limitController = TextEditingController();
@override
void initState() {
super.initState();
_currentLimit = (widget.beneficiary.transactionLimit == null ||
widget.beneficiary.transactionLimit!.isEmpty)
? 'N/A'
: widget.beneficiary.transactionLimit!;
}
@override
void dispose() {
_limitController.dispose();
super.dispose();
}
void _deleteBeneficiary(BuildContext context) async { void _deleteBeneficiary(BuildContext context) async {
try { try {
await service.deleteBeneficiary(beneficiary.accountNo); await service.deleteBeneficiary(widget.beneficiary.accountNo);
if (!context.mounted) { if (!context.mounted) {
return; return;
} }
@@ -77,6 +101,73 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
); );
} }
Future<void> _showEditLimitDialog() async {
_limitController.text = _currentLimit == 'N/A' ? '' : _currentLimit;
await showDialog(
context: context,
builder: (dialogContext) {
final localizations = AppLocalizations.of(dialogContext);
final theme = Theme.of(dialogContext);
return AlertDialog(
title: Text(localizations.editLimit),
content: TextField(
controller: _limitController,
autofocus: true,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d+')),
],
decoration: InputDecoration(
labelText: localizations.limitAmount,
prefixText: '',
border: const OutlineInputBorder(),
),
),
actions: [
TextButton(
onPressed: () => Navigator.of(dialogContext).pop(),
child: Text(localizations.cancel),
),
ElevatedButton(
onPressed: () async {
final value = _limitController.text;
if (value.isEmpty || int.tryParse(value) == null) return;
try {
await service.updateLimit(
beneficiaryAccountNo: widget.beneficiary.accountNo,
newLimit: value,
);
if (!mounted) return;
setState(() {
_currentLimit = value;
});
Navigator.of(dialogContext).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(localizations.limitUpdatedSuccess),
behavior: SnackBarBehavior.floating,
),
);
} catch (e) {
Navigator.of(dialogContext).pop();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("${localizations.error}: $e"),
behavior: SnackBarBehavior.floating,
backgroundColor: theme.colorScheme.error,
),
);
}
},
child: Text(localizations.save),
),
],
);
},
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@@ -96,11 +187,11 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
CircleAvatar( CircleAvatar(
radius: 24, radius: 24,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
child: getBankLogo(beneficiary.bankName, context), child: getBankLogo(widget.beneficiary.bankName, context),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
Text( Text(
beneficiary.name, widget.beneficiary.name,
style: const TextStyle( style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold), fontSize: 20, fontWeight: FontWeight.bold),
), ),
@@ -108,29 +199,28 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
), ),
const SizedBox(height: 24), const SizedBox(height: 24),
_buildDetailRow('${AppLocalizations.of(context).bankName} ', _buildDetailRow('${AppLocalizations.of(context).bankName} ',
beneficiary.bankName ?? 'N/A'), widget.beneficiary.bankName ?? 'N/A'),
_buildDetailRow( _buildDetailRow(
'${AppLocalizations.of(context).accountNumber} ', '${AppLocalizations.of(context).accountNumber} ',
beneficiary.accountNo), widget.beneficiary.accountNo),
_buildDetailRow( _buildDetailRow(
'${AppLocalizations.of(context).accountType} ', '${AppLocalizations.of(context).accountType} ',
beneficiary.accountType), widget.beneficiary.accountType),
_buildDetailRow('${AppLocalizations.of(context).ifscCode} ', _buildDetailRow('${AppLocalizations.of(context).ifscCode} ',
beneficiary.ifscCode), widget.beneficiary.ifscCode),
_buildDetailRow('${AppLocalizations.of(context).branchName} ', _buildDetailRow('${AppLocalizations.of(context).branchName} ',
beneficiary.branchName ?? 'N/A'), widget.beneficiary.branchName ?? 'N/A'),
_buildDetailRow("Beneficiary Transactional Limit", beneficiary.transactionLimit ?? 'N/A'), _buildDetailRow(
"Beneficiary Transactional Limit", _currentLimit),
const Spacer(), const Spacer(),
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
// ElevatedButton.icon( ElevatedButton.icon(
// onPressed: () { onPressed: _showEditLimitDialog,
// // Set Transaction Limit for this beneficiary icon: const Icon(Icons.currency_rupee),
// }, label: Text(AppLocalizations.of(context).editLimit),
// icon: const Icon(Icons.currency_rupee), ),
// label: const Text('Set Limit'),
// ),
ElevatedButton.icon( ElevatedButton.icon(
onPressed: () { onPressed: () {
// Delete beneficiary option // Delete beneficiary option
@@ -184,3 +274,4 @@ class BeneficiaryDetailsScreen extends StatelessWidget {
); );
} }
} }

View File

@@ -50,24 +50,24 @@ class _GovSchemeScreenState extends State<GovSchemeScreen> {
}, },
), ),
), ),
Expanded( // Expanded(
child: GovSchemeTile( // child: GovSchemeTile(
logoText: "APY", // logoText: "APY",
label: l10n.registerForAtalPensionYojana, // label: l10n.registerForAtalPensionYojana,
subtitle: l10n.secureYourFutureAPY, // subtitle: l10n.secureYourFutureAPY,
onTap: () { // onTap: () {
Navigator.push( // Navigator.push(
context, // context,
MaterialPageRoute( // MaterialPageRoute(
builder: (context) => APYScreen( // builder: (context) => APYScreen(
users: widget.users, // users: widget.users,
selectedIndex: widget.selectedIndex, // selectedIndex: widget.selectedIndex,
), // ),
), // ),
);// Action for APY will be added later // );// Action for APY will be added later
}, // },
), // ),
), // ),
], ],
), ),
), ),