From 075f5b69676ab735a7625e99d43679fb881fe2a1 Mon Sep 17 00:00:00 2001 From: John Huang Date: Mon, 1 Apr 2024 16:22:48 -0700 Subject: [PATCH] MOB-432 previous branch was based on a wrong branch (#48) * MOB-432 previous branch was based on a wrong branch * PR --- v4/app/src/main/assets/features.json | 20 ++++++++++ .../common/featureflags/DydxFeatureFlags.kt | 1 + .../trade/tradeinput/DydxTradeInputView.kt | 38 ++++++++++++++++--- .../tradeinput/DydxTradeInputViewModel.kt | 4 ++ 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/v4/app/src/main/assets/features.json b/v4/app/src/main/assets/features.json index c0bb042e..29294792 100644 --- a/v4/app/src/main/assets/features.json +++ b/v4/app/src/main/assets/features.json @@ -32,6 +32,26 @@ } ] } + }, + { + "title":{ + "text":"Isolated Market" + }, + "field":{ + "field":"enable_isolated_market", + "optional":true, + "type" : "text", + "options" : [ + { + "text": "yes", + "value" : "1" + }, + { + "text": "no", + "value" : "0" + } + ] + } } ] } diff --git a/v4/common/src/main/java/exchange/dydx/trading/common/featureflags/DydxFeatureFlags.kt b/v4/common/src/main/java/exchange/dydx/trading/common/featureflags/DydxFeatureFlags.kt index 0792916c..c31ae2df 100644 --- a/v4/common/src/main/java/exchange/dydx/trading/common/featureflags/DydxFeatureFlags.kt +++ b/v4/common/src/main/java/exchange/dydx/trading/common/featureflags/DydxFeatureFlags.kt @@ -6,6 +6,7 @@ import javax.inject.Inject enum class DydxFeatureFlag { deployment_url, force_mainnet, + enable_isolated_market, } class DydxFeatureFlags @Inject constructor( diff --git a/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputView.kt b/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputView.kt index e1647c19..bc8c251d 100644 --- a/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputView.kt +++ b/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputView.kt @@ -69,7 +69,11 @@ import exchange.dydx.trading.feature.trade.tradeinput.components.sheettip.DydxTr @Composable fun Preview_DydxTradeInputView() { DydxThemedPreviewSurface { - DydxTradeInputView.Content(Modifier, DydxTradeInputView.ViewState.preview, rememberBottomSheetScaffoldState().bottomSheetState) + DydxTradeInputView.Content( + Modifier, + DydxTradeInputView.ViewState.preview, + rememberBottomSheetScaffoldState().bottomSheetState, + ) } } @@ -103,6 +107,7 @@ object DydxTradeInputView : DydxComponent { data class ViewState( val localizer: LocalizerProtocol, + val isIsolatedMarketEnabled: Boolean = false, val inputFields: List = listOf(), val orderbookToggleState: OrderbookToggleState = OrderbookToggleState.Open, val requestedBottomSheetState: BottomSheetState? = null, @@ -148,7 +153,7 @@ object DydxTradeInputView : DydxComponent { val scope = rememberCoroutineScope() - var sheetState: MutableState = remember { mutableStateOf(null) } + val sheetState: MutableState = remember { mutableStateOf(null) } val screenHeight = LocalConfiguration.current.screenHeightDp.dp val focusManager = LocalFocusManager.current @@ -171,9 +176,13 @@ object DydxTradeInputView : DydxComponent { DydxTradeSheetTipView.Content(Modifier) } - DydxTradeInputOrderTypeView.Content( - Modifier, - ) + if (state.isIsolatedMarketEnabled) { + DydxTradeInputSideView.Content(Modifier) + } else { + DydxTradeInputOrderTypeView.Content( + Modifier, + ) + } PlatformDivider() @@ -194,7 +203,13 @@ object DydxTradeInputView : DydxComponent { DydxOrderbookGroupView.Content(Modifier.padding(start = 12.dp)) } } - DydxTradeInputSideView.Content(Modifier.weight(1f)) + if (state.isIsolatedMarketEnabled) { + DydxTradeInputOrderTypeView.Content( + Modifier.weight(1f), + ) + } else { + DydxTradeInputSideView.Content(Modifier.weight(1f)) + } } Row( @@ -253,8 +268,10 @@ object DydxTradeInputView : DydxComponent { when (state.requestedBottomSheetState) { BottomSheetState.Hidden -> { } + BottomSheetState.Tip -> { } + BottomSheetState.Expanded -> { LaunchedEffect(key1 = "expand") { bottomSheetState.expand() @@ -286,30 +303,39 @@ object DydxTradeInputView : DydxComponent { InputField.Size -> { DydxTradeInputSizeView.Content(Modifier.animateItemPlacement()) } + InputField.Leverage -> { DydxTradeInputLeverageView.Content(Modifier.animateItemPlacement()) } + InputField.LimitPrice -> { DydxTradeInputLimitPriceView.Content(Modifier.animateItemPlacement()) } + InputField.TriggerPrice -> { DydxTradeInputTriggerPriceView.Content(Modifier.animateItemPlacement()) } + InputField.TrailingPercent -> { // DydxTradeInputTriggerPriceView.Content(Modifier) } + InputField.TimeInForce -> { DydxTradeInputTimeInForceView.Content(Modifier.animateItemPlacement()) } + InputField.Execution -> { DydxTradeInputExecutionView.Content(Modifier.animateItemPlacement()) } + InputField.GoodTil -> { DydxTradeInputGoodTilView.Content(Modifier.animateItemPlacement()) } + InputField.PostOnly -> { DydxTradeInputPostOnlyView.Content(Modifier.animateItemPlacement()) } + InputField.ReduceOnly -> { DydxTradeInputReduceOnlyView.Content(Modifier.animateItemPlacement()) } diff --git a/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputViewModel.kt b/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputViewModel.kt index aa098fcd..d349582b 100644 --- a/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputViewModel.kt +++ b/v4/feature/trade/src/main/java/exchange/dydx/trading/feature/trade/tradeinput/DydxTradeInputViewModel.kt @@ -6,6 +6,8 @@ import exchange.dydx.abacus.output.input.TradeInput import exchange.dydx.abacus.protocols.LocalizerProtocol import exchange.dydx.dydxstatemanager.AbacusStateManagerProtocol import exchange.dydx.trading.common.DydxViewModel +import exchange.dydx.trading.common.featureflags.DydxFeatureFlag +import exchange.dydx.trading.common.featureflags.DydxFeatureFlags import exchange.dydx.trading.feature.receipt.ReceiptType import exchange.dydx.trading.feature.receipt.TradeReceiptType import kotlinx.coroutines.flow.Flow @@ -18,6 +20,7 @@ import javax.inject.Inject class DydxTradeInputViewModel @Inject constructor( private val localizer: LocalizerProtocol, private val abacusStateManager: AbacusStateManagerProtocol, + private val featureFlags: DydxFeatureFlags, val receiptTypeFlow: MutableStateFlow<@JvmSuppressWildcards ReceiptType?>, val orderbookToggleStateFlow: Flow<@JvmSuppressWildcards DydxTradeInputView.OrderbookToggleState>, val buttomSheetStateFlow: MutableStateFlow<@JvmSuppressWildcards DydxTradeInputView.BottomSheetState?>, @@ -60,6 +63,7 @@ class DydxTradeInputViewModel @Inject constructor( if (tradeInput?.options?.needsPostOnly == true) DydxTradeInputView.InputField.PostOnly else null, if (tradeInput?.options?.needsReduceOnly == true) DydxTradeInputView.InputField.ReduceOnly else null, ), + isIsolatedMarketEnabled = featureFlags.isFeatureEnabled(DydxFeatureFlag.enable_isolated_market), orderbookToggleState = orderbookToggleState, requestedBottomSheetState = buttomSheetState, onRequestedBottomSheetStateCompleted = {