Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix value formatting and UI layout bug #165

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PlatformUI/PlatformUI/Components/TabGroup/TabGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private struct TabGroupView<ItemContent: PlatformViewModeling>: View {
}
}
}
.fixedSize(horizontal: false, vertical: true)
.animation(selectionAnimation, value: model.currentSelection)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class TabItemViewModel: PlatformViewModel, Equatable {
switch value {
case .text(let value, let edgeInsets):
return Text(value)
.frame(maxHeight: .infinity)
.themeFont(fontSize: .small)
.padding(edgeInsets)
.themeStyle(styleKey: styleKey, parentStyle: style)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class dydxMarketPositionViewPresenter: HostedViewPresenter<dydxMarketPositionVie
viewModel?.logoUrl = sharedOrderViewModel.logoUrl
viewModel?.gradientType = sharedOrderViewModel.gradientType

viewModel?.amount = dydxFormatter.shared.dollar(number: position.valueTotal?.current?.doubleValue, digits: configs.displayTickSizeDecimals?.intValue ?? 0)
viewModel?.amount = dydxFormatter.shared.dollar(number: position.valueTotal?.current?.doubleValue, digits: 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is USDC value so should be 2


viewModel?.openPrice = dydxFormatter.shared.dollar(number: position.entryPrice?.current?.doubleValue, digits: configs.displayTickSizeDecimals?.intValue ?? 0)
viewModel?.closePrice = dydxFormatter.shared.dollar(number: position.exitPrice?.doubleValue, digits: configs.displayTickSizeDecimals?.intValue ?? 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,17 @@ class dydxMarketStatsViewPresenter: HostedViewPresenter<dydxMarketStatsViewModel
.CombineLatest(marketPublisher,
AbacusStateManager.shared.state.assetMap)
.sink { [weak self] market, assetMap in
let stepSize = market.configs?.displayStepSize?.doubleValue
let tickSize = market.configs?.displayTickSize?.doubleValue
self?.updateStats(market: market, asset: assetMap[market.assetId], stepSize: stepSize, tickSize: tickSize)
let tickSizeNumDecimals = market.configs?.displayTickSizeDecimals?.intValue ?? 0
let stepSizeNumDecimals = market.configs?.displayStepSizeDecimals?.intValue ?? 0
self?.updateStats(market: market, asset: assetMap[market.assetId], stepSizeNumDecimals: stepSizeNumDecimals, tickSizeNumDecimals: tickSizeNumDecimals)
}
.store(in: &subscriptions)
}

private func updateStats(market: PerpetualMarket, asset: Asset?, stepSize: Double? = nil, tickSize: Double? = nil) {
private func updateStats(market: PerpetualMarket, asset: Asset?, stepSizeNumDecimals: Int, tickSizeNumDecimals: Int) {
var items = [dydxMarketStatsViewModel.StatItem]()

let stepSize = String(value: stepSize)
let tickSize = String(value: tickSize)

let oraclePrice = dydxFormatter.shared.dollar(number: market.oraclePrice?.doubleValue, size: tickSize) ?? "-"
let oraclePrice = dydxFormatter.shared.dollar(number: market.oraclePrice?.doubleValue, digits: tickSizeNumDecimals) ?? "-"
items += [
.init(header: DataLocalizer.localize(path: "APP.TRADE.ORACLE_PRICE"),
value: SignedAmountViewModel(text: oraclePrice, sign: .none, coloringOption: .allText))
Expand Down Expand Up @@ -105,7 +102,7 @@ class dydxMarketStatsViewPresenter: HostedViewPresenter<dydxMarketStatsViewModel
value: nextFundingViewModel)
]

let openInterest = dydxFormatter.shared.localFormatted(number: market.perpetual?.openInterest, size: stepSize) ?? "-"
let openInterest = dydxFormatter.shared.localFormatted(number: market.perpetual?.openInterest, digits: stepSizeNumDecimals) ?? "-"
let token: TokenTextViewModel?
if let symbol = asset?.id {
token = TokenTextViewModel(symbol: symbol)
Expand Down
Loading