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 @@ -19,6 +19,8 @@ import com.flipcash.app.billing.BillingClient
import com.flipcash.app.contacts.ContactCoordinator
import com.flipcash.app.contacts.LocalContactCoordinator
import com.flipcash.app.core.LocalUserManager
import com.flipcash.app.core.toast.LocalToastController
import com.flipcash.app.core.toast.ToastController
import com.flipcash.app.core.verification.email.EmailCodeChannel
import com.flipcash.app.core.verification.email.LocalEmailCodeChannel
import com.flipcash.app.onramp.LocalCoinbaseOnRampController
Expand Down Expand Up @@ -125,6 +127,9 @@ class MainActivity : FragmentActivity() {
@Inject
lateinit var contactCoordinator: ContactCoordinator

@Inject
lateinit var toastController: ToastController

@Inject
lateinit var coinbaseOnRampController: CoinbaseOnRampController

Expand Down Expand Up @@ -153,6 +158,7 @@ class MainActivity : FragmentActivity() {
LocalAppUpdater provides appUpdater,
LocalEmailCodeChannel provides emailCodeChannel,
LocalContactCoordinator provides contactCoordinator,
LocalToastController provides toastController,
LocalCoinbaseOnRampController provides coinbaseOnRampController,
LocalUiTesting provides intent.getBooleanExtra(UI_TEST, false),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import com.flipcash.app.shareapp.ShareAppScreen
import com.flipcash.app.tokens.SwapFlowScreen
import com.flipcash.app.tokens.TokenInfoScreen
import com.flipcash.app.tokens.TokenSelectScreen
import com.flipcash.app.tokens.TokenTxProcessingScreen

import com.flipcash.app.transactions.TransactionHistoryScreen
import com.flipcash.app.userflags.UserFlagsScreen
import com.flipcash.app.withdrawal.WithdrawalFlowScreen
Expand Down Expand Up @@ -110,10 +110,6 @@ fun appEntryProvider(
annotatedEntry<AppRoute.Token.Swap> { key ->
SwapFlowScreen(route = key, resultStateRegistry = resultStateRegistry)
}
// TODO: fold this into above entry
annotatedEntry<AppRoute.Token.TxProcessing> { key ->
TokenTxProcessingScreen(key.swapId, key.swapPurpose, key.amount, key.isFundingShortfall)
}
annotatedEntry<AppRoute.Token.Discovery> { TokenDiscoveryScreen() }
annotatedEntry<AppRoute.Token.CurrencyCreator> { key ->
CurrencyCreatorFlowScreen(route = key, resultStateRegistry = resultStateRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ import com.flipcash.app.core.verification.VerificationStep
import com.flipcash.app.core.withdrawal.WithdrawalResult
import com.flipcash.app.core.withdrawal.WithdrawalStep
import com.flipcash.app.core.onboarding.OnboardingStep
import com.getcode.navigation.NonDismissableRoute
import com.getcode.navigation.NonDraggableRoute
import com.getcode.navigation.flow.FlowRoute
import com.getcode.navigation.flow.FlowRouteWithResult
import com.getcode.opencode.exchange.VerifiedFiat
import com.getcode.opencode.internal.solana.model.SwapId
import com.getcode.opencode.model.financial.Fiat
import com.getcode.solana.keys.Mint
import com.getcode.solana.keys.PublicKey
import com.getcode.ui.core.RestrictionType
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -181,6 +176,7 @@ sealed interface AppRoute : NavKey, Parcelable {
data class Swap(
val purpose: SwapPurpose,
val shortfall: Fiat? = null,
val popToRoot: Boolean = false,
) : Token, FlowRouteWithResult<SwapResult> {
override val initialStack: List<NavKey>
get() = listOf(SwapStep.Entry(purpose, initialAmount = shortfall))
Expand All @@ -192,13 +188,6 @@ sealed interface AppRoute : NavKey, Parcelable {
@Serializable
data object PhantomConfirmTransaction: Token

@Serializable
data class TxProcessing(
val swapId: SwapId,
val swapPurpose: SwapPurpose? = null,
val amount: VerifiedFiat? = null,
val isFundingShortfall: Boolean = false,
) : Token, NonDismissableRoute, NonDraggableRoute

@Serializable
data object Discovery: AppRoute
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.flipcash.app.core.toast

import androidx.compose.runtime.staticCompositionLocalOf
import com.getcode.opencode.model.financial.Fiat

interface ToastController {
fun showToast(amount: Fiat, isDeposit: Boolean)
}

val LocalToastController = staticCompositionLocalOf<ToastController> {
error("No ToastController provided")
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.flipcash.app.core.tokens

import android.os.Parcelable
import com.getcode.opencode.model.financial.Fiat
import kotlinx.parcelize.Parcelize
import kotlinx.serialization.Serializable

@Serializable
sealed interface SwapResult : Parcelable {
@Parcelize
@Serializable
data object Success : SwapResult
data class Success(val amount: Fiat = Fiat.Zero) : SwapResult

@Parcelize
@Serializable
Expand Down
8 changes: 6 additions & 2 deletions apps/flipcash/core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@
<string name="subtitle_balanceIsHeldInUsdStablecoins">Your balance is held in US dollar stablecoins</string>
<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="action_deposit">Deposit</string>
<string name="title_deposit">Deposit</string>
<string name="title_depositFunds">Deposit Funds</string>
<string name="action_depositFunds">Deposit Funds</string>


<string name="title_withdraw">Withdraw</string>
<string name="title_withdrawFunds">Withdraw Funds</string>
Expand Down Expand Up @@ -235,7 +237,7 @@
<string name="title_tapAboveToAddCashToWallet">Tap above to Add Cash to your wallet</string>
<string name="title_tapBelowToAddCashWallet">You don\'t have any cash yet.\nTap below to add cash to your wallet</string>
<string name="title_noBalanceYet">No Balance Yet</string>
<string name="description_noBalanceYet">Buy a currency to get started, or get another Flipcash user to give you some cash</string>
<string name="description_noBalanceYet">Deposit funds to get started</string>
<string name="description_noBalanceYetDiscover">Buy your first currency to get started</string>
<string name="action_dismiss">Dismiss</string>
<string name="title_success">Success</string>
Expand Down Expand Up @@ -489,6 +491,7 @@
<string name="label_solanaUsdc">Solana USDC with</string>
<string name="title_sellToken">Sell %1$s</string>
<string name="title_purchasingToken">Purchasing %1$s</string>
<string name="title_depositingToken">Depositing %1$s</string>
<string name="title_sellingToken">Selling %1$s</string>
<string name="label_sellWarning">Review the above before confirming.\nOnce made, your transaction is irreversible.</string>

Expand All @@ -506,6 +509,7 @@
<string name="label_marketCapYearShort">1Y</string>
<string name="label_marketCapYear">this year</string>

<string name="prompt_title_selectMethod">Select Method</string>
<string name="prompt_title_selectPurchaseMethod">Select Purchase Method</string>
<string name="action_useCashReservesWithBalance">USDF (%1$s)</string>
<string name="action_debitCardWithPrefix">Debit Card with</string>
Expand Down
1 change: 1 addition & 0 deletions apps/flipcash/features/balance/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {

implementation(project(":apps:flipcash:shared:analytics"))
implementation(project(":apps:flipcash:shared:featureflags"))
implementation(project(":apps:flipcash:shared:payments"))
implementation(project(":apps:flipcash:shared:tokens"))
implementation(project(":apps:flipcash:shared:userflags"))
implementation(project(":libs:datetime"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Text
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -97,29 +97,23 @@ private fun BalanceScreenContent(

Text(
modifier = Modifier.fillMaxWidth(0.6f),
text = if (tokenState.discoveryEnabled) {
stringResource(R.string.description_noBalanceYetDiscover)
} else {
stringResource(R.string.description_noBalanceYet)
},
text = stringResource(R.string.description_noBalanceYet),
style = CodeTheme.typography.textSmall,
color = CodeTheme.colors.textSecondary,
textAlign = TextAlign.Center,
)

if (tokenState.discoveryEnabled) {
CodeButton(
onClick = {
dispatchEvent(
BalanceViewModel.Event.OpenScreen(AppRoute.Token.Discovery)
)
},
modifier = Modifier.align(Alignment.CenterHorizontally),
contentPadding = PaddingValues(),
text = stringResource(R.string.action_discoverCurrencies),
shape = CircleShape,
)
}
CodeButton(
onClick = {
dispatchEvent(BalanceViewModel.Event.PresentDepositOptions)
},
modifier = Modifier
.padding(top = CodeTheme.dimens.grid.x2)
.align(Alignment.CenterHorizontally),
contentPadding = PaddingValues(),
text = stringResource(R.string.action_depositFunds),
shape = CircleShape,
)
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.flipcash.app.balance.internal

import androidx.lifecycle.viewModelScope
import com.flipcash.app.core.AppRoute
import com.flipcash.app.payments.PurchaseMethodController
import com.flipcash.app.userflags.UserFlagsCoordinator
import com.flipcash.services.internal.model.thirdparty.OnRampProvider
import com.flipcash.services.user.AuthState
Expand All @@ -23,6 +24,7 @@ internal class BalanceViewModel @Inject constructor(
userManager: UserManager,
userFlags: UserFlagsCoordinator,
dispatchers: DispatcherProvider,
purchaseMethodController: PurchaseMethodController,
) : BaseViewModel<BalanceViewModel.State, BalanceViewModel.Event>(
initialState = State(),
updateStateForEvent = updateStateForEvent,
Expand All @@ -38,6 +40,7 @@ internal class BalanceViewModel @Inject constructor(
data object OpenCurrencySelection : Event

data class OpenScreen(val screen: AppRoute) : Event
data object PresentDepositOptions: Event
}

init {
Expand All @@ -46,9 +49,13 @@ internal class BalanceViewModel @Inject constructor(
.flatMapLatest { userFlags.resolvedFlags }
.mapNotNull { it.preferredOnRampProvider.effectiveValue }
.filterIsInstance<OnRampProvider.Defined>()
.onEach { provider ->
dispatchEvent(Event.OnPreferredOnRampProviderChanged(provider))
}
.onEach { provider -> dispatchEvent(Event.OnPreferredOnRampProviderChanged(provider)) }
.launchIn(viewModelScope)

eventFlow
.filterIsInstance<Event.PresentDepositOptions>()
.mapNotNull { purchaseMethodController.presentDepositOptions(popToRoot = true) }
.onEach { route -> dispatchEvent(Event.OpenScreen(route)) }
.launchIn(viewModelScope)
}

Expand All @@ -59,6 +66,7 @@ internal class BalanceViewModel @Inject constructor(
is Event.OnPreferredOnRampProviderChanged -> { state ->
state.copy(preferredOnRampProvider = event.provider)
}
Event.PresentDepositOptions -> { state -> state }
is Event.OpenScreen -> { state -> state }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.Center
import androidx.compose.ui.Modifier
Expand All @@ -28,8 +29,12 @@ import com.flipcash.app.core.verification.VerificationResult
import com.flipcash.app.core.verification.VerificationStep
import com.flipcash.app.theme.FlipcashPreview
import com.flipcash.features.contact.verification.R
import com.getcode.navigation.core.LocalCodeNavigator
import com.getcode.navigation.flow.LocalOuterCodeNavigator
import com.getcode.navigation.flow.rememberFlowNavigator
import com.getcode.theme.CodeTheme
import com.getcode.ui.components.AppBarDefaults
import com.getcode.ui.components.AppBarWithTitle
import com.getcode.ui.theme.ButtonState
import com.getcode.ui.theme.CodeButton
import com.getcode.ui.theme.CodeScaffold
Expand All @@ -56,10 +61,28 @@ private fun VerificationFlowIntroScreenContent(
isForOnRamp: Boolean,
onClick: () -> Unit,
) {
val navigator = LocalOuterCodeNavigator.current
val isSheetRoot = remember { navigator.backStack.size <= 1 }
CodeScaffold(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.navigationBars),
topBar = {
if (isSheetRoot) {
AppBarWithTitle(
isInModal = true,
endContent = {
AppBarDefaults.Close { navigator.hide() }
},
)
} else {
AppBarWithTitle(
isInModal = true,
backButton = true,
onBackIconClicked = { navigator.pop() },
)
}
},
bottomBar = {
CodeButton(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.flipcash.app.currencycreator.CurrencyCreatorCoordinator
import com.flipcash.app.currencycreator.internal.components.CurrencyCreatorTopBarController
import com.flipcash.app.onramp.DeeplinkError
import com.flipcash.app.onramp.DeeplinkOnRampError
import com.flipcash.app.onramp.PhantomSwapResult
import com.flipcash.app.onramp.PhantomWalletController
import com.flipcash.app.onramp.isAlert
import com.flipcash.app.onramp.isNetworkCause
Expand Down Expand Up @@ -542,7 +543,8 @@ internal class CurrencyCreatorViewModel @Inject constructor(
amount = totalAmount,
fee = feeAmount,
token = token,
).onSuccess { swapId ->
).onSuccess { result ->
val swapId = (result as PhantomSwapResult.WithSwapId).swapId
dispatchEvent(Event.PurchaseSubmitted(swapId, token.address))
}.onFailure { error ->
handlePhantomError(error)
Expand Down
1 change: 1 addition & 0 deletions apps/flipcash/features/direct-send/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation(project(":libs:messaging"))
implementation(project(":libs:permissions:bindings"))
implementation(project(":apps:flipcash:shared:featureflags"))
implementation(project(":apps:flipcash:shared:payments"))
implementation(project(":apps:flipcash:shared:permissions"))
implementation(project(":apps:flipcash:shared:contacts"))
implementation(project(":apps:flipcash:shared:tokens"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.flipcash.app.directsend.internal.screens.ContactListScreen
import com.flipcash.app.directsend.internal.screens.ContactsPermissionGateScreen
import com.flipcash.app.directsend.internal.screens.PhoneGateLandingScreen
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.flowSharedViewModel
Expand Down
Loading
Loading