Revoke Stop base Created

This commit is contained in:
2026-02-02 18:18:04 +05:30
parent 5f8c88342e
commit dc51690292
5 changed files with 799 additions and 489 deletions

View File

@@ -76,9 +76,9 @@ Dio _createDioClient() {
final dio = Dio( final dio = Dio(
BaseOptions( BaseOptions(
baseUrl: baseUrl:
// 'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com', //test 'http://lb-test-mobile-banking-app-192209417.ap-south-1.elb.amazonaws.com', //test
//'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod //'http://lb-kccb-mobile-banking-app-848675342.ap-south-1.elb.amazonaws.com', //prod
'https://kccbmbnk.net', //prod small //'https://kccbmbnk.net', //prod small
connectTimeout: const Duration(seconds: 60), connectTimeout: const Duration(seconds: 60),
receiveTimeout: const Duration(seconds: 60), receiveTimeout: const Duration(seconds: 60),
headers: { headers: {

View File

@@ -85,7 +85,7 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => RevokeStopSingleChequeScreen( builder: (context) => RevokeStopChequeScreen(
users: users, users: users,
selectedIndex: selectedAccountIndex, selectedIndex: selectedAccountIndex,
), ),

View File

@@ -0,0 +1,337 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/di/injection.dart';
import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart';
class RevokeStopMultipleChequesScreen extends StatefulWidget {
final User selectedAccount;
final String date;
final String instrType;
final String fromCheque;
final String toCheque;
const RevokeStopMultipleChequesScreen(
{super.key,
required this.selectedAccount,
required this.date,
required this.instrType,
required this.fromCheque,
required this.toCheque});
@override
State<RevokeStopMultipleChequesScreen> createState() =>
_RevokeStopMultipleChequesScreenState();
}
class _RevokeStopMultipleChequesScreenState extends State<RevokeStopMultipleChequesScreen> {
final _formKey = GlobalKey<FormState>();
final _stopFromChequeNoController = TextEditingController();
final _stopToChequeNoController = TextEditingController();
final _stopIssueDateController = TextEditingController();
final _stopExpiryDateController = TextEditingController();
final _stopAmountController = TextEditingController();
final _chequeService = getIt<ChequeService>();
String? _selectedComment;
final _otherCommentController = TextEditingController();
bool _showOtherCommentField = false;
final List<String> _commentOptions = [
'Cheque Found',
'Cheque Fixed',
'Other'
];
Future<void> _selectDate(TextEditingController controller) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime.now(),
lastDate: DateTime(2101),
);
if (picked != null) {
setState(() {
controller.text =
'${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
});
}
}
Future<void> _showResponseDialog(String title, String message) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
Text(message),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context).stopMultipleChequesTitle),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: ListView(
children: [
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.selectedAccount.accountNo!),
subtitle:
Text(AppLocalizations.of(context).accountNumberTitle),
),
),
const SizedBox(height: 24),
TextFormField(
controller: _stopFromChequeNoController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).fromChequeNumberHint,
border: const OutlineInputBorder(),
errorMaxLines: 2,
),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context)
.pleaseEnterChequeNumberError;
}
final chequeNumber = int.tryParse(value);
final fromCheque = int.tryParse(widget.fromCheque);
final toCheque = int.tryParse(widget.toCheque);
if (chequeNumber == null ||
fromCheque == null ||
toCheque == null) {
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
// return AppLocalizations.of(context).chequeNumberRangeError(
// widget.fromCheque, widget.toCheque);
// }
return null;
},
),
const SizedBox(height: 16),
TextFormField(
controller: _stopToChequeNoController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).toChequeNumberHint,
border: const OutlineInputBorder(),
errorMaxLines: 2,
),
keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return AppLocalizations.of(context)
.pleaseEnterChequeNumberError;
}
final chequeNumber = int.tryParse(value);
final fromCheque = int.tryParse(widget.fromCheque);
final toCheque = int.tryParse(widget.toCheque);
if (chequeNumber == null ||
fromCheque == null ||
toCheque == null) {
return AppLocalizations.of(context)
.invalidChequeNumberFormatError;
}
// if (chequeNumber < fromCheque || chequeNumber > toCheque) {
// return AppLocalizations.of(context).chequeNumberRangeError(
// widget.fromCheque, widget.toCheque);
// }
return null;
},
),
const SizedBox(height: 16),
TextFormField(
initialValue: widget.instrType,
readOnly: true,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).instrumentTypeLabel,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 16),
TextFormField(
controller: _stopIssueDateController,
readOnly: true,
onTap: () => _selectDate(_stopIssueDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopIssueDateHint,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopIssueDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopExpiryDateController,
readOnly: true,
onTap: () => _selectDate(_stopExpiryDateController),
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopExpiryDateHint,
border: const OutlineInputBorder(),
suffixIcon: IconButton(
icon: const Icon(Icons.calendar_today),
onPressed: () => _selectDate(_stopExpiryDateController),
),
),
keyboardType: TextInputType.datetime,
),
const SizedBox(height: 16),
TextFormField(
controller: _stopAmountController,
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopAmountHint,
border: const OutlineInputBorder(),
),
keyboardType: TextInputType.number,
),
const SizedBox(height: 16),
DropdownButtonFormField<String>(
value: _selectedComment,
items: _commentOptions.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (newValue) {
setState(() {
_selectedComment = newValue;
_showOtherCommentField = newValue == 'Other';
});
},
decoration: InputDecoration(
labelText: AppLocalizations.of(context).stopCommentHint,
border: const OutlineInputBorder(),
),
),
if (_showOtherCommentField)
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: TextFormField(
controller: _otherCommentController,
decoration: const InputDecoration(
labelText: "Other Reasons :",
border: OutlineInputBorder(),
),
validator: (value) {
return null;
},
),
),
const SizedBox(height: 32),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => TransactionPinScreen(
onPinCompleted: (ctx, pin) async {
Navigator.pop(context);
try {
final response = await _chequeService.revokeStop(
accountno: widget.selectedAccount.accountNo!,
removeFromChequeNo:
_stopFromChequeNoController.text,
instrType: widget.instrType,
removeToChequeNo:
_stopToChequeNoController.text,
removeIssueDate: _stopIssueDateController.text,
removeExpiryDate: _stopExpiryDateController.text,
removeAmount: _stopAmountController.text,
removeComment: _selectedComment == 'Other'
? _otherCommentController.text
: _selectedComment ?? '',
tpin: pin,
);
if (!mounted) return;
final decodedResponse = jsonDecode(response);
String responseString = response.toString(); // used as the case only for incorrect TPIN
final status = decodedResponse['status'];
final message = decodedResponse['message'];
final code = decodedResponse['code'];
if (status == 'SUCCESS') {
_showResponseDialog('Success', message);
} if (status == 'ERROR') {
String errMessage = "error";
if(code == '0429') {
errMessage = 'The selected Cheque is already stopped';
} else if(code == '0748') {
errMessage = 'The selected Cheque is already presented';
}
_showResponseDialog('Error', errMessage);
}
if(responseString.contains('INCORRECT_TPIN')){
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
}
} on Exception catch (e) {
try {
final errorBodyString =
e.toString().split('Exception: ')[1];
final errorBody = jsonDecode(errorBodyString);
if (errorBody.containsKey('error') &&
errorBody['error'] == 'INCORRECT_TPIN') {
_showResponseDialog('Invalid TPIN',
'The TPIN you entered is incorrect. Please try again.');
} else {
_showResponseDialog(
'Error', 'Internal Server Error');
}
} catch (_) {
_showResponseDialog(
'Error', 'Internal Server Error');
}
}
},
),
),
);
}
},
child: Text(AppLocalizations.of(context).stopChequeButton),
),
],
),
),
),
);
}
}

