Skip to content
Open
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 @@ -28,7 +28,8 @@ import com.flipcash.app.contact.verification.VerificationFlowScreen
import com.flipcash.app.currencycreator.CurrencyCreatorFlowScreen
import com.flipcash.app.core.AppRoute
import com.flipcash.app.currency.RegionSelectionScreen
import com.flipcash.app.deposit.DepositScreen
import com.flipcash.app.deposit.DepositDestinationScreen
import com.flipcash.app.deposit.DepositFlowScreen
import com.flipcash.app.discovery.TokenDiscoveryScreen
import com.flipcash.app.discovery.TokenDiscoverySheet
import com.flipcash.app.internal.ui.navigation.decorators.rememberNavMessagingEntryDecorator
Expand Down Expand Up @@ -126,13 +127,15 @@ fun appEntryProvider(
annotatedEntry<AppRoute.Menu.AppSettings> { AppSettingsScreen() }
annotatedEntry<AppRoute.Menu.Lab> { LabsScreen() }
annotatedEntry<AppRoute.Menu.MyAccount> { MyAccountScreen() }
annotatedEntry<AppRoute.Menu.Deposit> { key -> DepositScreen(key.mint) }
annotatedEntry<AppRoute.Menu.BackupKey> { BackupKeyScreen() }
annotatedEntry<AppRoute.Menu.AdvancedFeatures> { AdvancedFeaturesScreen() }
annotatedEntry<AppRoute.Menu.DeviceLogs> { DeviceLogsScreen() }

annotatedEntry<AppRoute.UserFlags> { UserFlagsScreen() }
// Transfers
annotatedEntry<AppRoute.Transfers.Deposit> { key ->
DepositFlowScreen(route = key, resultStateRegistry = resultStateRegistry)
}
annotatedEntry<AppRoute.Transfers.Withdrawal> { key ->
WithdrawalFlowScreen(route = key, resultStateRegistry = resultStateRegistry)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.flipcash.app.core

import android.os.Parcelable
import androidx.navigation3.runtime.NavKey
import com.flipcash.app.core.deposit.DepositResult
import com.flipcash.app.core.deposit.DepositStep
import com.flipcash.app.core.money.RegionSelectionKind
import com.flipcash.app.core.tokens.CurrencyCreatorResult
import com.flipcash.app.core.tokens.CurrencyCreatorStep
Expand Down Expand Up @@ -168,6 +170,15 @@ sealed interface AppRoute : NavKey, Parcelable {
@Serializable
@Parcelize
sealed interface Transfers : AppRoute {
@Serializable
data class Deposit(val mint: Mint): Transfers, FlowRouteWithResult<DepositResult> {
override val initialStack: List<NavKey>
get() = if (mint == Mint.usdf) {
listOf(DepositStep.UsdcInformational)
} else {
listOf(DepositStep.Destination(mint))
}
}

@Serializable
data class Withdrawal(val mint: Mint) : Transfers, FlowRouteWithResult<WithdrawalResult> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.flipcash.app.core.deposit

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

@Serializable
sealed interface DepositResult : Parcelable {
@Parcelize
@Serializable
data object Success : DepositResult

@Parcelize
@Serializable
data object Canceled : DepositResult
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.flipcash.app.core.deposit

import android.os.Parcelable
import com.getcode.navigation.flow.FlowStep
import com.getcode.solana.keys.Mint
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

/**
* Steps inside the Withdrawal flow. Owned by [com.flipcash.app.core.AppRoute.Transfers.Withdrawal]
* and rendered inside a [com.getcode.navigation.flow.FlowHost].
*/
@Serializable
sealed interface DepositStep : FlowStep, Parcelable {
@Parcelize
object UsdcInformational : DepositStep


@Parcelize
@Serializable
data class Destination(val mint: Mint) : DepositStep
}

This file was deleted.

5 changes: 5 additions & 0 deletions apps/flipcash/core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<string name="subtitle_currentValueOfAllCurrencies">The current value of your currencies</string>
<string name="subtitle_ofUsdStablecoins">of US dollar stablecoins</string>
<string name="action_depositFunds">Deposit</string>
<string name="title_deposit">Deposit</string>
<string name="title_depositFunds">Deposit Funds</string>

<string name="title_withdraw">Withdraw</string>
Expand Down Expand Up @@ -638,6 +639,7 @@
<string name="description_withdrawUsdfAsUsdc">Your USDF will be converted 1:1 to Solana USDC on withdrawal</string>
<string name="displayName_solanaUsdc">Solana USDC</string>
<string name="displayName_usdc">USDC</string>
<string name="displayName_usdf">USDF</string>
<string name="label_withdrawalAmount">Withdrawal amount</string>
<string name="label_lessFee">Less fee</string>
<string name="label_netAmount">Net amount</string>
Expand All @@ -647,6 +649,9 @@

<string name="action_discover">Discover</string>

<string name="title_depositUsdcAsUsdf">Deposit USDC</string>
<string name="description_depositUsdcAsUsdf">Your Solana USDC will be converted 1:1 to USD on Flipcash (USDF)</string>

<string name="title_buyWithPhantom">Buy With Phantom</string>
<string name="description_buyWithPhantom">Purchase using Solana USDC in Phantom. Simply connect your wallet and confirm the transaction</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ private fun BalanceScreenContent(
TokenList(
modifier = Modifier.weight(1f),
itemModifier = { Modifier.animateItem(fadeInSpec = null) },
includeReserves = true,
header = {
BalanceHeader(
modifier = Modifier
Expand Down Expand Up @@ -124,15 +125,6 @@ private fun BalanceScreenContent(
}
}
},
reserves = { mint, reserves ->
CashReservesRow(reserves) {
dispatchEvent(
BalanceViewModel.Event.OpenScreen(
AppRoute.Token.Info(mint)
)
)
}
},
pinFooter = true,
footer = if (tokenState.discoveryEnabled) {
{
Expand Down
1 change: 1 addition & 0 deletions apps/flipcash/features/deposit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android {
dependencies {
implementation(project(":libs:messaging"))

implementation(project(":apps:flipcash:shared:featureflags"))
implementation(project(":services:flipcash"))

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.flipcash.app.deposit.internal.DepositScreen
import com.flipcash.app.deposit.internal.DepositDestinationScreen
import com.flipcash.app.deposit.internal.DepositViewModel
import com.flipcash.core.R
import com.getcode.navigation.core.LocalCodeNavigator
import com.getcode.solana.keys.Mint
import com.getcode.ui.components.AppBarWithTitle

@Composable
fun DepositScreen(mint: Mint) {
fun DepositDestinationScreen(mint: Mint) {
val navigator = LocalCodeNavigator.current
val viewModel = hiltViewModel<DepositViewModel>()
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
Expand All @@ -33,7 +33,7 @@ fun DepositScreen(mint: Mint) {
backButton = true,
onBackIconClicked = { navigator.pop() },
)
DepositScreen(viewModel)
DepositDestinationScreen(viewModel)
}

LaunchedEffect(viewModel, mint) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.flipcash.app.deposit

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewWrapper
import androidx.navigation3.runtime.NavEntry
import androidx.navigation3.runtime.NavKey
import androidx.navigation3.runtime.entryProvider
import com.flipcash.app.core.AppRoute
import com.flipcash.app.core.deposit.DepositResult
import com.flipcash.app.core.deposit.DepositStep
import com.flipcash.app.featureflags.FeatureFlag
import com.flipcash.app.featureflags.LocalFeatureFlags
import com.flipcash.app.deposit.internal.DepositViewModel
import com.flipcash.app.deposit.internal.UsdcDepositInformationScreen
import com.flipcash.app.theme.FlipcashThemeWrapper
import com.getcode.navigation.annotatedEntry
import com.getcode.navigation.core.LocalCodeNavigator
import com.getcode.navigation.flow.FlowExitReason
import com.getcode.navigation.flow.FlowHost
import com.getcode.navigation.flow.LocalFlowNavigator
import com.getcode.navigation.flow.PreviewFlowNavigator
import com.getcode.navigation.flow.deliverFlowResult
import com.getcode.navigation.flow.rememberInitialStack
import com.getcode.navigation.results.NavResultOrCanceled
import com.getcode.navigation.results.NavResultStateRegistry
import com.getcode.solana.keys.Mint

@Composable
fun DepositFlowScreen(
route: AppRoute.Transfers.Deposit,
resultStateRegistry: NavResultStateRegistry,
) {
val outerNavigator = LocalCodeNavigator.current
val featureFlags = LocalFeatureFlags.current

val initialStack = route.rememberInitialStack<DepositStep> { steps ->
val directDeposit = featureFlags.observe(FeatureFlag.DepositUsdc).value
if (!directDeposit && route.mint == Mint.usdf) {
listOf(DepositStep.Destination(route.mint))
} else {
steps
}
}

FlowHost(
initialStack = initialStack,
resultStateRegistry = resultStateRegistry,
onExit = { reason ->
val result: DepositResult = when (reason) {
is FlowExitReason.Completed -> reason.result
FlowExitReason.Canceled,
FlowExitReason.BackedOutOfRoot -> DepositResult.Canceled
}
outerNavigator.deliverFlowResult(
route = route,
value = NavResultOrCanceled.ReturnValue(result),
)
when (result) {
DepositResult.Success -> {
outerNavigator.popUntil { it == AppRoute.Sheets.Menu }
}
DepositResult.Canceled -> {
outerNavigator.pop()
}
}
},
entryProvider = depositEntryProvider(route.mint),
)
}

private fun depositEntryProvider(
mint: Mint,
): (NavKey) -> NavEntry<NavKey> = entryProvider {
annotatedEntry<DepositStep.UsdcInformational> {
UsdcDepositInformationScreen()
}
annotatedEntry<DepositStep.Destination> {
DepositDestinationScreen(mint)
}
}

@Composable
private fun DepositFlowPreview(
content: @Composable (state: DepositViewModel.State) -> Unit
) {
CompositionLocalProvider(
LocalFlowNavigator provides PreviewFlowNavigator<DepositStep, DepositResult>(),
) {
val state = DepositViewModel.State()
content(state)
}
}

@Preview
@PreviewWrapper(FlipcashThemeWrapper::class)
@Composable
private fun Preview_UsdcInformational() {
DepositFlowPreview { UsdcDepositInformationScreen() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import com.getcode.ui.theme.CodeButton
import com.getcode.ui.theme.CodeScaffold

@Composable
internal fun DepositScreen(viewModel: DepositViewModel) {
internal fun DepositDestinationScreen(viewModel: DepositViewModel) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
DepositScreenContent(state, viewModel::dispatchEvent)
}
Expand Down
Loading
Loading