diff --git a/PlatformUI/PlatformUI/Components/Labels/SignedAmount.swift b/PlatformUI/PlatformUI/Components/Labels/SignedAmount.swift index 91424df6d..4010e0ed5 100644 --- a/PlatformUI/PlatformUI/Components/Labels/SignedAmount.swift +++ b/PlatformUI/PlatformUI/Components/Labels/SignedAmount.swift @@ -7,7 +7,6 @@ // import SwiftUI -import dydxFormatter public class SignedAmountViewModel: PlatformViewModel, Hashable { public enum ColoringOption { @@ -35,35 +34,6 @@ public class SignedAmountViewModel: PlatformViewModel, Hashable { self.negativeTextStyleKey = negativeTextStyleKey } - public convenience init(amount: Double?, displayType: DisplayType, coloringOption: ColoringOption, positiveTextStyleKey: String, negativeTextStyleKey: String, shouldDisplaySignForPositiveNumbers: Bool = false) { - let formattedZero: String - let formattedText: String - let sign: PlatformUISign - switch displayType { - case .dollar: - formattedText = dydxFormatter.shared.dollarVolume(number: amount, shouldDisplaySignForPositiveNumbers: shouldDisplaySignForPositiveNumbers) ?? "" - formattedZero = dydxFormatter.shared.dollarVolume(number: 0.0, shouldDisplaySignForPositiveNumbers: shouldDisplaySignForPositiveNumbers) ?? "" - case .percent: - let digits = 2 - formattedText = dydxFormatter.shared.percent(number: amount, digits: digits, shouldDisplayPlusSignForPositiveNumbers: shouldDisplaySignForPositiveNumbers) ?? "" - formattedZero = dydxFormatter.shared.percent(number: 0.0, digits: digits, shouldDisplayPlusSignForPositiveNumbers: shouldDisplaySignForPositiveNumbers) ?? "" - } - // special logic for when a value like -0.001 would render as "-$0.00" instead of "$0.00" - if formattedText == formattedZero { - sign = .none - } else if (amount ?? 0) > 0 { - sign = .plus - } else { - sign = .minus - } - self.init(text: formattedText, - sign: sign, - coloringOption: coloringOption, - positiveTextStyleKey: positiveTextStyleKey, - negativeTextStyleKey: negativeTextStyleKey) - } - - public static func == (lhs: SignedAmountViewModel, rhs: SignedAmountViewModel) -> Bool { lhs.text == rhs.text && diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioPositionsViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioPositionsViewPresenter.swift index 75a8e8f8a..d2a4f679d 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioPositionsViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioPositionsViewPresenter.swift @@ -91,7 +91,7 @@ class dydxPortfolioPositionsViewPresenter: HostedViewPresenter 0 { + sign = .plus + } else { + sign = .minus + } + self.init(text: formattedText, + sign: sign, + coloringOption: coloringOption) + } +} diff --git a/dydx/dydxViews/dydxViews/Themes/dydxThemes.swift b/dydx/dydxViews/dydxViews/Themes/dydxThemes.swift index cb04acad0..ee387dd7c 100644 --- a/dydx/dydxViews/dydxViews/Themes/dydxThemes.swift +++ b/dydx/dydxViews/dydxViews/Themes/dydxThemes.swift @@ -146,21 +146,6 @@ struct GradientTypeModifier: ViewModifier { } } -public extension SignedAmountViewModel { - convenience init(text: String? = nil, sign: PlatformUISign = .plus, coloringOption: ColoringOption) { - self.init(text: text, sign: sign, coloringOption: coloringOption, positiveTextStyleKey: ThemeSettings.positiveTextStyleKey, negativeTextStyleKey: ThemeSettings.negativeTextStyleKey) - } - - convenience init(amount: Double?, displayType: DisplayType, coloringOption: ColoringOption, shouldDisplaySignForPositiveNumbers: Bool = false) { - self.init(amount: amount, - displayType: displayType, - coloringOption: coloringOption, - positiveTextStyleKey: ThemeSettings.positiveTextStyleKey, - negativeTextStyleKey: ThemeSettings.negativeTextStyleKey, - shouldDisplaySignForPositiveNumbers: shouldDisplaySignForPositiveNumbers) - } -} - private extension UIWindow { /// Unload all views and add back.