Fromatting and localizations

This commit is contained in:
2025-12-31 12:44:39 +05:30
parent 60270a5fa9
commit 54a7b8f1b0
21 changed files with 501 additions and 194 deletions

View File

@@ -4,6 +4,7 @@ import 'package:kmobile/di/injection.dart';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
class StopSingleChequeScreen extends StatefulWidget {
final User selectedAccount;
@@ -63,7 +64,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
),
actions: <Widget>[
TextButton(
child: const Text('Close'),
child: Text(AppLocalizations.of(context).closeButton),
onPressed: () {
Navigator.of(context).pop();
},
@@ -78,7 +79,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Stop Single Cheque'),
title: Text(AppLocalizations.of(context).stopSingleChequeTitle),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
@@ -96,20 +97,22 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
height: 40,
),
title: Text(widget.selectedAccount.accountNo!),
subtitle: const Text("Account Number"),
subtitle:
Text(AppLocalizations.of(context).accountNumberLabel),
),
),
const SizedBox(height: 24),
TextFormField(
controller: _stopFromChequeNoController,
decoration: const InputDecoration(
labelText: 'Cheque Number *',
decoration: InputDecoration(
labelText: AppLocalizations.of(context).chequeNumberLabel,
border: OutlineInputBorder(),
),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a cheque number';
return AppLocalizations.of(context)
.pleaseEnterChequeNumberError;
}
final chequeNumber = int.tryParse(value);
final fromCheque = int.tryParse(widget.fromCheque);
@@ -117,10 +120,12 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
if (chequeNumber == null ||
fromCheque == null ||
toCheque == null) {
return 'Invalid cheque number format';
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
return 'Cheque number must be between ${widget.fromCheque} and ${widget.toCheque}';
return AppLocalizations.of(context).chequeNumberRangeError(
widget.fromCheque, widget.toCheque);
}
return null;
},
@@ -129,53 +134,54 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
TextFormField(
initialValue: widget.instrType,
readOnly: true,
decoration: const InputDecoration(
labelText: 'Instrument Type *',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).instrumentTypeLabel,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 16),
TextFormField(
controller: _stopIssueDateController,
decoration: const InputDecoration(
labelText: 'Stop Issue Date',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopIssueDateLabel,
border: const OutlineInputBorder(),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopExpiryDateController,
decoration: const InputDecoration(
labelText: 'Stop Expiry Date',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopExpiryDateLabel,
border: const OutlineInputBorder(),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopAmountController,
decoration: const InputDecoration(
labelText: 'Stop Amount',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopAmountHint,
border: const OutlineInputBorder(),
),
keyboardType: TextInputType.number,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopCommentController,
decoration: const InputDecoration(
labelText: 'Stop Comment',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopCommentHint,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 16),
TextFormField(
initialValue: _formatDate(widget.date),
readOnly: true,
decoration: const InputDecoration(
labelText: 'Chequebook Issue Date',
border: OutlineInputBorder(),
decoration: InputDecoration(
labelText:
AppLocalizations.of(context).chequebookIssueDateHint,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 32),
@@ -187,7 +193,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
Navigator.pop(context);
try {
final response = await _chequeService.stopCheque(
accountno: widget.selectedAccount.accountNo!,
@@ -197,8 +203,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
stopToChequeNo:
_stopFromChequeNoController.text,
stopIssueDate: _stopIssueDateController.text,
stopExpiryDate:
_stopExpiryDateController.text,
stopExpiryDate: _stopExpiryDateController.text,
stopAmount: _stopAmountController.text,
stopComment: _stopCommentController.text,
chequeIssueDate: widget.date,
@@ -206,7 +211,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
);
if (!mounted) return;
final decodedResponse = jsonDecode(response);
final status = decodedResponse['status'];
final status = decodedResponse['status'];
final message = decodedResponse['message'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
@@ -218,9 +223,11 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
print(e.toString());
try {
final errorBodyString = e.toString().split('Exception: ')[1];
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') && errorBody['error'] == 'INCORRECT_TPIN') {
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
} else {
@@ -238,7 +245,7 @@ class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
);
}
},
child: const Text('Stop Cheque'),
child: Text(AppLocalizations.of(context).stopChequeButton),
),
],
),