163 lines
5.8 KiB
Dart
163 lines
5.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:kmobile/data/models/user.dart';
|
|
import 'package:kmobile/l10n/app_localizations.dart';
|
|
|
|
class PositivePayScreen extends StatefulWidget {
|
|
final List<User> users;
|
|
final int selectedIndex;
|
|
const PositivePayScreen({
|
|
super.key,
|
|
required this.users,
|
|
required this.selectedIndex,
|
|
});
|
|
|
|
@override
|
|
State<PositivePayScreen> createState() => _PositivePayScreenState();
|
|
}
|
|
|
|
class _PositivePayScreenState extends State<PositivePayScreen> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
final _accountNumberController = TextEditingController();
|
|
final _chequeNumberController = TextEditingController();
|
|
final _chequeDateController = TextEditingController();
|
|
final _amountController = TextEditingController();
|
|
final _payeeController = TextEditingController();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// Pre-fill the account number if possible
|
|
if (widget.users.isNotEmpty) {
|
|
_accountNumberController.text = widget.users[widget.selectedIndex].accountNo!;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_accountNumberController.dispose();
|
|
_chequeNumberController.dispose();
|
|
_chequeDateController.dispose();
|
|
_amountController.dispose();
|
|
_payeeController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(
|
|
AppLocalizations.of(context).positivePay, // Will be replaced by localization
|
|
),
|
|
centerTitle: false,
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
const SizedBox(height: 16.0),
|
|
TextFormField(
|
|
controller: _accountNumberController,
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context).accountNumber,
|
|
border: const OutlineInputBorder(),
|
|
),
|
|
keyboardType: TextInputType.number,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Please enter account number';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
const SizedBox(height: 16.0),
|
|
TextFormField(
|
|
controller: _chequeNumberController,
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context).chequeNumberLabel,
|
|
border: const OutlineInputBorder(),
|
|
),
|
|
keyboardType: TextInputType.number,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return AppLocalizations.of(context).pleaseEnterChequeNumber;
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
const SizedBox(height: 16.0),
|
|
TextFormField(
|
|
controller: _chequeDateController,
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context).chequeIssuedDate,
|
|
border: const OutlineInputBorder(),
|
|
suffixIcon: const Icon(Icons.calendar_today),
|
|
),
|
|
readOnly: true,
|
|
onTap: () async {
|
|
DateTime? pickedDate = await showDatePicker(
|
|
context: context,
|
|
initialDate: DateTime.now(),
|
|
firstDate: DateTime(2000),
|
|
lastDate: DateTime.now(),
|
|
);
|
|
if (pickedDate != null) {
|
|
// Format the date as you wish
|
|
String formattedDate = "${pickedDate.day}-${pickedDate.month}-${pickedDate.year}";
|
|
_chequeDateController.text = formattedDate;
|
|
}
|
|
},
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return AppLocalizations.of(context).pleaseSelectChequeIssuedDate;
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
const SizedBox(height: 16.0),
|
|
TextFormField(
|
|
controller: _payeeController,
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context).payeeName,
|
|
border: const OutlineInputBorder(),
|
|
),
|
|
),
|
|
const SizedBox(height: 16.0),
|
|
TextFormField(
|
|
controller: _amountController,
|
|
decoration: InputDecoration(
|
|
labelText: AppLocalizations.of(context).amountLabel,
|
|
border: const OutlineInputBorder(),
|
|
prefixText: '₹ ',
|
|
),
|
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return AppLocalizations.of(context).pleaseEnterAmount;
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
const SizedBox(height: 32.0),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
if (_formKey.currentState!.validate()) {
|
|
// Process data
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text(AppLocalizations.of(context).processingData)),
|
|
);
|
|
}
|
|
},
|
|
child: Text(AppLocalizations.of(context).proceedButton),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|