@@ -244,7 +244,6 @@ public class dydxPortfolioPositionItemViewModel: PlatformViewModel {
244244}
245245
246246public class dydxPortfolioPositionsViewModel : PlatformViewModel {
247- @Published public var emptyText : String ?
248247 @Published public var positionItems : [ dydxPortfolioPositionItemViewModel ] {
249248 didSet {
250249 contentChanged ? ( )
@@ -259,19 +258,19 @@ public class dydxPortfolioPositionsViewModel: PlatformViewModel {
259258 @Published public var vaultBalance : String ?
260259 @Published public var vaultApy : Double ?
261260 @Published public var vaultTapAction : ( ( ) -> Void ) ?
261+ @Published public var isSignedIn : Bool = false
262+ @Published public var onboardAction : ( ( ) -> Void ) ?
262263
263264 public var contentChanged : ( ( ) -> Void ) ?
264265
265266 init (
266267 positionItems: [ dydxPortfolioPositionItemViewModel ] = [ ] ,
267268 pendingPositionItems: [ dydxPortfolioPendingPositionsItemViewModel ] = [ ] ,
268269 vaultBalance: String ? = nil ,
269- vaultApy: String ? = nil ,
270- emptyText: String ? = nil
270+ vaultApy: String ? = nil
271271 ) {
272272 self . positionItems = positionItems
273273 self . pendingPositionItems = pendingPositionItems
274- self . emptyText = emptyText
275274 }
276275
277276 public static var previewValue : dydxPortfolioPositionsViewModel {
@@ -283,8 +282,8 @@ public class dydxPortfolioPositionsViewModel: PlatformViewModel {
283282 pendingPositionItems: [
284283 . previewValue
285284 ] ,
286- vaultBalance: " 324.320 " ,
287- emptyText : " empty " )
285+ vaultBalance: " 324.320 "
286+ )
288287 }
289288
290289 public var pendingPositionsHeader : PlatformViewModel ? {
@@ -309,9 +308,9 @@ public class dydxPortfolioPositionsViewModel: PlatformViewModel {
309308
310309 private var openPositionsView : some View {
311310 LazyVStack {
312- if let emptyText = self . emptyText , positionItems. isEmpty {
311+ if positionItems. isEmpty {
313312 AnyView (
314- PlaceholderViewModel ( text: emptyText )
313+ PlaceholderViewModel ( text: DataLocalizer . localize ( path : " APP.GENERAL.PLACEHOLDER_NO_POSITIONS " ) )
315314 . createView ( )
316315 )
317316 } else {
@@ -398,6 +397,14 @@ public class dydxPortfolioPositionsViewModel: PlatformViewModel {
398397 public override func createView( parentStyle: ThemeStyle = ThemeStyle . defaultStyle, styleKey: String ? = nil ) -> PlatformView {
399398 PlatformView ( viewModel: self , parentStyle: parentStyle, styleKey: styleKey) { [ weak self] _ in
400399 guard let self = self else { return AnyView ( PlatformView . nilView) }
400+ guard self . isSignedIn else {
401+ return PlatformButtonViewModel (
402+ content: Text ( DataLocalizer . localize ( path: " APP.GENERAL.SIGN_IN_TO_VIEW " ) ) . wrappedViewModel,
403+ action: { self . onboardAction ? ( ) }
404+ )
405+ . createView ( parentStyle: parentStyle)
406+ . wrappedInAnyView ( )
407+ }
401408
402409 return AnyView (
403410 ScrollView {
0 commit comments