From 3a6756c8d3ab40a19d9ad4465700a0c4ce1bce08 Mon Sep 17 00:00:00 2001 From: Manish Date: Thu, 20 Nov 2025 11:57:13 +0530 Subject: [PATCH] advance paymen --- lib/view/finance/advance_payment_screen.dart | 49 +++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/view/finance/advance_payment_screen.dart b/lib/view/finance/advance_payment_screen.dart index 4a59de8..77dcf36 100644 --- a/lib/view/finance/advance_payment_screen.dart +++ b/lib/view/finance/advance_payment_screen.dart @@ -35,6 +35,8 @@ class _AdvancePaymentScreenState extends State } }); + _searchCtrl.addListener(() { + controller.searchQuery.value = _searchCtrl.text.trim(); _searchCtrl.addListener(() { controller.searchQuery.value = _searchCtrl.text.trim(); }); @@ -58,6 +60,25 @@ class _AdvancePaymentScreenState extends State final bool isLandscape = constraints.maxWidth > constraints.maxHeight; + return RefreshIndicator( + onRefresh: () async { + final emp = controller.selectedEmployee.value; + if (emp != null) { + await controller.fetchAdvancePayments(emp.id.toString()); + } + }, + color: Colors.white, + backgroundColor: contentTheme.primary, + strokeWidth: 2.5, + displacement: 60, + child: GestureDetector( + behavior: HitTestBehavior.translucent, + onTap: () { + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + }, return RefreshIndicator( onRefresh: () async { final emp = controller.selectedEmployee.value; @@ -208,6 +229,13 @@ class _AdvancePaymentScreenState extends State } }); }, + onTap: () { + Future.delayed(const Duration(milliseconds: 50), () { + if (mounted) { + FocusScope.of(context).requestFocus(_searchFocus); + } + }); + }, decoration: InputDecoration( contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 0), @@ -287,6 +315,12 @@ class _AdvancePaymentScreenState extends State TextPosition(offset: e.name.length), ); + _searchCtrl + ..text = e.name + ..selection = TextSelection.fromPosition( + TextPosition(offset: e.name.length), + ); + FocusScope.of(context).unfocus(); SystemChannels.textInput.invokeMethod('TextInput.hide'); controller.employees.clear(); @@ -413,7 +447,9 @@ class _AdvancePaymentScreenState extends State ? DateFormat('dd MMM yyyy').format(parsedDate) : (dateStr.isNotEmpty ? dateStr : '—'); - + // final formattedTime = + // parsedDate != null ? DateFormat('hh:mm a').format(parsedDate) : ''; + final project = item.name ?? ''; final desc = item.title ?? ''; final amount = (item.amount ?? 0).toDouble(); @@ -443,7 +479,16 @@ class _AdvancePaymentScreenState extends State style: TextStyle(fontSize: 12, color: Colors.grey.shade600), ), - + // if (formattedTime.isNotEmpty) ...[ + // const SizedBox(width: 6), + // Text( + // formattedTime, + // style: TextStyle( + // fontSize: 12, + // color: Colors.grey.shade500, + // fontStyle: FontStyle.italic), + // ), + // ] ], ), const SizedBox(height: 4),