Skip to content

Commit a9da7ed

Browse files
committed
Add sign in button to other portfolio tabs
1 parent 798694e commit a9da7ed

File tree

7 files changed

+52
-28
lines changed

7 files changed

+52
-28
lines changed

ios/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioFillsViewPresenter.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ class dydxPortfolioFillsViewPresenter: HostedViewPresenter<dydxPortfolioFillsVie
2929
super.init()
3030

3131
self.viewModel = viewModel
32+
33+
viewModel?.onboardAction = {
34+
Router.shared?.navigate(to: RoutingRequest(path: "/onboard"), animated: true, completion: { /* [weak self] */ _, _ in
35+
})
36+
}
3237
}
3338

3439
override func start() {
3540
super.start()
3641

3742
AbacusStateManager.shared.state.onboarded
3843
.sink { [weak self] onboarded in
39-
if onboarded {
40-
self?.viewModel?.placeholderText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_TRADES")
41-
} else {
42-
self?.viewModel?.placeholderText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_TRADES_LOG_IN")
43-
}
44+
self?.viewModel?.isSignedIn = onboarded
4445
}
4546
.store(in: &subscriptions)
4647

ios/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioFundingViewPresenter.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ class dydxPortfolioFundingViewPresenter: HostedViewPresenter<dydxPortfolioFundin
2929
super.init()
3030

3131
self.viewModel = viewModel
32+
33+
viewModel?.onboardAction = {
34+
Router.shared?.navigate(to: RoutingRequest(path: "/onboard"), animated: true, completion: { /* [weak self] */ _, _ in
35+
})
36+
}
3237
}
3338

3439
override func start() {
3540
super.start()
3641

3742
AbacusStateManager.shared.state.onboarded
3843
.sink { [weak self] onboarded in
39-
if onboarded {
40-
self?.viewModel?.placeholderText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_FUNDING")
41-
} else {
42-
self?.viewModel?.placeholderText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_FUNDING_LOG_IN")
43-
}
44+
self?.viewModel?.isSignedIn = onboarded
4445
}
4546
.store(in: &subscriptions)
4647

ios/dydx/dydxPresenters/dydxPresenters/_v4/Portfolio/Components/dydxPortfolioOrdersViewPresenter.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,19 @@ class dydxPortfolioOrdersViewPresenter: HostedViewPresenter<dydxPortfolioOrdersV
2929
super.init()
3030

3131
self.viewModel = viewModel
32+
33+
viewModel?.onboardAction = {
34+
Router.shared?.navigate(to: RoutingRequest(path: "/onboard"), animated: true, completion: { /* [weak self] */ _, _ in
35+
})
36+
}
3237
}
3338

3439
override func start() {
3540
super.start()
3641

3742
AbacusStateManager.shared.state.onboarded
3843
.sink { [weak self] onboarded in
39-
if onboarded {
40-
self?.viewModel?.placeholderText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_ORDERS")
41-
} else {
42-
self?.viewModel?.placeholderText = DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_ORDERS_LOG_IN")
43-
}
44+
self?.viewModel?.isSignedIn = onboarded
4445
}
4546
.store(in: &subscriptions)
4647

ios/dydx/dydxViews/dydxViews/_v4/Portfolio/Components/Sections/dydxPortfolioFillsView.swift

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

1313
public class dydxPortfolioFillsViewModel: PlatformListViewModel {
14-
@Published public var placeholderText: String?
14+
@Published public var isSignedIn: Bool = false
15+
@Published public var onboardAction: (() -> Void)?
1516

1617
public override var placeholder: PlatformViewModel? {
17-
let vm = PlaceholderViewModel()
18-
vm.text = placeholderText
19-
return vm
18+
guard self.isSignedIn else {
19+
return PlatformButtonViewModel(
20+
content: Text(DataLocalizer.localize(path: "APP.GENERAL.SIGN_IN_TO_VIEW")).wrappedViewModel,
21+
action: { self.onboardAction?() }
22+
)
23+
}
24+
return PlaceholderViewModel(
25+
text: DataLocalizer.localize(path: "APP.TRADE.TRADES_EMPTY_STATE")
26+
)
2027
}
2128

2229
public init(items: [PlatformViewModel] = [], contentChanged: (() -> Void)? = nil) {

ios/dydx/dydxViews/dydxViews/_v4/Portfolio/Components/Sections/dydxPortfolioFundingView.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,19 @@ public class dydxPortfolioFundingItemViewModel: PlatformViewModel {
147147
}
148148

149149
public class dydxPortfolioFundingViewModel: PlatformListViewModel {
150-
@Published public var placeholderText: String?
150+
@Published public var isSignedIn: Bool = false
151+
@Published public var onboardAction: (() -> Void)?
151152

152153
public override var placeholder: PlatformViewModel? {
153-
let vm = PlaceholderViewModel()
154-
vm.text = placeholderText
155-
return vm
154+
guard self.isSignedIn else {
155+
return PlatformButtonViewModel(
156+
content: Text(DataLocalizer.localize(path: "APP.GENERAL.SIGN_IN_TO_VIEW")).wrappedViewModel,
157+
action: { self.onboardAction?() }
158+
)
159+
}
160+
return PlaceholderViewModel(
161+
text: DataLocalizer.localize(path: "APP.TRADE.FUNDING_EMPTY_STATE")
162+
)
156163
}
157164

158165
public init(items: [PlatformViewModel] = [], contentChanged: (() -> Void)? = nil) {

ios/dydx/dydxViews/dydxViews/_v4/Portfolio/Components/Sections/dydxPortfolioOrdersView.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,19 @@ public class dydxPortfolioOrderItemViewModel: PlatformViewModel {
183183
}
184184

185185
public class dydxPortfolioOrdersViewModel: PlatformListViewModel {
186-
@Published public var placeholderText: String?
186+
@Published public var isSignedIn: Bool = false
187+
@Published public var onboardAction: (() -> Void)?
187188

188189
public override var placeholder: PlatformViewModel? {
189-
let vm = PlaceholderViewModel()
190-
vm.text = placeholderText
191-
return vm
190+
guard self.isSignedIn else {
191+
return PlatformButtonViewModel(
192+
content: Text(DataLocalizer.localize(path: "APP.GENERAL.SIGN_IN_TO_VIEW")).wrappedViewModel,
193+
action: { self.onboardAction?() }
194+
)
195+
}
196+
return PlaceholderViewModel(
197+
text: DataLocalizer.localize(path: "APP.TRADE.ORDER_EMPTY_STATE")
198+
)
192199
}
193200

194201
public init(items: [PlatformViewModel] = [], contentChanged: (() -> Void)? = nil) {

ios/dydx/dydxViews/dydxViews/_v4/Portfolio/Components/Sections/dydxPortfolioPositionsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public class dydxPortfolioPositionsViewModel: PlatformViewModel {
310310
LazyVStack {
311311
if positionItems.isEmpty {
312312
AnyView(
313-
PlaceholderViewModel(text: DataLocalizer.localize(path: "APP.GENERAL.PLACEHOLDER_NO_POSITIONS"))
313+
PlaceholderViewModel(text: DataLocalizer.localize(path: "APP.TRADE.POSITIONS_EMPTY_STATE"))
314314
.createView()
315315
)
316316
} else {

0 commit comments

Comments
 (0)