Skip to content

Commit f431d2f

Browse files
committed
chore: consolidate currency creator FeatureFlags; bring back BillCustomizer when CurrencyCreator disabled
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent edca7bd commit f431d2f

13 files changed

Lines changed: 321 additions & 265 deletions

File tree

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

Lines changed: 173 additions & 170 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
<string name="title_noTransactionHistory">No Activity</string>
364364
<string name="description_noTransactionHistory">Your recent activity will appear here when you send or receive money</string>
365365

366+
<string name="title_billCustomizer">Bill Creator</string>
366367
<string name="title_createYourCurrency">Create Your Currency</string>
367368
<string name="subtitle_currencyCreatorInfo">Launch your own currency in %1$d easy steps</string>
368369
<string name="title_currencyCreatorStepName">Name</string>

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ 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.Event
14+
import com.flipcash.app.bill.customization.LocalBillPlaygroundController
1315
import com.flipcash.core.R
1416
import com.getcode.navigation.core.LocalCodeNavigator
17+
import com.getcode.opencode.model.financial.Token
18+
import com.getcode.opencode.model.financial.usdf
1519
import com.getcode.ui.components.AppBarWithTitle
1620
import kotlinx.coroutines.flow.filterIsInstance
1721
import kotlinx.coroutines.flow.launchIn
@@ -20,6 +24,7 @@ import kotlinx.coroutines.flow.onEach
2024
@Composable
2125
fun AdvancedFeaturesScreen() {
2226
val navigator = LocalCodeNavigator.current
27+
val billPlayground = LocalBillPlaygroundController.current
2328
val viewModel = hiltViewModel<AdvancedFeaturesScreenViewModel>()
2429

2530
Column(
@@ -43,4 +48,14 @@ fun AdvancedFeaturesScreen() {
4348
.onEach { navigator.push(it.screen) }
4449
.launchIn(this)
4550
}
51+
52+
LaunchedEffect(viewModel) {
53+
viewModel.eventFlow
54+
.filterIsInstance<AdvancedFeaturesScreenViewModel.Event.OpenBillPlayground>()
55+
.onEach {
56+
navigator.hide()
57+
billPlayground.dispatchEvent(Event.Load())
58+
}
59+
.launchIn(this)
60+
}
4661
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.flipcash.app.advanced.internal
33
import androidx.compose.material.icons.Icons
44
import androidx.compose.material.icons.filled.AddCircle
55
import androidx.compose.material.icons.outlined.Description
6+
import androidx.compose.material.icons.outlined.Palette
67
import androidx.compose.runtime.Composable
78
import androidx.compose.ui.graphics.painter.Painter
89
import androidx.compose.ui.graphics.vector.rememberVectorPainter
@@ -23,6 +24,14 @@ internal data object CurrencyCreator : FullMenuItem<AdvancedFeaturesScreenViewMo
2324
)
2425
}
2526

27+
internal data object BillCustomizer : FullMenuItem<AdvancedFeaturesScreenViewModel.Event>() {
28+
override val icon: Painter
29+
@Composable get() = rememberVectorPainter(Icons.Outlined.Palette)
30+
override val name: String
31+
@Composable get() = stringResource(R.string.title_billCustomizer)
32+
override val action: AdvancedFeaturesScreenViewModel.Event = AdvancedFeaturesScreenViewModel.Event.OpenBillPlayground
33+
}
34+
2635
internal data object Deposit : FullMenuItem<AdvancedFeaturesScreenViewModel.Event>() {
2736
override val icon: Painter
2837
@Composable get() = painterResource(R.drawable.ic_menu_deposit)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import javax.inject.Inject
1717

1818
private val FullMenuList = buildList {
1919
add(CurrencyCreator)
20+
add(BillCustomizer)
2021
add(Deposit)
2122
add(DeviceLogs)
2223
}
@@ -40,10 +41,11 @@ internal class AdvancedFeaturesScreenViewModel @Inject constructor(
4041
data class OnBetaFeaturesUnlocked(val unlocked: Boolean) : Event
4142
data class OnCurrencyCreatorEnabled(val enabled: Boolean) : Event
4243
data class OpenScreen(val screen: AppRoute) : Event
44+
data object OpenBillPlayground : Event
4345
}
4446

4547
init {
46-
featureFlagController.observe(FeatureFlag.BillCustomizer)
48+
featureFlagController.observe(FeatureFlag.CurrencyCreator)
4749
.onEach {
4850
dispatchEvent(Event.OnCurrencyCreatorEnabled(it))
4951
}.launchIn(viewModelScope)
@@ -70,14 +72,15 @@ internal class AdvancedFeaturesScreenViewModel @Inject constructor(
7072
is Event.OnCurrencyCreatorEnabled -> { state ->
7173
state.copy(
7274
items = if (event.enabled) {
73-
FullMenuList
75+
FullMenuList.filterNot { it is BillCustomizer }
7476
} else {
7577
FullMenuList.filterNot { it is CurrencyCreator }
7678
}
7779
)
7880
}
7981

8082
is Event.OpenScreen -> { state -> state }
83+
is Event.OpenBillPlayground -> { state -> state }
8184
}
8285
}
8386
}

