Stop Cheque Screens Created #Single
This commit is contained in:
@@ -200,7 +200,7 @@ class _ChequeEnquiryScreenState extends State<ChequeEnquiryScreen> {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Search...',
|
labelText: 'Search by Cheque Details',
|
||||||
prefixIcon: Icon(Icons.search),
|
prefixIcon: Icon(Icons.search),
|
||||||
border: InputBorder
|
border: InputBorder
|
||||||
.none, // Remove border to make it look like it's inside the card
|
.none, // Remove border to make it look like it's inside the card
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class _ChequeManagementScreen extends State<ChequeManagementScreen> {
|
|||||||
icon: Symbols.block_sharp,
|
icon: Symbols.block_sharp,
|
||||||
label: AppLocalizations.of(context).stopCheque,
|
label: AppLocalizations.of(context).stopCheque,
|
||||||
subtitle:
|
subtitle:
|
||||||
"Initiate a stop payment request for a cheque that has already been presented for payment. This action helps prevent unauthorized transactions or rectifies errors on cheques that are in the process of being cleared",
|
"Initiate stop for one or more cheques from your issued checkbook. This essential service helps prevent unauthorized transactions and protects against fraud.",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/features/cheque/screens/stop_multiple_cheques_screen.dart';
|
||||||
|
import 'package:kmobile/features/cheque/screens/stop_single_cheque_screen.dart';
|
||||||
import 'package:kmobile/api/services/cheque_service.dart';
|
import 'package:kmobile/api/services/cheque_service.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:kmobile/l10n/app_localizations.dart';
|
||||||
|
|
||||||
class StopChequeScreen extends StatefulWidget {
|
class StopChequeScreen extends StatefulWidget {
|
||||||
final List<User> users;
|
final List<User> users;
|
||||||
@@ -18,11 +21,9 @@ class StopChequeScreen extends StatefulWidget {
|
|||||||
|
|
||||||
class _StopChequeScreenState extends State<StopChequeScreen> {
|
class _StopChequeScreenState extends State<StopChequeScreen> {
|
||||||
User? _selectedAccount;
|
User? _selectedAccount;
|
||||||
final TextEditingController _searchController = TextEditingController();
|
|
||||||
var service = getIt<ChequeService>();
|
var service = getIt<ChequeService>();
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
List<Cheque> _allCheques = [];
|
Cheque? _ciCheque;
|
||||||
Map<String, List<Cheque>> _groupedCheques = {};
|
|
||||||
List<User> _filteredUsers = [];
|
List<User> _filteredUsers = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -49,16 +50,13 @@ class _StopChequeScreenState extends State<StopChequeScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_loadCheques();
|
_loadCheques();
|
||||||
_searchController.addListener(() {
|
|
||||||
_filterCheques(_searchController.text);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadCheques() async {
|
Future<void> _loadCheques() async {
|
||||||
if (_selectedAccount == null) {
|
if (_selectedAccount == null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
_groupedCheques = {};
|
_ciCheque = null;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -85,23 +83,15 @@ class _StopChequeScreenState extends State<StopChequeScreen> {
|
|||||||
try {
|
try {
|
||||||
final data = await service.ChequeEnquiry(
|
final data = await service.ChequeEnquiry(
|
||||||
accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
|
accountNumber: _selectedAccount!.accountNo!, instrType: instrType);
|
||||||
_allCheques = data.where((cheque) => cheque.type == 'PR').toList();
|
final ciCheques = data.where((cheque) => cheque.type == 'CI').toList();
|
||||||
_groupedCheques.clear();
|
|
||||||
for (var cheque in _allCheques) {
|
|
||||||
if (cheque.type != null) {
|
|
||||||
if (!_groupedCheques.containsKey(cheque.type)) {
|
|
||||||
_groupedCheques[cheque.type!] = [];
|
|
||||||
}
|
|
||||||
_groupedCheques[cheque.type!]!.add(cheque);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_ciCheque = ciCheques.isNotEmpty ? ciCheques.first : null;
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
_groupedCheques = {};
|
_ciCheque = null;
|
||||||
});
|
});
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@@ -111,31 +101,19 @@ class _StopChequeScreenState extends State<StopChequeScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _filterCheques(String query) {
|
String _getAccountTypeDisplayName(String accountType) {
|
||||||
_groupedCheques.clear();
|
switch (accountType.toLowerCase()) {
|
||||||
List<Cheque> filteredCheques;
|
case 'sa':
|
||||||
if (query.isEmpty) {
|
return AppLocalizations.of(context).savingsAccount;
|
||||||
filteredCheques = _allCheques;
|
case 'sb':
|
||||||
} else {
|
return AppLocalizations.of(context).savingsAccount;
|
||||||
filteredCheques = _allCheques.where((cheque) {
|
case 'ca':
|
||||||
final lowerQuery = query.toLowerCase();
|
return "Current Account";
|
||||||
return (cheque.ChequeNumber?.toLowerCase().contains(lowerQuery) ?? false) ||
|
case 'cc':
|
||||||
(cheque.status?.toLowerCase().contains(lowerQuery) ?? false) ||
|
return "Cash Credit Account";
|
||||||
(cheque.fromCheque?.toLowerCase().contains(lowerQuery) ?? false) ||
|
default:
|
||||||
(cheque.toCheque?.toLowerCase().contains(lowerQuery) ?? false);
|
return accountType;
|
||||||
}).toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var cheque in filteredCheques) {
|
|
||||||
if (cheque.type != null) {
|
|
||||||
if (!_groupedCheques.containsKey(cheque.type)) {
|
|
||||||
_groupedCheques[cheque.type!] = [];
|
|
||||||
}
|
|
||||||
_groupedCheques[cheque.type!]!.add(cheque);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -192,39 +170,112 @@ class _StopChequeScreenState extends State<StopChequeScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Card(
|
Row(
|
||||||
elevation: 4,
|
children: [
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
Expanded(
|
||||||
child: Padding(
|
child: Card(
|
||||||
padding: const EdgeInsets.all(8.0),
|
color: Theme.of(context).colorScheme.primaryContainer,
|
||||||
child: TextField(
|
elevation: 4,
|
||||||
controller: _searchController,
|
child: InkWell(
|
||||||
decoration: const InputDecoration(
|
onTap: () {
|
||||||
labelText: 'Search',
|
if (_selectedAccount != null && _ciCheque != null) {
|
||||||
prefixIcon: Icon(Icons.search),
|
Navigator.push(
|
||||||
border: InputBorder
|
context,
|
||||||
.none, // Remove border to make it look like it's inside the card
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
StopSingleChequeScreen(
|
||||||
|
selectedAccount: _selectedAccount!,
|
||||||
|
date: _ciCheque!.Date!,
|
||||||
|
instrType: _ciCheque!.InstrType!,
|
||||||
|
fromCheque: _ciCheque!.fromCheque!,
|
||||||
|
toCheque: _ciCheque!.toCheque!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'No cheque book found to stop cheques from.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Stop Single Cheque',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onPrimaryContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Card(
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.primaryContainer,
|
||||||
|
elevation: 4,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (_selectedAccount != null) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
StopMultipleChequesScreen(
|
||||||
|
selectedAccount: _selectedAccount!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Please select an account first.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Stop Multiple Cheques',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onSecondaryContainer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _isLoading
|
child: _isLoading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: _groupedCheques.isEmpty
|
: _ciCheque == null
|
||||||
? const Center(child: Text('No cheque status found.'))
|
? const Center(
|
||||||
: ListView(
|
child: Text('No Cheque Issued status found.'))
|
||||||
children: _groupedCheques.entries.map((entry) {
|
: _buildCiTile(context, _ciCheque!),
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
...entry.value.map((cheque) =>
|
|
||||||
ChequeStatusTile(cheque: cheque)),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -247,53 +298,31 @@ class _StopChequeScreenState extends State<StopChequeScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class ChequeStatusTile extends StatelessWidget {
|
Widget _buildCiTile(BuildContext context, Cheque cheque) {
|
||||||
final Cheque cheque;
|
|
||||||
|
|
||||||
const ChequeStatusTile({
|
|
||||||
super.key,
|
|
||||||
required this.cheque,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
switch (cheque.type) {
|
|
||||||
case 'PR':
|
|
||||||
return _buildPrTile(context);
|
|
||||||
default:
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildPrTile(BuildContext context) {
|
|
||||||
return Card(
|
return Card(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 8.0),
|
margin: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8.0,
|
||||||
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('Presented Cheque(PR)',
|
Text('Chequebook Details',
|
||||||
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('Customer Name:', _selectedAccount!.name!),
|
||||||
|
_buildInfoRow('CIF Number:', _selectedAccount!.cifNumber!),
|
||||||
|
_buildInfoRow('Account Type:',
|
||||||
|
_getAccountTypeDisplayName(_selectedAccount!.accountType!)),
|
||||||
_buildInfoRow('Branch Code:', cheque.branchCode),
|
_buildInfoRow('Branch Code:', cheque.branchCode),
|
||||||
_buildInfoRow('Cheque Number:', cheque.ChequeNumber),
|
_buildInfoRow('Starting Cheque Number:', cheque.fromCheque),
|
||||||
_buildInfoRow('Date:', cheque.Date),
|
_buildInfoRow('Ending Cheque Number:', cheque.toCheque),
|
||||||
_buildInfoRow('Transaction Code:', cheque.transactionCode),
|
_buildInfoRow('Issue Date:', cheque.Date),
|
||||||
_buildInfoRow('Amount:', '₹ ${cheque.amount.toString()}'),
|
_buildInfoRow('Number of Cheques:', cheque.Chequescount),
|
||||||
_buildInfoRow('Status:', cheque.status),
|
_buildInfoRow('Instrument Type:', cheque.InstrType),
|
||||||
const SizedBox(height: 16),
|
|
||||||
Center(
|
|
||||||
child: ElevatedButton.icon(
|
|
||||||
onPressed: () {
|
|
||||||
// TODO: Implement stop cheque functionality
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.block_sharp),
|
|
||||||
label: const Text('Stop Cheque'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/data/models/user.dart';
|
||||||
|
|
||||||
|
class StopMultipleChequesScreen extends StatefulWidget {
|
||||||
|
final User selectedAccount;
|
||||||
|
|
||||||
|
const StopMultipleChequesScreen({super.key, required this.selectedAccount});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StopMultipleChequesScreen> createState() =>
|
||||||
|
_StopMultipleChequesScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StopMultipleChequesScreenState extends State<StopMultipleChequesScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _fromChequeController = TextEditingController();
|
||||||
|
final _toChequeController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Stop Multiple Cheques'),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _fromChequeController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'From Cheque Number',
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return 'Please enter the starting cheque number';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
TextFormField(
|
||||||
|
controller: _toChequeController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'To Cheque Number',
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return 'Please enter the ending cheque number';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
// TODO: Implement stop multiple cheques logic
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text('Submit'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
179
lib/features/cheque/screens/stop_single_cheque_screen.dart
Normal file
179
lib/features/cheque/screens/stop_single_cheque_screen.dart
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/data/models/user.dart';
|
||||||
|
|
||||||
|
class StopSingleChequeScreen extends StatefulWidget {
|
||||||
|
final User selectedAccount;
|
||||||
|
final String date;
|
||||||
|
final String instrType;
|
||||||
|
final String fromCheque;
|
||||||
|
final String toCheque;
|
||||||
|
|
||||||
|
const StopSingleChequeScreen(
|
||||||
|
{super.key,
|
||||||
|
required this.selectedAccount,
|
||||||
|
required this.date,
|
||||||
|
required this.instrType,
|
||||||
|
required this.fromCheque,
|
||||||
|
required this.toCheque});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StopSingleChequeScreen> createState() => _StopSingleChequeScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StopSingleChequeScreenState extends State<StopSingleChequeScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final _stopFromChequeNoController = TextEditingController();
|
||||||
|
final _stopIssueDateController = TextEditingController();
|
||||||
|
final _stopExpiryDateController = TextEditingController();
|
||||||
|
final _stopAmountController = TextEditingController();
|
||||||
|
final _stopCommentController = TextEditingController();
|
||||||
|
|
||||||
|
bool _validateChequeNumber() {
|
||||||
|
final value = _stopFromChequeNoController.text;
|
||||||
|
if (value.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Please enter a cheque number')),
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final chequeNumber = int.tryParse(value);
|
||||||
|
final fromCheque = int.tryParse(widget.fromCheque);
|
||||||
|
final toCheque = int.tryParse(widget.toCheque);
|
||||||
|
if (chequeNumber == null || fromCheque == null || toCheque == null) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Invalid cheque number format')),
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
'Cheque number must be between ${widget.fromCheque} and ${widget.toCheque}')),
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Stop Single Cheque'),
|
||||||
|
),
|
||||||
|
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: const Text("Account Number"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopFromChequeNoController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Cheque Number',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
// This validator will only return null or empty string to allow SnackBar to display
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return ''; // Return empty string to trigger error state without message
|
||||||
|
}
|
||||||
|
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 '';
|
||||||
|
}
|
||||||
|
if (chequeNumber < fromCheque || chequeNumber > toCheque) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
initialValue: widget.instrType,
|
||||||
|
readOnly: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Instrument Type',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopIssueDateController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Stop Issue Date',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.datetime,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopExpiryDateController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Stop Expiry Date',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.datetime,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopAmountController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Stop Amount',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
controller: _stopCommentController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Stop Comment',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextFormField(
|
||||||
|
initialValue: widget.date,
|
||||||
|
readOnly: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Chequebook Issue Date',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate() && _validateChequeNumber()) {
|
||||||
|
// TODO: Implement stop single cheque logic
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text('Stop Cheque'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user