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
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fun appEntryProvider(

// Tokens
annotatedEntry<AppRoute.Token.Info>(testTag = "token_info_screen") { key ->
TokenInfoScreen(key.mint, key.shortfall, key.fromDeeplink, key.asPush)
TokenInfoScreen(key.mint, key.shortfall, key.fromDeeplink, key.asPush, key.returnAfterBuy)
}
annotatedEntry<AppRoute.Token.Transactions>(testTag = "transaction_history_screen") { key ->
TransactionHistoryScreen(key.mint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ sealed interface AppRoute : NavKey, Parcelable {
// (fade-in-place, ✕ dismiss). Set when the screen is reached by drilling in from a list — e.g.
// token discovery — where a back arrow that slides back is the expected navigation.
val asPush: Boolean = false,
// Pop back to whatever opened this screen once a buy of [mint] succeeds, rather than
// staying here. Set by a chat's gate: the reader came to buy their way into the group,
// so the purchase finishing is the moment to put them back in front of Join.
val returnAfterBuy: Boolean = false,
) : Token

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ internal fun MessengerScreen(viewModel: ChatViewModel) {
// A drill-in from the transcript, so push it: the fade-in-place
// expand is the wallet card growing into its own detail, and there
// is no card here for it to grow from.
AppRoute.Token.Info(action.mint, asPush = true)
AppRoute.Token.Info(
action.mint,
asPush = true,
returnAfterBuy = action.returnAfterBuy,
)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ internal fun GroupGateBar(
enabled = currency != null,
onClick = {
unmetBalance.mints.firstOrNull()
?.let { onAction(ChatAction.ViewToken(Mint(it.bytes))) }
?.let { onAction(ChatAction.ViewToken(Mint(it.bytes), returnAfterBuy = true)) }
},
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.flipcash.app.analytics.Analytics
import com.flipcash.app.analytics.Button
import com.flipcash.app.analytics.rememberAnalytics
import com.flipcash.app.core.AppRoute
import com.flipcash.app.core.tokens.SwapPurpose
import com.flipcash.app.core.tokens.SwapResult
import com.flipcash.app.tokens.internal.TokenInfoScreen
import com.flipcash.app.tokens.internal.components.info.CurrencyInfoTitlePill
Expand Down Expand Up @@ -66,6 +67,7 @@ fun TokenInfoScreen(
shortFall: Fiat?,
fromDeeplink: Boolean,
asPush: Boolean = false,
returnAfterBuy: Boolean = false,
) {
val navigator = LocalCodeNavigator.current
val analytics = rememberAnalytics()
Expand Down Expand Up @@ -198,9 +200,18 @@ fun TokenInfoScreen(
when (screen) {
is AppRoute.Token.Swap -> {
navigator.navigateForResult<SwapResult>(screen) { result ->
if (result is NavResultOrCanceled.ReturnValue &&
result.value is SwapResult.OpenDeposit) {
navigator.push(AppRoute.Transfers.Deposit(showOtherOptions = false))
if (result !is NavResultOrCanceled.ReturnValue) return@navigateForResult
when (result.value) {
is SwapResult.OpenDeposit ->
navigator.push(AppRoute.Transfers.Deposit(showOtherOptions = false))
// Only a buy of this currency. Add Money from here also ends in a
// successful Buy, but of USDF to fund this one, and the reader
// still has this purchase to make.
is SwapResult.Success -> {
val bought = (screen.purpose as? SwapPurpose.Buy)?.mint
if (returnAfterBuy && bought == mint) navigator.pop()
}
else -> Unit
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ sealed interface ChatAction {
data class RetryMessage(val bubble: ChatListItem.ContentBubble) : ChatAction
data class AdvanceReadPointer(val messageId: Long) : ChatAction
object RefreshContact : ChatAction
data class ViewToken(val mint: Mint) : ChatAction
/**
* Opens a currency's info screen. [returnAfterBuy] brings the reader back here once they buy
* it — set by the group gate, where buying is how they get in.
*/
data class ViewToken(val mint: Mint, val returnAfterBuy: Boolean = false) : ChatAction

/**
* Opens the group a link card names, pushed over this chat so Back returns here. The pushed
Expand Down
Loading