Skip to content

Commit 2eed9d3

Browse files
committed
feat(flipcash): implement intent submissions for all steps end-to-end
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 72641f2 commit 2eed9d3

File tree

53 files changed

+1151
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1151
-672
lines changed

apps/flipcash/app/src/main/kotlin/com/flipcash/app/internal/ui/HomeViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ internal class HomeViewModel @Inject constructor(
112112
)
113113
}
114114

115+
suspend fun logout(): Result<Unit> {
116+
return authManager.logout()
117+
}
118+
115119
private fun checkBiometrics() {
116120
viewModelScope.launch {
117121
_requireBiometrics.value = !shareSheetController.isCheckingForShare &&
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.flipcash.app.internal.ui.navigation
2+
3+
import android.os.Parcelable
4+
import androidx.compose.runtime.Composable
5+
import androidx.compose.runtime.rememberCoroutineScope
6+
import cafe.adriel.voyager.core.registry.ScreenRegistry
7+
import cafe.adriel.voyager.core.screen.Screen
8+
import com.flipcash.app.core.NavScreenProvider
9+
import com.flipcash.app.internal.ui.HomeViewModel
10+
import com.getcode.navigation.core.LocalCodeNavigator
11+
import com.getcode.navigation.extensions.getActivityScopedViewModel
12+
import com.getcode.ui.components.restrictions.ContentRestrictedView
13+
import com.getcode.ui.core.RestrictionType
14+
import kotlinx.coroutines.launch
15+
import kotlinx.parcelize.Parcelize
16+
17+
@Parcelize
18+
class AppRestrictedScreen(private val restrictionType: RestrictionType): Screen, Parcelable {
19+
@Composable
20+
override fun Content() {
21+
val homeViewModel = getActivityScopedViewModel<HomeViewModel>()
22+
val navigator = LocalCodeNavigator.current
23+
val coroutineScope = rememberCoroutineScope()
24+
ContentRestrictedView(restrictionType) {
25+
coroutineScope.launch {
26+
homeViewModel.logout()
27+
.onSuccess {
28+
navigator.replaceAll(
29+
ScreenRegistry.get(
30+
NavScreenProvider.Login.Home()
31+
)
32+
)
33+
}
34+
}
35+
}
36+
}
37+
}

apps/flipcash/app/src/main/kotlin/com/flipcash/app/internal/ui/navigation/AppScreenContent.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ import com.getcode.navigation.modal.ModalScreen
3939
@Composable
4040
internal fun AppScreenContent(content: @Composable () -> Unit) {
4141
ScreenRegistry {
42+
register<NavScreenProvider.AppRestricted> {
43+
AppRestrictedScreen(it.restrictionType)
44+
}
4245
register<NavScreenProvider.Login.Home> {
4346
LoginRouter(it.seed, it.fromDeeplink)
4447
}

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/pools/Pool.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ data class Pool(
1919
val rendezvousSignature: List<Byte> = emptyList(),
2020
val createdAt: Instant,
2121
val closedAt: Instant?,
22-
val didWin: Boolean,
2322
val derivationIndex: Long,
2423
val betSummary: PoolBetSummary,
24+
val userSummary: PoolUserSummary,
2525
) {
2626
companion object
2727

@@ -88,9 +88,9 @@ val Pool.Companion.Empty: Pool
8888
fundingDestination = PublicKey(emptyList()),
8989
createdAt = Instant.fromEpochMilliseconds(0),
9090
closedAt = null,
91-
didWin = false,
9291
resolution = PoolResolution.NotSet,
9392
isOpen = true,
9493
derivationIndex = -1,
95-
betSummary = PoolBetSummary.Boolean(0, 0),
94+
betSummary = PoolBetSummary.NotSet,
95+
userSummary = PoolUserSummary.NotSet,
9696
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.flipcash.app.core.pools
2+
3+
import com.getcode.opencode.model.financial.Fiat
4+
5+
sealed interface PoolUserSummary {
6+
data object NotSet : PoolUserSummary
7+
data class Won(val amount: Fiat): PoolUserSummary
8+
data class Lost(val amount: Fiat): PoolUserSummary
9+
data class Refunded(val amount: Fiat): PoolUserSummary
10+
}

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/pools/PoolWithBets.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.flipcash.app.core.pools
22

33
import com.getcode.ed25519.Ed25519
4+
import com.getcode.opencode.model.core.ID
45
import com.getcode.opencode.model.financial.Fiat
56

67
data class PoolWithBets(
78
val pool: Pool,
89
val isHost: Boolean,
910
val rendezvousSeed: String?,
10-
val bets: List<PoolBet>
11+
val bets: List<PoolBet>,
12+
val pagingToken: ID? = null,
1113
) {
1214
val totalPoolAmount: Fiat
1315
get() = pool.totalPoolAmount

apps/flipcash/core/src/main/res/values/strings.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,16 @@
184184
<string name="subtitle_poolNamePlaceholder">Question</string>
185185
<string name="subtitle_poolNameHint">Pose a Yes or No Question</string>
186186
<string name="action_createYourPool">Create Your Pool</string>
187-
<string name="error_title_bidLimitReached">Bid Limit Reached</string>
188-
<string name="error_description_bidLimitReached">Bids are capped at %1$s</string>
187+
<string name="error_title_bidLimitReached">Cost Limit Too High</string>
188+
<string name="error_description_bidLimitReached">Your pool’s cost to join is too high. Enter a smaller amount and try again</string>
189189
<string name="error_title_createPoolFailed">Create Pool Failed</string>
190190
<string name="error_description_createPoolFailed">Something went wrong</string>
191191
<string name="subtitle_totalInPool">%1$s in pool so far</string>
192192
<string name="subtitle_poolHostOutcomeDisclaimer">As the pool host, you will decide the outcome of the pool in your sole discretion</string>
193193
<string name="subtitle_poolParticipantOutcomeDisclaimer">The person who created the pool gets to decide the outcome of the pool in their sole discretion</string>
194194
<string name="action_sharePoolWithFriends">Share Pool With Friends</string>
195195
<string name="action_declareOutcome">Declare the Outcome</string>
196+
<string name="action_distributeFunds">Distribute Funds</string>
196197
<string name="subtitle_inPoolSoFar">in pool so far</string>
197198

198199
<string name="error_title_poolNotFound">Something went wrong</string>
@@ -206,7 +207,7 @@
206207
<string name="action_pool_bet_yes">Yes</string>
207208
<string name="action_pool_bet_no">No</string>
208209
<string name="subtitle_poolAlreadyBet">You\'re bought in</string>
209-
<string name="subtitle_poolNotYetBet">Tap to buy in</string>
210+
<string name="subtitle_poolNotYetBet">Tap yes or no to buy in for %1$s</string>
210211

211212
<string name="error_title_paymentFailed">Payment Failed</string>
212213
<string name="error_description_paymentFailed">This payment request could not be paid at this time. Please try again later.</string>

0 commit comments

Comments
 (0)