You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.2 KiB
152 lines
5.2 KiB
import 'package:flutter/material.dart';
|
|
|
|
class AddTransactionScreen extends StatefulWidget {
|
|
@override
|
|
_AddTransactionScreenState createState() => _AddTransactionScreenState();
|
|
}
|
|
|
|
class _AddTransactionScreenState extends State<AddTransactionScreen> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
String? transactionType;
|
|
String? accountName;
|
|
String? paymentMode;
|
|
String? paymentStatus;
|
|
|
|
TextEditingController amountController = TextEditingController(text: "₹500");
|
|
TextEditingController transactionIdController = TextEditingController(text: "₹500");
|
|
TextEditingController dateController = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
elevation: 0,
|
|
leading: Icon(Icons.arrow_back, color: Colors.black),
|
|
title: Text(
|
|
"Add Transaction",
|
|
style: TextStyle(color: Colors.black, fontWeight: FontWeight.w600),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () {},
|
|
child: Text("HELP", style: TextStyle(color: Colors.purple)),
|
|
)
|
|
],
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
buildDropdown("Transaction Type *", ["Credit", "Debit"], transactionType, (val) {
|
|
setState(() => transactionType = val);
|
|
}),
|
|
SizedBox(height: 16),
|
|
buildDropdown("Account Name *", ["Name1", "Name2"], accountName, (val) {
|
|
setState(() => accountName = val);
|
|
}),
|
|
SizedBox(height: 16),
|
|
buildTextField("Amount (in ₹) *", amountController),
|
|
SizedBox(height: 16),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: buildDropdown("Payment Mode *", ["Cash", "Card", "UPI"], paymentMode, (val) {
|
|
setState(() => paymentMode = val);
|
|
}),
|
|
),
|
|
SizedBox(width: 12),
|
|
Expanded(
|
|
child: buildDatePicker(),
|
|
),
|
|
],
|
|
),
|
|
SizedBox(height: 16),
|
|
buildTextField("Transaction ID *", transactionIdController),
|
|
SizedBox(height: 16),
|
|
buildDropdown("Payment Status *", ["Pending", "Completed", "Failed"], paymentStatus, (val) {
|
|
setState(() => paymentStatus = val);
|
|
}),
|
|
SizedBox(height: 24),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFF8270DB),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
padding: EdgeInsets.symmetric(vertical: 14),
|
|
),
|
|
onPressed: () {
|
|
if (_formKey.currentState!.validate()) {
|
|
// Handle save
|
|
}
|
|
},
|
|
child: Text("Save", style: TextStyle(color: Colors.white, fontSize: 16)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildDropdown(String label, List<String> items, String? value, Function(String?) onChanged) {
|
|
return DropdownButtonFormField<String>(
|
|
decoration: InputDecoration(
|
|
labelText: label,
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
|
),
|
|
value: value,
|
|
items: items.map((e) => DropdownMenuItem(value: e, child: Text(e))).toList(),
|
|
onChanged: onChanged,
|
|
);
|
|
}
|
|
|
|
Widget buildTextField(String label, TextEditingController controller) {
|
|
return TextFormField(
|
|
controller: controller,
|
|
decoration: InputDecoration(
|
|
labelText: label,
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildDatePicker() {
|
|
return TextFormField(
|
|
controller: dateController,
|
|
readOnly: true,
|
|
decoration: InputDecoration(
|
|
labelText: "Date *",
|
|
suffixIcon: Icon(Icons.calendar_today),
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
|
),
|
|
onTap: () async {
|
|
DateTime? picked = await showDatePicker(
|
|
context: context,
|
|
initialDate: DateTime.now(),
|
|
firstDate: DateTime(2000),
|
|
lastDate: DateTime(2100),
|
|
);
|
|
if (picked != null) {
|
|
setState(() {
|
|
dateController.text = "${picked.day}-${picked.month}-${picked.year}";
|
|
});
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|