Skip to content

Commit

Permalink
inverted coloring for cross margin and position leverage directions
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dydx committed Jun 27, 2024
1 parent 76167c2 commit 4c8bd4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
let crossMarginUsageUpdated: AmountTextModel = .init(amount: input.summary?.crossMarginUsageUpdated, unit: .percentage)
let crossMarginUsageChange: AmountChangeModel = .init(
before: crossMarginUsage.amount != nil ? crossMarginUsage : nil,
after: crossMarginUsageUpdated.amount != nil ? crossMarginUsageUpdated : nil)
after: crossMarginUsageUpdated.amount != nil ? crossMarginUsageUpdated : nil,
increasingIsPositiveDirection: false)
crossReceiptItems.append(
dydxReceiptChangeItemView(
title: DataLocalizer.localize(path: "APP.GENERAL.CROSS_MARGIN_USAGE"),
Expand All @@ -232,7 +233,9 @@ private class dydxAdjustMarginInputViewPresenter: HostedViewPresenter<dydxAdjust
let positionLeverageUpdated: AmountTextModel = .init(amount: input.summary?.positionLeverageUpdated, unit: .multiplier)
let positionLeverageChange: AmountChangeModel = .init(
before: positionLeverage.amount != nil ? positionLeverage : nil,
after: positionLeverageUpdated.amount != nil ? positionLeverageUpdated : nil)
after: positionLeverageUpdated.amount != nil ? positionLeverageUpdated : nil,
increasingIsPositiveDirection: false
)
positionReceiptItems.append(
dydxReceiptChangeItemView(
title: DataLocalizer.localize(path: "APP.TRADE.POSITION_LEVERAGE"),
Expand Down
13 changes: 12 additions & 1 deletion dydx/dydxViews/dydxViews/Shared/AmountChange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ import Utilities

public class AmountChangeModel: BeforeArrowAfterModel<AmountTextModel> {

public convenience init(before: AmountTextModel?, after: AmountTextModel?) {
public convenience init(before: AmountTextModel?, after: AmountTextModel?, increasingIsPositiveDirection: Bool = true) {
self.init()

self.before = before
self.after = after

changeDirection = { [weak self] in
guard let beforeAmount = self?.before?.amount, let afterAmount = self?.after?.amount else {
return .orderedSame
}
if increasingIsPositiveDirection {
return beforeAmount.compare(afterAmount)
} else {
return afterAmount.compare(beforeAmount)
}
}
}

public required init(unit: AmountTextModel.Unit = .dollar) {
Expand Down

0 comments on commit 4c8bd4a

Please sign in to comment.