Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Add horizontal swipe gesture to loans screen #3604

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions screen/loans/src/main/java/com/ivy/loans/loan/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.ivy.loans.loan

internal object Constants {
const val SWIPE_HORIZONTAL_THRESHOLD = 200
}
13 changes: 13 additions & 0 deletions screen/loans/src/main/java/com/ivy/loans/loan/LoansScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
Loading