Skip to content

Commit

Permalink
MOB-432 previous branch was based on a wrong branch (#48)
Browse files Browse the repository at this point in the history
* MOB-432 previous branch was based on a wrong branch

* PR
  • Loading branch information
johnqh authored Apr 1, 2024
1 parent bd5ce3e commit 075f5b6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
20 changes: 20 additions & 0 deletions v4/app/src/main/assets/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import javax.inject.Inject
enum class DydxFeatureFlag {
deployment_url,
force_mainnet,
enable_isolated_market,
}

class DydxFeatureFlags @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
}

Expand Down Expand Up @@ -103,6 +107,7 @@ object DydxTradeInputView : DydxComponent {

data class ViewState(
val localizer: LocalizerProtocol,
val isIsolatedMarketEnabled: Boolean = false,
val inputFields: List<InputField> = listOf(),
val orderbookToggleState: OrderbookToggleState = OrderbookToggleState.Open,
val requestedBottomSheetState: BottomSheetState? = null,
Expand Down Expand Up @@ -148,7 +153,7 @@ object DydxTradeInputView : DydxComponent {

val scope = rememberCoroutineScope()

var sheetState: MutableState<SheetState?> = remember { mutableStateOf(null) }
val sheetState: MutableState<SheetState?> = remember { mutableStateOf(null) }

val screenHeight = LocalConfiguration.current.screenHeightDp.dp
val focusManager = LocalFocusManager.current
Expand All @@ -171,9 +176,13 @@ object DydxTradeInputView : DydxComponent {
DydxTradeSheetTipView.Content(Modifier)
}

DydxTradeInputOrderTypeView.Content(
Modifier,
)
if (state.isIsolatedMarketEnabled) {
DydxTradeInputSideView.Content(Modifier)
} else {
DydxTradeInputOrderTypeView.Content(
Modifier,
)
}

PlatformDivider()

Expand All @@ -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(
Expand Down Expand Up @@ -253,8 +268,10 @@ object DydxTradeInputView : DydxComponent {
when (state.requestedBottomSheetState) {
BottomSheetState.Hidden -> {
}

BottomSheetState.Tip -> {
}

BottomSheetState.Expanded -> {
LaunchedEffect(key1 = "expand") {
bottomSheetState.expand()
Expand Down Expand Up @@ -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())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?>,
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 075f5b6

Please sign in to comment.