diff --git a/apps/flipcash/core/src/androidMain/res/values/strings.xml b/apps/flipcash/core/src/androidMain/res/values/strings.xml index f391c7b7f1..22981b460c 100644 --- a/apps/flipcash/core/src/androidMain/res/values/strings.xml +++ b/apps/flipcash/core/src/androidMain/res/values/strings.xml @@ -1207,7 +1207,7 @@ Didn\'t pay %1$s · Hasn\'t paid yet - Send %1$s + Pay %1$s Request options Close Close Request diff --git a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestDetailsScreen.kt b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestDetailsScreen.kt index d521539db3..047a6e52b3 100644 --- a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestDetailsScreen.kt +++ b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestDetailsScreen.kt @@ -164,7 +164,7 @@ internal fun RequestDetailsScreen( .padding(horizontal = CodeTheme.dimens.inset) .padding(bottom = CodeTheme.dimens.grid.x2) .testTag("request_details_send"), - text = stringResource(R.string.action_sendShare, share.amount.requestText()), + text = stringResource(R.string.action_payShare, share.amount.requestText()), buttonState = ButtonState.Filled, isLoading = pay.preparing, onClick = viewModel::payTapped, diff --git a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPayFlow.kt b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPayFlow.kt index dd9c3433ff..ba45571d98 100644 --- a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPayFlow.kt +++ b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPayFlow.kt @@ -59,7 +59,7 @@ internal class RequestPayFlow( ) { data class State( val requestId: ID? = null, - /** Refetching before the sheet opens: the caller's Send button spins. */ + /** Refetching before the sheet opens: the caller's Pay button spins. */ val preparing: Boolean = false, /** The swipe sheet is up. */ val open: Boolean = false, diff --git a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPaySheet.kt b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPaySheet.kt index d0766fd7a0..b6f75ad8d5 100644 --- a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPaySheet.kt +++ b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/request/RequestPaySheet.kt @@ -95,16 +95,21 @@ internal fun RequestPaySheet( PayShareSheet( creator = members[request.creator], share = share, - swipePay = SwipePayUiState( - token = token, - progress = pay.progress, - tokenPickable = true, - swipeTestTag = "request_pay_swipe", - ), + swipePay = requestPaySwipeState(pay, token), actions = actions, ) } +/** The swipe for a share: the viewer pays the request, so it reads "Swipe to Pay". */ +internal fun requestPaySwipeState(pay: RequestPayFlow.State, token: Token?): SwipePayUiState = + SwipePayUiState( + token = token, + progress = pay.progress, + tokenPickable = true, + swipeLabel = R.string.action_swipeToPay, + swipeTestTag = "request_pay_swipe", + ) + /** * Frame 10: who is being paid, the share, the token, and the swipe. The token pill swaps this * sheet's content for the currency list, as on the group send confirm sheet. diff --git a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/swipepay/SwipePaySheet.kt b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/swipepay/SwipePaySheet.kt index 44bb9cba91..98e3e65b56 100644 --- a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/swipepay/SwipePaySheet.kt +++ b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/swipepay/SwipePaySheet.kt @@ -1,6 +1,7 @@ package com.flipcash.app.messenger.internal.swipepay import androidx.activity.compose.BackHandler +import androidx.annotation.StringRes import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues @@ -50,6 +51,8 @@ internal data class SwipePayUiState( val tokenPickable: Boolean, /** True when only back closes the sheet: no drag, no tap on the scrim. */ val backOnly: Boolean = false, + /** The swipe's label: "Swipe to Send" unless the flow pays a request. */ + @StringRes val swipeLabel: Int = R.string.action_swipeToSend, val swipeTestTag: String? = null, ) { /** A swipe is in flight or has finished; the sheet holds still until the flow lets go. */ @@ -122,7 +125,7 @@ internal fun SwipePaySheet( enabled = state.progress.isIdle, isLoading = state.progress.loading, isSuccess = state.progress.success, - label = stringResource(R.string.action_swipeToSend), + label = stringResource(state.swipeLabel), ) } Column( diff --git a/apps/flipcash/features/messenger/src/test/kotlin/com/flipcash/app/messenger/internal/request/RequestPayLabelTest.kt b/apps/flipcash/features/messenger/src/test/kotlin/com/flipcash/app/messenger/internal/request/RequestPayLabelTest.kt new file mode 100644 index 0000000000..94c0e6334d --- /dev/null +++ b/apps/flipcash/features/messenger/src/test/kotlin/com/flipcash/app/messenger/internal/request/RequestPayLabelTest.kt @@ -0,0 +1,38 @@ +package com.flipcash.app.messenger.internal.request + +import com.flipcash.app.messenger.internal.swipepay.SwipePayUiState +import com.flipcash.features.messenger.R +import com.getcode.view.LoadingSuccessState +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.RuntimeEnvironment +import org.robolectric.annotation.Config +import kotlin.test.Test +import kotlin.test.assertEquals + +/** Paying a request reads "Pay"; sending to a group or from Currency Info still reads "Send". */ +@RunWith(RobolectricTestRunner::class) +@Config(manifest = Config.NONE) +class RequestPayLabelTest { + + private val context = RuntimeEnvironment.getApplication() + + @Test + fun `request pay swipe reads swipe to pay`() { + val state = requestPaySwipeState(RequestPayFlow.State(open = true), token = null) + + assertEquals("Swipe to Pay", context.getString(state.swipeLabel)) + } + + @Test + fun `send swipe keeps swipe to send`() { + val state = SwipePayUiState(token = null, progress = LoadingSuccessState(), tokenPickable = true) + + assertEquals("Swipe to Send", context.getString(state.swipeLabel)) + } + + @Test + fun `request details button reads pay and the share`() { + assertEquals("Pay $20", context.getString(R.string.action_payShare, "$20")) + } +}