View File

@@ -2,15 +2,15 @@ import 'package:kmobile/data/models/user.dart';
import 'package:kmobile/di/injection.dart'; import 'package:kmobile/di/injection.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:kmobile/api/services/cheque_service.dart'; import 'package:kmobile/api/services/cheque_service.dart';
import 'package:kmobile/features/cheque/screens/stop_multiple_cheques_screen.dart'; import 'package:kmobile/features/cheque/screens/revoke%20_stop_multiple_screen.dart';
import 'package:kmobile/features/cheque/screens/stop_single_cheque_screen.dart'; import 'package:kmobile/features/cheque/screens/revoke_stop_single_screen.dart';
import 'package:kmobile/l10n/app_localizations.dart'; import 'package:kmobile/l10n/app_localizations.dart';
class RevokeStopSingleChequeScreen extends StatefulWidget { class RevokeStopChequeScreen extends StatefulWidget {
final List<User> users; final List<User> users;
final int selectedIndex; final int selectedIndex;
const RevokeStopSingleChequeScreen( const RevokeStopChequeScreen(
{ {
super.key, super.key,
required this.users, required this.users,
@@ -18,14 +18,14 @@ class RevokeStopSingleChequeScreen extends StatefulWidget {
}); });
@override @override
State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState(); State<RevokeStopChequeScreen> createState() => _RevokeStopChequeScreenState();
} }
class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> { class _RevokeStopChequeScreenState extends State<RevokeStopChequeScreen> {
User? _selectedAccount; User? _selectedAccount;
var service = getIt<ChequeService>(); var service = getIt<ChequeService>();
bool _isLoading = true; bool _isLoading = true;
Cheque? _stCheque; List<Cheque> _stCheques = [];
List<User> _filteredUsers = []; List<User> _filteredUsers = [];
@override @override
@@ -58,7 +58,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
if (_selectedAccount == null) { if (_selectedAccount == null) {
setState(() { setState(() {
_isLoading = false; _isLoading = false;
_stCheque = null; _stCheques = [];
}); });
return; return;
} }
@@ -87,13 +87,13 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
accountNumber: _selectedAccount!.accountNo!, instrType: instrType); accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
final stCheques = data.where((cheque) => cheque.type == 'ST').toList(); final stCheques = data.where((cheque) => cheque.type == 'ST').toList();
setState(() { setState(() {
_stCheque = stCheques.isNotEmpty ? stCheques.first : null; _stCheques = stCheques;
_isLoading = false; _isLoading = false;
}); });
} catch (e) { } catch (e) {
setState(() { setState(() {
_isLoading = false; _isLoading = false;
_stCheque = null; _stCheques = [];
}); });
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
@@ -122,15 +122,14 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context).stopChequeTitle), title: const Text("Revoke Stop Cheque"),
centerTitle: false, centerTitle: false,
), ),
body: Stack( body: Stack(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Column( child: Column(children: [
children: [
Card( Card(
elevation: 4, elevation: 4,
margin: const EdgeInsets.symmetric(vertical: 8.0), margin: const EdgeInsets.symmetric(vertical: 8.0),
@@ -180,24 +179,25 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
elevation: 4, elevation: 4,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (_selectedAccount != null && _stCheque != null) { if (_selectedAccount != null &&
_stCheques.isNotEmpty) {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => StopSingleChequeScreen( builder: (context) =>
RevokeStopSingleChequeScreen(
selectedAccount: _selectedAccount!, selectedAccount: _selectedAccount!,
date: _stCheque!.Date!, date: _stCheques.first.Date!,
instrType: _stCheque!.InstrType!, instrType: _stCheques.first.InstrType!,
fromCheque: _stCheque!.fromCheque!, fromCheque: _stCheques.first.fromCheque!,
toCheque: _stCheque!.toCheque!, toCheque: _stCheques.first.toCheque!,
), ),
), ),
); );
} else { } else {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( const SnackBar(
content: Text(AppLocalizations.of(context) content: Text("No stopped cheques present"),
.noChequebookToStop),
), ),
); );
} }
@@ -206,8 +206,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Center( child: Center(
child: Text( child: Text(
AppLocalizations.of(context) "Revoke Single Stop",
.stopSingleChequeTitle,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
@@ -229,17 +228,18 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
elevation: 4, elevation: 4,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (_selectedAccount != null) { if (_selectedAccount != null &&
_stCheques.isNotEmpty) {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) =>
StopMultipleChequesScreen( RevokeStopMultipleChequesScreen(
selectedAccount: _selectedAccount!, selectedAccount: _selectedAccount!,
date: _stCheque!.Date!, date: _stCheques.first.Date!,
instrType: _stCheque!.InstrType!, instrType: _stCheques.first.InstrType!,
fromCheque: _stCheque!.fromCheque!, fromCheque: _stCheques.first.fromCheque!,
toCheque: _stCheque!.toCheque!, toCheque: _stCheques.first.toCheque!,
), ),
), ),
); );
@@ -256,8 +256,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Center( child: Center(
child: Text( child: Text(
AppLocalizations.of(context) "Revoke Multiple Stops",
.stopMultipleChequesButton,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
@@ -278,14 +277,18 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
Expanded( Expanded(
child: _isLoading child: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: _stCheque == null : _stCheques.isEmpty
? Center( ? Center(
child: Text(AppLocalizations.of(context) child: Text(AppLocalizations.of(context)
.noChequeIssuedStatus)) .noChequeIssuedStatus))
: _buildCiTile(context, _stCheque!), : ListView.builder(
itemCount: _stCheques.length,
itemBuilder: (context, index) {
return _buildSTTile(context, _stCheques[index]);
},
), ),
],
), ),
]),
), ),
IgnorePointer( IgnorePointer(
child: Center( child: Center(
@@ -306,7 +309,7 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
); );
} }
Widget _buildCiTile(BuildContext context, Cheque cheque) { Widget _buildSTTile(BuildContext context, Cheque cheque) {
return Card( return Card(
margin: const EdgeInsets.symmetric( margin: const EdgeInsets.symmetric(
vertical: 8.0, vertical: 8.0,
@@ -316,20 +319,17 @@ class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScr
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text(AppLocalizations.of(context).chequebookDetailsTitle, Text(AppLocalizations.of(context).stopChequeLabel,
style: Theme.of(context).textTheme.titleLarge), style: Theme.of(context).textTheme.titleLarge),
const SizedBox(height: 8), const SizedBox(height: 8),
_buildInfoRow('Account Number:', _selectedAccount!.accountNo!), _buildInfoRow('From Cheque:', cheque.fromCheque),
_buildInfoRow('Customer Name:', _selectedAccount!.name!), _buildInfoRow('To Cheque:', cheque.toCheque),
_buildInfoRow('CIF Number:', _selectedAccount!.cifNumber!),
_buildInfoRow('Account Type:', _buildInfoRow('Account Type:',
_getAccountTypeDisplayName(_selectedAccount!.accountType!)), _getAccountTypeDisplayName(_selectedAccount!.accountType!)),
_buildInfoRow('Branch Code:', cheque.branchCode), _buildInfoRow('Branch Code:', cheque.branchCode),
_buildInfoRow('Starting Cheque Number:', cheque.fromCheque), _buildInfoRow('Stop Issue Date:', cheque.stopIssueDate),
_buildInfoRow('Ending Cheque Number:', cheque.toCheque), _buildInfoRow('Stop Expiry Date:', cheque.StopExpiryDate),
_buildInfoRow('Issue Date:', cheque.Date), _buildInfoRow('Cheques Count:', cheque.Chequescount),
_buildInfoRow('Number of Cheques:', cheque.Chequescount),
_buildInfoRow('Instrument Type:', cheque.InstrType),
], ],
), ),
), ),

View File

@@ -1,331 +1,304 @@
// import 'dart:convert'; import 'dart:convert';
// import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
// import 'package:kmobile/data/models/user.dart'; import 'package:kmobile/data/models/user.dart';
// import 'package:kmobile/di/injection.dart'; import 'package:kmobile/di/injection.dart';
// import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:kmobile/api/services/cheque_service.dart'; import 'package:kmobile/api/services/cheque_service.dart';
// import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart'; import 'package:kmobile/features/fund_transfer/screens/transaction_pin_screen.dart';
// import 'package:kmobile/l10n/app_localizations.dart'; import 'package:kmobile/l10n/app_localizations.dart';
// class RevokeStopSingleChequeScreen extends StatefulWidget { class RevokeStopSingleChequeScreen extends StatefulWidget {
// final User selectedAccount; final User selectedAccount;
// final String date; final String date;
// final String instrType; final String instrType;
// final String fromCheque; final String fromCheque;
// final String toCheque; final String toCheque;
// const RevokeStopSingleChequeScreen( const RevokeStopSingleChequeScreen(
// {super.key, {super.key,
// required this.selectedAccount, required this.selectedAccount,
// required this.date, required this.date,
// required this.instrType, required this.instrType,
// required this.fromCheque, required this.fromCheque,
// required this.toCheque}); required this.toCheque});
// @override @override
// State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState(); State<RevokeStopSingleChequeScreen> createState() => _RevokeStopSingleChequeScreenState();
// } }
// class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> { class _RevokeStopSingleChequeScreenState extends State<RevokeStopSingleChequeScreen> {
// final _formKey = GlobalKey<FormState>(); final _formKey = GlobalKey<FormState>();
// final _stopFromChequeNoController = TextEditingController(); final _stopFromChequeNoController = TextEditingController();
// final _stopIssueDateController = TextEditingController(); final _stopIssueDateController = TextEditingController();
// final _stopExpiryDateController = TextEditingController(); final _stopExpiryDateController = TextEditingController();
// final _stopAmountController = TextEditingController(); final _stopAmountController = TextEditingController();
// final _chequeService = getIt<ChequeService>(); final _chequeService = getIt<ChequeService>();
// String? _selectedComment; String? _selectedComment;
// final _otherCommentController = TextEditingController(); final _otherCommentController = TextEditingController();
// bool _showOtherCommentField = false; bool _showOtherCommentField = false;
// final List<String> _commentOptions = [ final List<String> _commentOptions = [
// 'Cheque Lost', 'Cheque Found',
// 'Cheque Stolen', 'Cheque Fixed',
// 'Cheque Missing', 'Other'
// 'Cheque Damaged', ];
// 'Other'
// ];
// String _formatDate(String dateString) { Future<void> _selectDate(TextEditingController controller) async {
// if (dateString.length != 8) { final DateTime? picked = await showDatePicker(
// return dateString; // Return as is if not in expected ddmmyyyy format context: context,
// } initialDate: DateTime.now(),
// try { firstDate: DateTime.now(),
// final day = dateString.substring(0, 2); lastDate: DateTime(2101),
// final month = dateString.substring(2, 4); );
// final year = dateString.substring(4, 8); if (picked != null) {
// return '$day/$month/$year'; setState(() {
// } catch (e) { controller.text =
// return dateString; // Return original string on error '${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}';
// } });
// } }
}
// Future<void> _selectDate(TextEditingController controller) async { Future<void> _showResponseDialog(String title, String message) async {
// final DateTime? picked = await showDatePicker( return showDialog<void>(
// context: context, context: context,
// initialDate: DateTime.now(), barrierDismissible: false, // user must tap button!
// firstDate: DateTime.now(), builder: (BuildContext context) {
// lastDate: DateTime(2101), return AlertDialog(
// ); title: Text(title),
// if (picked != null) { content: SingleChildScrollView(
// setState(() { child: ListBody(
// controller.text = children: <Widget>[
// '${picked.day.toString().padLeft(2, '0')}/${picked.month.toString().padLeft(2, '0')}/${picked.year}'; Text(message),
// }); ],
// } ),
// } ),
actions: <Widget>[
TextButton(
child: Text(AppLocalizations.of(context).closeButton),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
// Future<void> _showResponseDialog(String title, String message) async { @override
// return showDialog<void>( Widget build(BuildContext context) {
// context: context, return Scaffold(
// barrierDismissible: false, // user must tap button! appBar: AppBar(
// builder: (BuildContext context) { title: const Text("Revoke Single Stop")),
// return AlertDialog( body: Padding(
// title: Text(title), padding: const EdgeInsets.all(16.0),
// content: SingleChildScrollView( child: Form(
// child: ListBody( key: _formKey,
// children: <Widget>[ child: ListView(
// Text(message), children: [
// ], Card(
// ), elevation: 0,
// ), margin: const EdgeInsets.symmetric(vertical: 8.0),
// actions: <Widget>[ child: ListTile(
// TextButton( leading: Image.asset(
// child: Text(AppLocalizations.of(context).closeButton), 'assets/images/logo.png',
// onPressed: () { width: 40,
// Navigator.of(context).pop(); height: 40,
// }, ),
// ), title: Text(widget.selectedAccount.accountNo!),
// ], subtitle:
// ); Text(AppLocalizations.of(context).accountNumberLabel),
// }, ),
// ); ),
// } const SizedBox(height: 24),
TextFormField(
// @override controller: _stopFromChequeNoController,
// Widget build(BuildContext context) { decoration: InputDecoration(
// return Scaffold( labelText: AppLocalizations.of(context).chequeNumberLabel,
// appBar: AppBar( border: const OutlineInputBorder(),
// title: const Text("Revoke Stop")), errorMaxLines: 2,
// ); ),
// body: Padding( keyboardType: TextInputType.number,
// padding: const EdgeInsets.all(16.0), validator: (value) {
// child: Form( if (value == null || value.isEmpty) {
// key: _formKey, return AppLocalizations.of(context)
// child: ListView( .pleaseEnterChequeNumberError;
// children: [ }
// Card( final chequeNumber = int.tryParse(value);
// elevation: 0, final fromCheque = int.tryParse(widget.fromCheque);
// margin: const EdgeInsets.symmetric(vertical: 8.0), final toCheque = int.tryParse(widget.toCheque);
// child: ListTile( if (chequeNumber == null ||
// leading: Image.asset( fromCheque == null ||
// 'assets/images/logo.png', toCheque == null) {
// width: 40, return AppLocalizations.of(context)
// height: 40, .invalidChequeNumberFormatError;
// ), }
// title: Text(widget.selectedAccount.accountNo!), // if (chequeNumber < fromCheque || chequeNumber > toCheque) {
// subtitle: // return AppLocalizations.of(context).chequeNumberRangeError(
// Text(AppLocalizations.of(context).accountNumberLabel), // widget.fromCheque, widget.toCheque);
// ), // }
// ), return null;
// const SizedBox(height: 24), },
// TextFormField( ),
// controller: _stopFromChequeNoController, const SizedBox(height: 16),
// decoration: InputDecoration( TextFormField(
// labelText: AppLocalizations.of(context).chequeNumberLabel, initialValue: widget.instrType,
// border: OutlineInputBorder(), readOnly: true,
// errorMaxLines: 2, decoration: InputDecoration(
// ), labelText: AppLocalizations.of(context).instrumentTypeLabel,
// keyboardType: TextInputType.number, border: const OutlineInputBorder(),
// validator: (value) { ),
// if (value == null || value.isEmpty) { ),
// return AppLocalizations.of(context) const SizedBox(height: 16),
// .pleaseEnterChequeNumberError; TextFormField(
// } controller: _stopIssueDateController,
// final chequeNumber = int.tryParse(value); readOnly: true,
// final fromCheque = int.tryParse(widget.fromCheque); onTap: () => _selectDate(_stopIssueDateController),
// final toCheque = int.tryParse(widget.toCheque); decoration: InputDecoration(
// if (chequeNumber == null || labelText: AppLocalizations.of(context).stopIssueDateLabel,
// fromCheque == null || border: const OutlineInputBorder(),
// toCheque == null) { suffixIcon: IconButton(
// return AppLocalizations.of(context) icon: const Icon(Icons.calendar_today),
// .invalidChequeNumberFormatError; onPressed: () => _selectDate(_stopIssueDateController),
// } ),
// if (chequeNumber < fromCheque || chequeNumber > toCheque) { ),
// return AppLocalizations.of(context).chequeNumberRangeError( keyboardType: TextInputType.datetime,
// widget.fromCheque, widget.toCheque); ),
// } const SizedBox(height: 16),
// return null; TextFormField(
// }, controller: _stopExpiryDateController,
// ), readOnly: true,
// const SizedBox(height: 16), onTap: () => _selectDate(_stopExpiryDateController),
// TextFormField( decoration: InputDecoration(
// initialValue: widget.instrType, labelText: AppLocalizations.of(context).stopExpiryDateLabel,
// readOnly: true, border: const OutlineInputBorder(),
// decoration: InputDecoration( suffixIcon: IconButton(
// labelText: AppLocalizations.of(context).instrumentTypeLabel, icon: const Icon(Icons.calendar_today),
// border: const OutlineInputBorder(), onPressed: () => _selectDate(_stopExpiryDateController),
// ), ),
// ), ),
// const SizedBox(height: 16), keyboardType: TextInputType.datetime,
// TextFormField( ),
// controller: _stopIssueDateController, const SizedBox(height: 16),
// readOnly: true, TextFormField(
// onTap: () => _selectDate(_stopIssueDateController), controller: _stopAmountController,
// decoration: InputDecoration( decoration: InputDecoration(
// labelText: AppLocalizations.of(context).stopIssueDateLabel, labelText: AppLocalizations.of(context).stopAmountHint,
// border: const OutlineInputBorder(), border: const OutlineInputBorder(),
// suffixIcon: IconButton( ),
// icon: const Icon(Icons.calendar_today), keyboardType: TextInputType.number,
// onPressed: () => _selectDate(_stopIssueDateController), ),
// ), const SizedBox(height: 16),
// ), DropdownButtonFormField<String>(
// keyboardType: TextInputType.datetime, value: _selectedComment,
// ), items: _commentOptions.map((String value) {
// const SizedBox(height: 16), return DropdownMenuItem<String>(
// TextFormField( value: value,
// controller: _stopExpiryDateController, child: Text(value),
// readOnly: true, );
// onTap: () => _selectDate(_stopExpiryDateController), }).toList(),
// decoration: InputDecoration( onChanged: (newValue) {
// labelText: AppLocalizations.of(context).stopExpiryDateLabel, setState(() {
// border: const OutlineInputBorder(), _selectedComment = newValue;
// suffixIcon: IconButton( _showOtherCommentField = newValue == 'Other';
// icon: const Icon(Icons.calendar_today), });
// onPressed: () => _selectDate(_stopExpiryDateController), },
// ), decoration: InputDecoration(
// ), labelText: AppLocalizations.of(context).stopCommentHint,
// keyboardType: TextInputType.datetime, border: const OutlineInputBorder(),
// ), ),
// const SizedBox(height: 16), ),
// TextFormField( if (_showOtherCommentField)
// controller: _stopAmountController, Padding(
// decoration: InputDecoration( padding: const EdgeInsets.only(top: 16.0),
// labelText: AppLocalizations.of(context).stopAmountHint, child: TextFormField(
// border: const OutlineInputBorder(), controller: _otherCommentController,
// ), decoration: const InputDecoration(
// keyboardType: TextInputType.number, labelText: "Other Reasons :",
// ), border: OutlineInputBorder(),
// const SizedBox(height: 16), ),
// DropdownButtonFormField<String>( validator: (value) {
// value: _selectedComment, return null;
// items: _commentOptions.map((String value) { },
// return DropdownMenuItem<String>( ),
// value: value, ),
// child: Text(value), const SizedBox(height: 32),
// ); ElevatedButton(
// }).toList(), onPressed: () {
// onChanged: (newValue) { if (_formKey.currentState!.validate()) {
// setState(() { Navigator.push(
// _selectedComment = newValue; context,
// _showOtherCommentField = newValue == 'Other'; MaterialPageRoute(
// }); builder: (context) => TransactionPinScreen(
// }, onPinCompleted: (ctx, pin) async {
// decoration: InputDecoration( Navigator.pop(context);
// labelText: AppLocalizations.of(context).stopCommentHint, try {
// border: const OutlineInputBorder(), final response = await _chequeService.revokeStop(
// ), accountno: widget.selectedAccount.accountNo!,
// ), removeFromChequeNo:
// if (_showOtherCommentField) _stopFromChequeNoController.text,
// Padding( instrType: widget.instrType,
// padding: const EdgeInsets.only(top: 16.0), removeToChequeNo:
// child: TextFormField( _stopFromChequeNoController.text,
// controller: _otherCommentController, removeIssueDate: _stopIssueDateController.text,
// decoration: const InputDecoration( removeExpiryDate: _stopExpiryDateController.text,
// labelText: "Other Reasons :", removeAmount: _stopAmountController.text,
// border: OutlineInputBorder(), removeComment: _selectedComment == 'Other'
// ), ? _otherCommentController.text
// validator: (value) { : _selectedComment ?? '',
// return null; tpin: pin,
// }, );
// ), if (!mounted) return;
// ), final decodedResponse = jsonDecode(response);
// const SizedBox(height: 16), String responseString = response.toString(); // used as the case only for incorrect TPIN
// TextFormField( final status = decodedResponse['status'];
// initialValue: _formatDate(widget.date), final message = decodedResponse['message'];
// readOnly: true, final code = decodedResponse['code'];
// decoration: InputDecoration( if (status == 'SUCCESS') {
// labelText: _showResponseDialog('Success', message);
// AppLocalizations.of(context).chequebookIssueDateHint, } if (status == 'ERROR') {
// border: const OutlineInputBorder(), String errMessage = "error";
// ), if(code == '0429') {
// ), errMessage = 'The selected Cheque is already stopped';
// const SizedBox(height: 32), } else if(code == '0748') {
// ElevatedButton( errMessage = 'The selected Cheque is already presented';
// onPressed: () { }
// if (_formKey.currentState!.validate()) { _showResponseDialog('Error', errMessage);
// Navigator.push( }
// context, if(responseString.contains('INCORRECT_TPIN')){
// MaterialPageRoute( _showResponseDialog('Invalid TPIN',
// builder: (context) => TransactionPinScreen( 'The TPIN you entered is incorrect. Please try again.');
// onPinCompleted: (ctx, pin) async { }
// Navigator.pop(context); } on DioException catch (e) {
// try { try {
// final response = await _chequeService.revokeStop( final errorBodyString =
// accountno: widget.selectedAccount.accountNo!, e.toString().split('Exception: ')[1];
// stopFromChequeNo: final errorBody = jsonDecode(errorBodyString);
// _stopFromChequeNoController.text, if (errorBody.containsKey('error') &&
// instrType: widget.instrType, errorBody['error'] == 'INCORRECT_TPIN') {
// stopToChequeNo: _showResponseDialog('Invalid TPIN',
// _stopFromChequeNoController.text, 'The TPIN you entered is incorrect. Please try again.');
// stopIssueDate: _stopIssueDateController.text, } else {
// stopExpiryDate: _stopExpiryDateController.text, _showResponseDialog(
// stopAmount: _stopAmountController.text, 'Error', 'Internal Server Error');
// stopComment: _selectedComment == 'Other' }
// ? _otherCommentController.text } catch (_) {
// : _selectedComment ?? '', _showResponseDialog(
// chequeIssueDate: widget.date, 'Error', 'Internal Server Error');
// tpin: pin, }
// ); }
// if (!mounted) return; },
// final decodedResponse = jsonDecode(response); ),
// String responseString = response.toString(); // used as the case only for incorrect TPIN ),
// final status = decodedResponse['status']; );
// final message = decodedResponse['message']; }
// final code = decodedResponse['code']; },
// if (status == 'SUCCESS') { child: Text("Revoke Stop"),
// _showResponseDialog('Success', message); ),
// } if (status == 'ERROR') { ],
// String errMessage = "error"; ),
// if(code == '0429') { ),
// errMessage = 'The selected Cheque is already stopped'; ),
// } else if(code == '0748') { );
// errMessage = 'The selected Cheque is already presented'; }
// } }
// _showResponseDialog('Error', errMessage);
// }
// if(responseString.contains('INCORRECT_TPIN')){
// _showResponseDialog('Invalid TPIN',
// 'The TPIN you entered is incorrect. Please try again.');
// }
// } on DioException catch (e) {
// try {
// final errorBodyString =
// e.toString().split('Exception: ')[1];
// final errorBody = jsonDecode(errorBodyString);
// if (errorBody.containsKey('error') &&
// errorBody['error'] == 'INCORRECT_TPIN') {
// _showResponseDialog('Invalid TPIN',
// 'The TPIN you entered is incorrect. Please try again.');
// } else {
// _showResponseDialog(
// 'Error', 'Internal Server Error');
// }
// } catch (_) {
// _showResponseDialog(
// 'Error', 'Internal Server Error');
// }
// }
// },
// ),
// ),
// );
// }
// },
// child: Text("Revoke Stop"),
// ),
// ],
// ),
// ),
// );
// }
// }