Skip to content

Commit 2dab06c

Browse files
committed
feat(discovery): wire Create Currency button to currency creator flow
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 6333081 commit 2dab06c

6 files changed

Lines changed: 22 additions & 35 deletions

File tree

apps/flipcash/features/advanced/src/main/kotlin/com/flipcash/app/advanced/AdvancedFeaturesScreen.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ import androidx.compose.ui.res.stringResource
1010
import androidx.hilt.navigation.compose.hiltViewModel
1111
import com.flipcash.app.advanced.internal.AdvancedFeaturesScreen
1212
import com.flipcash.app.advanced.internal.AdvancedFeaturesScreenViewModel
13-
import com.flipcash.app.bill.customization.LocalBillPlaygroundController
1413
import com.flipcash.core.R
1514
import com.getcode.navigation.core.LocalCodeNavigator
16-
import com.getcode.opencode.model.financial.Token
17-
import com.getcode.opencode.model.financial.usdf
1815
import com.getcode.ui.components.AppBarWithTitle
1916
import kotlinx.coroutines.flow.filterIsInstance
2017
import kotlinx.coroutines.flow.launchIn
@@ -23,7 +20,6 @@ import kotlinx.coroutines.flow.onEach
2320
@Composable
2421
fun AdvancedFeaturesScreen() {
2522
val navigator = LocalCodeNavigator.current
26-
val billPlayground = LocalBillPlaygroundController.current
2723
val viewModel = hiltViewModel<AdvancedFeaturesScreenViewModel>()
2824

2925
Column(
@@ -47,14 +43,4 @@ fun AdvancedFeaturesScreen() {
4743
.onEach { navigator.push(it.screen) }
4844
.launchIn(this)
4945
}
50-
51-
LaunchedEffect(viewModel) {
52-
viewModel.eventFlow
53-
.filterIsInstance<AdvancedFeaturesScreenViewModel.Event.OpenBillPlayground>()
54-
.onEach {
55-
navigator.hide()
56-
billPlayground.customizeFor(Token.usdf)
57-
}
58-
.launchIn(this)
59-
}
6046
}

apps/flipcash/features/advanced/src/main/kotlin/com/flipcash/app/advanced/internal/AdvancedFeatureMenuItems.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.flipcash.app.advanced.internal
22

33
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.filled.AddCircle
45
import androidx.compose.material.icons.outlined.Description
5-
import androidx.compose.material.icons.outlined.Palette
66
import androidx.compose.runtime.Composable
77
import androidx.compose.ui.graphics.painter.Painter
88
import androidx.compose.ui.graphics.vector.rememberVectorPainter
@@ -13,12 +13,14 @@ import com.flipcash.app.core.tokens.TokenPurpose
1313
import com.flipcash.app.menu.FullMenuItem
1414
import com.flipcash.features.advanced.R
1515

16-
internal data object BillCustomizer : FullMenuItem<AdvancedFeaturesScreenViewModel.Event>() {
16+
internal data object CurrencyCreator : FullMenuItem<AdvancedFeaturesScreenViewModel.Event>() {
1717
override val icon: Painter
18-
@Composable get() = rememberVectorPainter(Icons.Outlined.Palette)
18+
@Composable get() = rememberVectorPainter(Icons.Default.AddCircle)
1919
override val name: String
20-
@Composable get() = stringResource(R.string.title_billCustomizer)
21-
override val action: AdvancedFeaturesScreenViewModel.Event = AdvancedFeaturesScreenViewModel.Event.OpenBillPlayground
20+
@Composable get() = stringResource(R.string.title_createYourCurrency)
21+
override val action: AdvancedFeaturesScreenViewModel.Event = AdvancedFeaturesScreenViewModel.Event.OpenScreen(
22+
AppRoute.Token.CurrencyCreator
23+
)
2224
}
2325

2426
internal data object Deposit : FullMenuItem<AdvancedFeaturesScreenViewModel.Event>() {

apps/flipcash/features/advanced/src/main/kotlin/com/flipcash/app/advanced/internal/AdvancedFeaturesScreenViewModel.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import com.flipcash.app.featureflags.FeatureFlag
66
import com.flipcash.app.featureflags.FeatureFlagController
77
import com.flipcash.app.menu.MenuItem
88
import com.flipcash.app.userflags.UserFlagsCoordinator
9-
import com.flipcash.services.user.UserManager
10-
import com.getcode.util.resources.ResourceHelper
119
import com.flipcash.libs.coroutines.DispatcherProvider
1210
import com.getcode.view.BaseViewModel2
1311
import dagger.hilt.android.lifecycle.HiltViewModel
@@ -18,14 +16,13 @@ import kotlinx.coroutines.flow.onEach
1816
import javax.inject.Inject
1917

2018
private val FullMenuList = buildList {
21-
add(BillCustomizer)
19+
add(CurrencyCreator)
2220
add(Deposit)
2321
add(DeviceLogs)
2422
}
2523

2624
@HiltViewModel
2725
internal class AdvancedFeaturesScreenViewModel @Inject constructor(
28-
userManager: UserManager,
2926
featureFlagController: FeatureFlagController,
3027
userFlags: UserFlagsCoordinator,
3128
dispatchers: DispatcherProvider,
@@ -41,16 +38,14 @@ internal class AdvancedFeaturesScreenViewModel @Inject constructor(
4138

4239
sealed interface Event {
4340
data class OnBetaFeaturesUnlocked(val unlocked: Boolean) : Event
44-
data class OnBillCustomizerEnabled(val enabled: Boolean) : Event
41+
data class OnCurrencyCreatorEnabled(val enabled: Boolean) : Event
4542
data class OpenScreen(val screen: AppRoute) : Event
46-
47-
data object OpenBillPlayground: Event
4843
}
4944

5045
init {
5146
featureFlagController.observe(FeatureFlag.BillCustomizer)
5247
.onEach {
53-
dispatchEvent(Event.OnBillCustomizerEnabled(it))
48+
dispatchEvent(Event.OnCurrencyCreatorEnabled(it))
5449
}.launchIn(viewModelScope)
5550

5651
combine(
@@ -72,18 +67,17 @@ internal class AdvancedFeaturesScreenViewModel @Inject constructor(
7267
)
7368
}
7469

75-
is Event.OnBillCustomizerEnabled -> { state ->
70+
is Event.OnCurrencyCreatorEnabled -> { state ->
7671
state.copy(
7772
items = if (event.enabled) {
7873
FullMenuList
7974
} else {
80-
FullMenuList.filterNot { it is BillCustomizer }
75+
FullMenuList.filterNot { it is CurrencyCreator }
8176
}
8277
)
8378
}
8479

8580
is Event.OpenScreen -> { state -> state }
86-
is Event.OpenBillPlayground -> { state -> state }
8781
}
8882
}
8983
}

apps/flipcash/features/discovery/src/main/kotlin/com/flipcash/app/discovery/TokenDiscoveryScreen.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,11 @@ fun TokenDiscoveryScreen() {
5252
.onEach { navigator.navigate(AppRoute.Token.Info(it)) }
5353
.launchIn(this)
5454
}
55+
56+
LaunchedEffect(viewModel) {
57+
viewModel.eventFlow
58+
.filterIsInstance<TokenDiscoveryViewModel.Event.CreateCurrency>()
59+
.onEach { navigator.navigate(AppRoute.Token.CurrencyCreator) }
60+
.launchIn(this)
61+
}
5562
}

apps/flipcash/features/discovery/src/main/kotlin/com/flipcash/app/discovery/internal/TokenDiscoveryScreenContent.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ private fun TokenDiscoveryScreenContent(
8484
)
8585
},
8686
bottomBar = {
87-
val resources = LocalResources.current
8887
if (state.createEnabled) {
8988
Box {
9089
var buttonHeight by remember { mutableStateOf(0.dp) }
@@ -110,10 +109,7 @@ private fun TokenDiscoveryScreenContent(
110109
),
111110
text = stringResource(R.string.action_createYourOwnCurrency),
112111
) {
113-
BottomBarManager.showInfo(
114-
title = resources.getString(R.string.prompt_title_notYetAvailable),
115-
message = resources.getString(R.string.prompt_message_currencyCreateNotYetAvailable),
116-
)
112+
dispatch(TokenDiscoveryViewModel.Event.CreateCurrency)
117113
}
118114
}
119115
}

apps/flipcash/features/discovery/src/main/kotlin/com/flipcash/app/discovery/internal/TokenDiscoveryViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ internal class TokenDiscoveryViewModel @Inject constructor(
5252
data class LoadTokensForCategory(val category: DiscoverCategory) : Event
5353
data object Refresh : Event
5454
data class OpenTokenInfo(val mint: Mint) : Event
55+
data object CreateCurrency: Event
5556
}
5657

5758
init {
@@ -120,6 +121,7 @@ internal class TokenDiscoveryViewModel @Inject constructor(
120121
is Event.LoadTokensForCategory -> { state -> state }
121122
is Event.OpenTokenInfo -> { state -> state }
122123
is Event.Refresh -> { state -> state }
124+
is Event.CreateCurrency -> { state -> state }
123125
}
124126
}
125127
}

0 commit comments

Comments
 (0)