Skip to content

Commit

Permalink
TRA-849, TRA-872, TRA-871, TRA-857: Vault polishing (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang authored Nov 11, 2024
1 parent c078fa1 commit 91afede
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dydx/dydxFormatter/dydxFormatter/dydxFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public final class dydxFormatter: NSObject, SingletonProtocol {
let postfix = ["", "K", "M", "B", "T"]
var value = number.decimalValue
var index = 0
while value.magnitude > 1000.0 && index < (postfix.count - 1) {
while value.magnitude >= 1000.0 && index < (postfix.count - 1) {
value = value / 1000.0
index += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ private class dydxVaultViewBuilderPresenter: HostedViewPresenter<dydxVaultViewMo
}

// only create new view model instance if it does not already exist
let side: SideTextViewModel.Side
let side: SideTextViewModel.Side?
if positionSize == 0 {
side = .none
side = nil
} else if positionSize > 0 {
side = .long
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class dydxPortfolioChartViewModel: PlatformViewModel {
HStack {
Text(equity)
.themeFont(fontSize: .larger)
.themeColor(foreground: .textPrimary)

Spacer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private struct dydxVaultChartView: View {
.chartXAxis(.hidden)
.chartYAxis {
AxisMarks(values: .automatic) {
let value = dydxFormatter.shared.condensedDollar(number: $0.as(Double.self))
let value = dydxFormatter.shared.condensedDollar(number: $0.as(Double.self), digits: 1)
AxisValueLabel {
if let value {
Text(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class dydxVaultPositionViewModel: PlatformViewModel {
@Published public var displayId: String
@Published public var symbol: String?
@Published public var iconType: PlatformIconViewModel.IconType = .init(url: nil, placeholderText: nil)
@Published public var side: SideTextViewModel.Side
@Published public var side: SideTextViewModel.Side?
@Published public var leverage: Double?
@Published public var equity: Double
@Published public var notionalValue: Double
Expand All @@ -31,8 +31,8 @@ public class dydxVaultPositionViewModel: PlatformViewModel {
@Published public var sparklineValues: [Double]?

fileprivate var sideLeverageAttributedText: AttributedString {
let attributedSideText = AttributedString(text: side.text, urlString: nil)
.themeColor(foreground: side.color)
let attributedSideText = AttributedString(text: side?.text ?? "-", urlString: nil)
.themeColor(foreground: side?.color ?? ThemeColor.SemanticColor.textTertiary)
if let leverage = leverage {
let leverageText = dydxFormatter.shared.leverage(number: leverage) ?? "--"
let attributedLeverageText = AttributedString(text: " @ " + leverageText, urlString: nil)
Expand All @@ -46,8 +46,8 @@ public class dydxVaultPositionViewModel: PlatformViewModel {
}

fileprivate var notionalValueText: String {
let size = dydxFormatter.shared.condensedDollar(number: notionalValue, digits: 0) ?? "--"
let equity = dydxFormatter.shared.condensedDollar(number: equity, digits: 0) ?? "--"
let size = dydxFormatter.shared.condensedDollar(number: notionalValue, digits: 2) ?? "--"
let equity = dydxFormatter.shared.condensedDollar(number: equity, digits: 2) ?? "--"
return "\(size) / \(equity)"
}

Expand Down Expand Up @@ -76,7 +76,7 @@ public class dydxVaultPositionViewModel: PlatformViewModel {
displayId: String,
symbol: String?,
iconType: PlatformIconViewModel.IconType,
side: SideTextViewModel.Side,
side: SideTextViewModel.Side?,
leverage: Double?,
equity: Double,
notionalValue: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private struct dydxVaultView: View {
Spacer(minLength: 4)
Text(dydxFormatter.shared.dollar(number: viewModel.vaultBalance) ?? "--")
.themeColor(foreground: .textPrimary)
.themeFont(fontType: .base, fontSize: .large)
.themeFont(fontType: .base, fontSize: .larger)
}
.leftAligned()
.padding(.horizontal, 16)
Expand All @@ -171,7 +171,7 @@ private struct dydxVaultView: View {
Spacer(minLength: 4)
Text(dydxFormatter.shared.dollar(number: viewModel.allTimeReturnUsdc) ?? "--")
.themeColor(foreground: viewModel.allTimeReturnUsdc == nil ? .textPrimary : ThemeSettings.directionalColor(forValue: viewModel.allTimeReturnUsdc))
.themeFont(fontType: .base, fontSize: .large)
.themeFont(fontType: .base, fontSize: .larger)
}
.leftAligned()
.padding(.horizontal, 16)
Expand All @@ -196,7 +196,7 @@ private struct dydxVaultView: View {
.themeFont(fontType: .base, fontSize: .small)
Text(dydxFormatter.shared.percent(number: viewModel.thirtyDayReturnPercent, digits: 0) ?? "")
.themeColor(foreground: ThemeSettings.directionalColor(forValue: viewModel.thirtyDayReturnPercent))
.themeFont(fontType: .base, fontSize: .large)
.themeFont(fontType: .base, fontSize: .larger)
}
}

Expand All @@ -207,7 +207,7 @@ private struct dydxVaultView: View {
.themeFont(fontType: .base, fontSize: .small)
Text(dydxFormatter.shared.dollar(number: viewModel.totalValueLocked, digits: 0) ?? "")
.themeColor(foreground: .textPrimary)
.themeFont(fontType: .base, fontSize: .large)
.themeFont(fontType: .base, fontSize: .larger)
}
}

Expand Down

0 comments on commit 91afede

Please sign in to comment.