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

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