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

Commit

Permalink
Add horizontal swipe gesture to loans screen (#3604)
Browse files Browse the repository at this point in the history
  • Loading branch information
p42rthicle authored Oct 12, 2024
1 parent 130e2b8 commit 3479e35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit 3479e35

Please sign in to comment.