From 3a7b0d13ed39ce8dd26725b93d871db2e27cac4f Mon Sep 17 00:00:00 2001 From: mike-dydx Date: Mon, 24 Jun 2024 11:58:05 -0400 Subject: [PATCH] fix layout for isolated/non-isolated stats row --- .../dydxMarketPositionViewPresenter.swift | 6 + .../Position/dydxMarketPositionView.swift | 158 ++++++++++++------ 2 files changed, 116 insertions(+), 48 deletions(-) diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/Components/dydxMarketPositionViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/Components/dydxMarketPositionViewPresenter.swift index 9186b388a..0bc53ee61 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/Components/dydxMarketPositionViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/Components/dydxMarketPositionViewPresenter.swift @@ -107,6 +107,12 @@ class dydxMarketPositionViewPresenter: HostedViewPresenter some View { - VStack(spacing: 0) { + VStack(spacing: 12) { HStack { createPositionTab(parentStyle: parentStyle) @@ -121,38 +201,11 @@ public class dydxMarketPositionViewModel: PlatformViewModel { } .frame(minWidth: 0, maxWidth: .infinity) } - .padding(.vertical, 8) - - DividerModel().createView(parentStyle: parentStyle) - .padding(.top, 8) - HStack(alignment: .top, spacing: 0) { - let unrealizedValue = VStack(alignment: .leading) { - unrealizedPNLAmount? - .createView(parentStyle: parentStyle.themeFont(fontSize: .large)) - - unrealizedPNLPercent? - .createView(parentStyle: parentStyle.themeFont(fontSize: .smaller).themeColor(foreground: .textTertiary)) - }.wrappedViewModel - - let realizedValue = VStack(alignment: .leading) { - realizedPNLAmount? - .createView(parentStyle: parentStyle.themeFont(fontSize: .large)) - Spacer() - }.wrappedViewModel - - self.createCollectionItem(parentStyle: parentStyle, title: DataLocalizer.localize(path: "APP.TRADE.UNREALIZED_PNL"), valueViewModel: unrealizedValue) - .padding(.vertical, 16) - .frame(height: 96) - - DividerModel().createView(parentStyle: parentStyle) - .frame(height: 82) - - self.createCollectionItem(parentStyle: parentStyle, title: DataLocalizer.localize(path: "APP.TRADE.REALIZED_PNL"), valueViewModel: realizedValue) - .padding(.vertical, 16) - .frame(height: 96) - } + statsRow } + .padding(.bottom, 8) + } private func createPositionTab(parentStyle: ThemeStyle) -> some View { @@ -194,30 +247,39 @@ public class dydxMarketPositionViewModel: PlatformViewModel { } private func createCollectionItem(parentStyle: ThemeStyle, title: String?, stringValue: String?) -> some View { - VStack(alignment: .leading) { - Text(title ?? "") - .themeFont(fontSize: .small) - .themeColor(foreground: .textTertiary) - .leftAligned() + VStack(spacing: 0) { + VStack(alignment: .leading, spacing: 6) { + Text(title ?? "") + .themeFont(fontType: .plus, fontSize: .small) + .themeColor(foreground: .textTertiary) + .fixedSize(horizontal: true, vertical: false) + .leftAligned() + Text(stringValue ?? "-") + .themeFont(fontSize: .medium) + .themeColor(foreground: .textSecondary) + .lineLimit(1) + .minimumScaleFactor(0.5) + } Spacer() - Text(stringValue ?? "-") - .leftAligned() - .lineLimit(1) - .minimumScaleFactor(0.5) } .padding(.horizontal, 8) } private func createCollectionItem(parentStyle: ThemeStyle, title: String?, valueViewModel: PlatformViewModel?) -> some View { - VStack(alignment: .leading) { - Text(title ?? "") - .themeFont(fontSize: .small) - .themeColor(foreground: .textTertiary) - .leftAligned() + VStack(spacing: 0) { + VStack(alignment: .leading, spacing: 6) { + Text(title ?? "") + .themeFont(fontType: .plus, fontSize: .small) + .themeColor(foreground: .textTertiary) + .fixedSize(horizontal: true, vertical: false) + .leftAligned() + valueViewModel?.createView(parentStyle: parentStyle, styleKey: nil) + .fixedSize(horizontal: true, vertical: false) + .leftAligned() + } Spacer() - valueViewModel?.createView(parentStyle: parentStyle, styleKey: nil) - .leftAligned() } + .padding(.horizontal, 8) } @@ -230,7 +292,7 @@ public class dydxMarketPositionViewModel: PlatformViewModel { let content = HStack { Spacer() Text(DataLocalizer.localize(path: "APP.TRADE.CLOSE_POSITION")) - .themeFont(fontSize: .medium) + .themeFont(fontType: .plus, fontSize: .medium) .themeColor(foreground: ThemeSettings.negativeColor) Spacer() }