Skip to content
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
2 changes: 1 addition & 1 deletion apps/flipcash/core/src/androidMain/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@
<string name="label_shareUnpaidEnded">Didn\'t pay</string>
<!-- Under the member's name on the Mark as Paid sheet: "$20 · Hasn't paid yet". -->
<string name="label_shareUnpaidAmount">%1$s · Hasn\'t paid yet</string>
<string name="action_sendShare">Send %1$s</string>
<string name="action_payShare">Pay %1$s</string>
<string name="cd_requestOptions">Request options</string>
<string name="cd_close">Close</string>
<string name="action_closeRequest">Close Request</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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"))
}
}
Loading