Swipe_Button_on_quick_pay
This commit is contained in:
@@ -9,8 +9,9 @@ class AccountStatementScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AccountStatementScreen extends State<AccountStatementScreen>{
|
||||
DateTimeRange? selectedDateRange;
|
||||
final _amountRangeController = TextEditingController(text: "100-500");
|
||||
DateTime? fromDate;
|
||||
DateTime? toDate;
|
||||
final _amountRangeController = TextEditingController(text: "");
|
||||
final transactions = [
|
||||
{"desc": "Transfer From ICICI Bank subsidy", "amount": "+₹133.98", "type": "Cr", "time": "21-02-2024 13:09:30"},
|
||||
{"desc": "Mobile recharge", "amount": "-₹299.00", "type": "Dr", "time": "21-02-2024 13:09:30"},
|
||||
@@ -21,20 +22,32 @@ class _AccountStatementScreen extends State<AccountStatementScreen>{
|
||||
{"desc": "Transfer From ICICI Bank subsidy", "amount": "+₹100.00", "type": "Cr", "time": "21-02-2024 13:09:30"},
|
||||
];
|
||||
|
||||
Future<void> _selectDateRange(BuildContext context) async {
|
||||
final DateTime now = DateTime.now();
|
||||
void _selectDate({required bool isFromDate}) async {
|
||||
final DateTime initial = isFromDate ? fromDate ?? DateTime.now() : toDate ?? fromDate ?? DateTime.now();
|
||||
|
||||
final DateTimeRange? picked = await showDateRangePicker(
|
||||
final DateTime? picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: initial,
|
||||
firstDate: DateTime(2023),
|
||||
lastDate: now, // disables future dates
|
||||
initialDateRange: selectedDateRange ??
|
||||
DateTimeRange(start: now.subtract(const Duration(days: 7)), end: now),
|
||||
lastDate: DateTime(2030),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
setState(() {
|
||||
selectedDateRange = picked;
|
||||
if (isFromDate) {
|
||||
fromDate = picked;
|
||||
if (toDate != null && toDate!.isBefore(fromDate!)) {
|
||||
toDate = null; // reset invalid toDate
|
||||
}
|
||||
} else {
|
||||
if (fromDate != null && picked.isBefore(fromDate!)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text("To Date cannot be before From Date"),
|
||||
));
|
||||
} else {
|
||||
toDate = picked;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -82,11 +95,13 @@ class _AccountStatementScreen extends State<AccountStatementScreen>{
|
||||
const SizedBox(height: 15,),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _buildDateRangeSelector()),
|
||||
Expanded(child: _buildFromDateSelector()),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: _buildFilterBox("100-500")),
|
||||
Expanded(child: _buildToDateSelector()),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildFilterBox(""),
|
||||
const SizedBox(height: 35),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -104,16 +119,9 @@ class _AccountStatementScreen extends State<AccountStatementScreen>{
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDateRangeSelector() {
|
||||
String label = "Select Date";
|
||||
if (selectedDateRange != null) {
|
||||
final from = _formatDate(selectedDateRange!.start);
|
||||
final to = _formatDate(selectedDateRange!.end);
|
||||
label = "$from - $to";
|
||||
}
|
||||
|
||||
Widget _buildFromDateSelector() {
|
||||
return GestureDetector(
|
||||
onTap: () => _selectDateRange(context),
|
||||
onTap: () => _selectDate(isFromDate: true),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
@@ -122,8 +130,37 @@ class _AccountStatementScreen extends State<AccountStatementScreen>{
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(label, style: const TextStyle(fontSize: 16))),
|
||||
const Icon(Icons.calendar_today),
|
||||
Expanded(
|
||||
child: Text(
|
||||
fromDate != null ? _formatDate(fromDate!) : "From Date",
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildToDateSelector() {
|
||||
return GestureDetector(
|
||||
onTap: () => _selectDate(isFromDate: false),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
toDate != null ? _formatDate(toDate!) : "To Date",
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.arrow_drop_down),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user