apps/flipcash/features/bill-customization/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies {
1313

1414
implementation(project(":apps:flipcash:shared:bills"))
1515
api(project(":apps:flipcash:shared:bill-customization"))
16+
implementation(project(":apps:flipcash:shared:featureflags"))
1617
implementation(project(":apps:flipcash:shared:tokens"))
1718
implementation(project(":libs:datetime"))
1819
implementation(project(":libs:messaging"))

apps/flipcash/features/bill-customization/src/main/kotlin/com/flipcash/app/bill/customization/BillCustomizationScaffold.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
4141
import com.flipcash.app.bill.customization.components.BillPlayground
4242
import com.flipcash.app.bills.AnimatedBill
4343
import com.flipcash.app.core.bill.Bill
44+
import com.flipcash.app.featureflags.FeatureFlag
45+
import com.flipcash.app.featureflags.LocalFeatureFlags
4446
import com.flipcash.features.bill.playground.R
4547
import com.getcode.theme.CodeTheme
4648
import com.getcode.ui.components.AppBarDefaults
@@ -52,9 +54,21 @@ import com.getcode.ui.utils.AnimationUtils
5254
@Composable
5355
fun BillPlaygroundScaffold(content: @Composable () -> Unit) {
5456
val controller = LocalBillPlaygroundController.current
55-
57+
val featureFlags = LocalFeatureFlags.current
5658
val playgroundState by controller.state.collectAsStateWithLifecycle()
5759

60+
val currencyCreatorEnabled by featureFlags.observe(FeatureFlag.CurrencyCreator)
61+
.collectAsStateWithLifecycle()
62+
63+
val isUsingPlayground by remember(
64+
playgroundState.isCustomizing,
65+
currencyCreatorEnabled
66+
) {
67+
derivedStateOf {
68+
playgroundState.isCustomizing && !currencyCreatorEnabled
69+
}
70+
}
71+
5872
// bill dismiss state, restarted for every bill
5973
val billDismissState = remember(playgroundState.bill) {
6074
DismissState(
@@ -67,6 +81,7 @@ fun BillPlaygroundScaffold(content: @Composable () -> Unit) {
6781

6882
val augmentedBill by remember(playgroundState.bill, customizationsOptions) {
6983
derivedStateOf {
84+
if (currencyCreatorEnabled) return@derivedStateOf null
7085
val bill = playgroundState.bill ?: return@derivedStateOf null
7186
if (bill !is Bill.Cash) return@derivedStateOf null
7287
bill.copy(
@@ -85,7 +100,7 @@ fun BillPlaygroundScaffold(content: @Composable () -> Unit) {
85100
mutableStateOf(0.dp)
86101
}
87102

88-
BackHandler(playgroundState.isCustomizing) {
103+
BackHandler(isUsingPlayground) {
89104
controller.cancel()
90105
}
91106

@@ -94,7 +109,7 @@ fun BillPlaygroundScaffold(content: @Composable () -> Unit) {
94109
AnimatedBill(
95110
modifier = Modifier.fillMaxSize(),
96111
dismissState = billDismissState,
97-
dismissed = !playgroundState.isCustomizing,
112+
dismissed = !isUsingPlayground,
98113
contentPadding = PaddingValues(
99114
top = topBarHeight,
100115
bottom = playgroundHeight,
@@ -111,7 +126,7 @@ fun BillPlaygroundScaffold(content: @Composable () -> Unit) {
111126
modifier = Modifier
112127
.fillMaxWidth()
113128
.measured { topBarHeight = it.height },
114-
visible = playgroundState.isCustomizing,
129+
visible = isUsingPlayground,
115130
enter = fadeIn(),
116131
exit = fadeOut(),
117132
) {
@@ -131,7 +146,7 @@ fun BillPlaygroundScaffold(content: @Composable () -> Unit) {
131146
.fillMaxWidth()
132147
.align(Alignment.BottomCenter)
133148
.measured { playgroundHeight = it.height },
134-
visible = playgroundState.isCustomizing,
149+
visible = isUsingPlayground,
135150
enter = slideInVertically { it },
136151
exit = slideOutVertically { it },
137152
label = "bill customization",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal class TokenDiscoveryViewModel @Inject constructor(
5656
}
5757

5858
init {
59-
featureFlags.observe(FeatureFlag.TokenCreate)
59+
featureFlags.observe(FeatureFlag.CurrencyCreator)
6060
.onEach { dispatchEvent(Event.OnCreateAllowed(it)) }
6161
.launchIn(viewModelScope)
6262

apps/flipcash/features/scanner/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dependencies {
1414
implementation(project(":apps:flipcash:shared:appupdates"))
1515
implementation(project(":apps:flipcash:shared:bills"))
1616
implementation(project(":apps:flipcash:shared:bill-customization"))
17+
implementation(project(":apps:flipcash:shared:featureflags"))
1718
implementation(project(":apps:flipcash:shared:router"))
1819
implementation(project(":apps:flipcash:shared:session"))
1920

0 commit comments

Comments
 (0)