Skip to content

Commit

Permalink
MOB-605: Position card updates + various visual fixes. (#187)
Browse files Browse the repository at this point in the history
position card preview screenshot taken before i changed default theme
  • Loading branch information
prashanDYDX authored Jul 2, 2024
1 parent 1a234be commit 5aaab71
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 66 deletions.
2 changes: 1 addition & 1 deletion v4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ext {
compileSdkVersion = 34

// App dependencies
abacusVersion = '1.8.14'
abacusVersion = '1.8.19'
carteraVersion = '0.1.15'
kollectionsVersion = '2.0.16'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ object DydxPortfolioPositionItemView {
ComposeAssetPosition(
position,
)
Spacer(modifier = Modifier.weight(1f))
}
Spacer(modifier = Modifier.height(8.dp))

Expand Down Expand Up @@ -169,11 +170,9 @@ object DydxPortfolioPositionItemView {
fontType = ThemeFont.FontType.plus,
),
)
}

Row(
verticalAlignment = Alignment.CenterVertically,
) {
Spacer(modifier = Modifier.weight(1f))

SideTextView.Content(
modifier = Modifier,
state = position.side?.copy(
Expand All @@ -199,6 +198,13 @@ object DydxPortfolioPositionItemView {
.themeColor(ThemeColor.SemanticColor.text_primary),
)
}

Text(
text = position.notionalTotal ?: "-",
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
)
}
}

Expand All @@ -212,20 +218,20 @@ object DydxPortfolioPositionItemView {
horizontalAlignment = Alignment.Start,
) {
Text(
text = localizer.localize("APP.GENERAL.INDEX_ENTRY"),
text = localizer.localize("APP.GENERAL.LIQ_ORACLE"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
)
Text(
text = position.oraclePrice ?: "",
text = position.liquidationPrice ?: localizer.localize("APP.GENERAL.NONE"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_primary),
)

Text(
text = position.entryPrice ?: "",
text = position.oraclePrice ?: "",
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.mini)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
Expand Down Expand Up @@ -286,11 +292,7 @@ object DydxPortfolioPositionItemView {
)

Text(
/*
TODO: Still need to verify what the margin means here
text = position.margin ?: "",
*/
text = position.margin ?: "",
text = position.margin ?: "-",
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_primary),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
package exchange.dydx.trading.feature.portfolio.components.positions

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import exchange.dydx.abacus.protocols.LocalizerProtocol
import exchange.dydx.platformui.components.dividers.PlatformDivider
import exchange.dydx.platformui.compose.collectAsStateWithLifecycle
import exchange.dydx.platformui.designSystem.theme.ThemeColor
import exchange.dydx.platformui.designSystem.theme.ThemeFont
import exchange.dydx.platformui.designSystem.theme.ThemeShapes
import exchange.dydx.platformui.designSystem.theme.dydxDefault
import exchange.dydx.platformui.designSystem.theme.themeColor
import exchange.dydx.platformui.designSystem.theme.themeFont
import exchange.dydx.platformui.theme.DydxThemedPreviewSurface
import exchange.dydx.platformui.theme.MockLocalizer
import exchange.dydx.trading.common.component.DydxComponent
Expand Down Expand Up @@ -132,42 +124,4 @@ object DydxPortfolioPositionsView : DydxComponent {
}
}
}

@Composable
private fun CreateHeader(modifier: Modifier, state: ViewState) {
Row(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = ThemeShapes.HorizontalPadding * 2),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = state.localizer.localize("APP.GENERAL.DETAILS"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
)

Spacer(modifier = Modifier.weight(1f))

Text(
text = state.localizer.localize("APP.GENERAL.INDEX_ENTRY"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
)

Row(
modifier = Modifier.width(80.dp),
) {
Spacer(modifier = Modifier.weight(1f))
Text(
text = state.localizer.localize("APP.GENERAL.PROFIT_AND_LOSS"),
style = TextStyle.dydxDefault
.themeFont(fontSize = ThemeFont.FontSize.small)
.themeColor(ThemeColor.SemanticColor.text_tertiary),
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import javax.inject.Inject

private val settingsFile = "settings_theme.json"
private val defaultTheme = "dark"
private val defaultTheme = "classic_dark"

@HiltViewModel
class DydxThemeViewModel @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import exchange.dydx.platformui.components.textgroups.PlatformAutoSizingText
import exchange.dydx.platformui.designSystem.theme.ThemeColor
import exchange.dydx.platformui.designSystem.theme.color
import exchange.dydx.platformui.designSystem.theme.dydxDefault
Expand Down Expand Up @@ -54,9 +54,9 @@ object TokenTextView {
.padding(horizontal = 4.dp)
.padding(vertical = 2.dp),
) {
Text(
PlatformAutoSizingText(
text = state.symbol,
style = textStyle,
textStyle = textStyle,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ data class SharedAccountViewState(
return SharedAccountViewState(
freeCollateral = formatter.dollar(
number = subaccount.freeCollateral?.current,
size = null,
digits = 2,
),
buyingPower = formatter.dollar(
number = subaccount.buyingPower?.current?.filter(
NumericFilter.NotNegative,
),
size = null,
digits = 2,
),
marginUsage = formatter.percent(
number = subaccount.marginUsage?.current,
digits = 2,
),
leverage = formatter.leverage(number = subaccount.leverage?.current),
equity = formatter.dollar(number = subaccount.equity?.current, size = null),
equity = formatter.dollar(number = subaccount.equity?.current, digits = 2),
openInterest = formatter.dollarVolume(
number = subaccount.notionalTotal?.current,
digits = 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ data class SharedMarketPositionViewState(
val liquidationPrice: String? = null,
val side: SideTextView.ViewState? = null,
val size: String? = null,
val notionalTotal: String? = null,
val margin: String? = null,
val token: TokenTextView.ViewState? = null,
val logoUrl: String? = null,
Expand Down Expand Up @@ -68,6 +69,7 @@ data class SharedMarketPositionViewState(
): SharedMarketPositionViewState? {
val configs = market.configs ?: return null
val positionSize = position.size.current ?: 0.0
val notionalTotal = position.notionalTotal.current ?: 0.0
if (positionSize == 0.0) return null

val unrealizedPnlPercent = position.unrealizedPnlPercent.current ?: 0.0
Expand Down Expand Up @@ -109,6 +111,7 @@ data class SharedMarketPositionViewState(
positionSize.absoluteValue,
configs.displayStepSizeDecimals ?: 1,
),
notionalTotal = formatter.dollar(notionalTotal, 2),
token = TokenTextView.ViewState(
symbol = asset?.id ?: market.assetId,
),
Expand Down

0 comments on commit 5aaab71

Please sign in to comment.