From 3479e354c0d68cad7066d1abb1bc342711f6eb88 Mon Sep 17 00:00:00 2001 From: Parth Takkar <128719760+p42rthicle@users.noreply.github.com> Date: Sun, 13 Oct 2024 00:03:35 +0530 Subject: [PATCH] Add horizontal swipe gesture to loans screen (#3604) --- .../src/main/java/com/ivy/loans/loan/Constants.kt | 5 +++++ .../src/main/java/com/ivy/loans/loan/LoansScreen.kt | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 screen/loans/src/main/java/com/ivy/loans/loan/Constants.kt diff --git a/screen/loans/src/main/java/com/ivy/loans/loan/Constants.kt b/screen/loans/src/main/java/com/ivy/loans/loan/Constants.kt new file mode 100644 index 0000000000..f71ebc03a8 --- /dev/null +++ b/screen/loans/src/main/java/com/ivy/loans/loan/Constants.kt @@ -0,0 +1,5 @@ +package com.ivy.loans.loan + +internal object Constants { + const val SWIPE_HORIZONTAL_THRESHOLD = 200 +} diff --git a/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt b/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt index 88ba8221ff..214c50d2ea 100644 --- a/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt +++ b/screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt @@ -41,6 +41,9 @@ import com.ivy.legacy.datamodel.Loan import com.ivy.legacy.humanReadableType import com.ivy.legacy.ivyWalletCtx import com.ivy.legacy.utils.getDefaultFIATCurrency +import com.ivy.legacy.utils.horizontalSwipeListener +import com.ivy.legacy.utils.rememberSwipeListenerState +import com.ivy.loans.loan.Constants.SWIPE_HORIZONTAL_THRESHOLD import com.ivy.loans.loan.data.DisplayLoan import com.ivy.navigation.LoanDetailsScreen import com.ivy.navigation.LoansScreen @@ -84,6 +87,16 @@ private fun BoxWithConstraintsScope.UI( modifier = Modifier .fillMaxSize() .systemBarsPadding() + .horizontalSwipeListener( + sensitivity = SWIPE_HORIZONTAL_THRESHOLD, + state = rememberSwipeListenerState(), + onSwipeLeft = { + onEventHandler.invoke(LoanScreenEvent.OnTabChanged(LoanTab.COMPLETED)) + }, + onSwipeRight = { + onEventHandler.invoke(LoanScreenEvent.OnTabChanged(LoanTab.PENDING)) + } + ) ) { Spacer(Modifier.height(32.dp))