Skip to content

Commit 22cfa90

Browse files
committed
Add sign in button to market positions screen
1 parent a9da7ed commit 22cfa90

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

ios/dydx/dydxPresenters/dydxPresenters/_v4/MarketInfo/Components/dydxMarketPositionViewPresenter.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,8 @@ class dydxMarketPositionViewPresenter: HostedViewPresenter<dydxMarketPositionVie
7777
.CombineLatest(AbacusStateManager.shared.state.onboarded,
7878
$position.removeDuplicates())
7979
.sink { [weak self] (onboarded, position) in
80-
if !onboarded {
81-
self?.viewModel?.emptyText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_POSITIONS_LOG_IN")
82-
} else if position == nil {
83-
self?.viewModel?.emptyText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_POSITIONS")
84-
} else {
85-
self?.viewModel?.emptyText = nil
86-
}
80+
self?.viewModel?.isSignedIn = onboarded
81+
self?.viewModel?.hasOpenPosition = position != nil
8782
}
8883
.store(in: &subscriptions)
8984

ios/dydx/dydxViews/dydxViews/_v4/MarketInfo/Components/Position/dydxMarketPositionView.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ import PlatformUI
1111
import Utilities
1212

1313
public class dydxMarketPositionViewModel: PlatformViewModel {
14-
@Published public var emptyText: String?
15-
1614
@Published public var closeAction: (() -> Void)?
1715
@Published public var editMarginAction: (() -> Void)?
16+
@Published public var onboardAction: (() -> Void)?
17+
18+
@Published public var isSignedIn: Bool = false
19+
@Published public var hasOpenPosition: Bool = false
20+
1821
@Published public var unrealizedPNLAmount: SignedAmountViewModel?
1922
@Published public var unrealizedPNLPercent: String = ""
2023
@Published public var realizedPNLAmount: SignedAmountViewModel?
@@ -77,13 +80,21 @@ public class dydxMarketPositionViewModel: PlatformViewModel {
7780
VStack(spacing: 24) {
7881
// check size to determine if there is current position data to display
7982
VStack {
80-
if let emptyText = self.emptyText {
81-
PlaceholderViewModel(text: emptyText)
82-
.createView()
83+
if self.isSignedIn {
84+
if self.hasOpenPosition {
85+
self.createCollection(parentStyle: style)
86+
self.createButtons(parentStyle: style)
87+
self.createList(parentStyle: style)
88+
} else {
89+
PlaceholderViewModel(text: DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_POSITIONS"))
90+
.createView()
91+
}
8392
} else {
84-
self.createCollection(parentStyle: style)
85-
self.createButtons(parentStyle: style)
86-
self.createList(parentStyle: style)
93+
PlatformButtonViewModel(
94+
content: Text(DataLocalizer.localize(path: "APP.GENERAL.SIGN_IN_TO_VIEW")).wrappedViewModel,
95+
action: { self.onboardAction?() }
96+
)
97+
.createView(parentStyle: parentStyle)
8798
}
8899
}
89100

0 commit comments

Comments
 (0)