Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-252 : Add link to share app on profile screen #98

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"destination":"Refresh.xib"
},
"/action/share":{
"destination":"Share.xib"
"destination":"PlatformRouting.ShareActionBuilder"
},
"/action/wallet":{
"destination":"Wallet.xib"
Expand Down
8 changes: 8 additions & 0 deletions PlatformRouting/PlatformRouting/_Actions/ShareAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
//

import RoutingKit
import Utilities
import UIToolkits

public class ShareActionBuilder: NSObject, ObjectBuilderProtocol {
public func build<T>() -> T? {
let action = ShareAction()
return action as? T
}
}

open class ShareAction: NSObject, NavigableProtocol {
private var completion: RoutingCompletionBlock?
open func navigate(to request: RoutingRequest?, animated: Bool, completion: RoutingCompletionBlock?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"destination":"dydxPresenters.dydxCancelOrderActionBuilder"
},
"/action/share": {
"destination":"ShareAction.xib"
"destination":"PlatformRouting.ShareActionBuilder"
},
"/action/wallet/connect": {
"destination":"dydxPresenters.WalletActionBuilder"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import PlatformParticles
import RoutingKit
import ParticlesKit
import PlatformUI
import dydxStateManager

public class dydxProfileViewBuilder: NSObject, ObjectBuilderProtocol {
public func build<T>() -> T? {
Expand Down Expand Up @@ -72,5 +73,10 @@ private class dydxProfileViewPresenter: HostedViewPresenter<dydxProfileViewModel
balancesPresenter.$viewModel.assign(to: &viewModel.$balances)

attachChildren(workers: childPresenters)

viewModel.share?.shareAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/action/share", params: ["text": DataLocalizer.shared?.localize(path: "APP.GENERAL.SHARE_MESSAGE", params: nil) ?? "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to add some tracking event for this action... maybe adding it to ShareAction's navigate() call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion, added e854479
and tested:
Screenshot 2024-02-27 at 5 14 18 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have also added to the notion tracking doc

"link": AbacusStateManager.shared.environment?.apps?.ios?.url ?? AbacusStateManager.shared.deploymentUri]), animated: true, completion: nil)
}
}
}
4 changes: 4 additions & 0 deletions dydx/dydxViews/dydxViews.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
276909102AAFD8BE0075B2D6 /* dydxPortfolioTransfersViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2769090F2AAFD8BE0075B2D6 /* dydxPortfolioTransfersViewModel.swift */; };
277442972AD88C4900C91357 /* Satoshi-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 277442952AD88C4900C91357 /* Satoshi-Bold.otf */; };
277442982AD88C4900C91357 /* Satoshi-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 277442962AD88C4900C91357 /* Satoshi-Regular.otf */; };
27759F5C2B89125F002865A9 /* dydxInlineShareView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27759F5B2B89125F002865A9 /* dydxInlineShareView.swift */; };
277E8F9F2B1A847D005CCBCB /* dydxTitledCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E8F9E2B1A847D005CCBCB /* dydxTitledCardView.swift */; };
277E8FCB2B1E5798005CCBCB /* dydxProfileRewardsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E8FCA2B1E5798005CCBCB /* dydxProfileRewardsViewModel.swift */; };
277E90132B1EA0D3005CCBCB /* dydxTradingRewardsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90122B1EA0D3005CCBCB /* dydxTradingRewardsView.swift */; };
Expand Down Expand Up @@ -504,6 +505,7 @@
2769090F2AAFD8BE0075B2D6 /* dydxPortfolioTransfersViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxPortfolioTransfersViewModel.swift; sourceTree = "<group>"; };
277442952AD88C4900C91357 /* Satoshi-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Satoshi-Bold.otf"; sourceTree = "<group>"; };
277442962AD88C4900C91357 /* Satoshi-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Satoshi-Regular.otf"; sourceTree = "<group>"; };
27759F5B2B89125F002865A9 /* dydxInlineShareView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxInlineShareView.swift; sourceTree = "<group>"; };
277E8F9E2B1A847D005CCBCB /* dydxTitledCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTitledCardView.swift; sourceTree = "<group>"; };
277E8FCA2B1E5798005CCBCB /* dydxProfileRewardsViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxProfileRewardsViewModel.swift; sourceTree = "<group>"; };
277E90122B1EA0D3005CCBCB /* dydxTradingRewardsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTradingRewardsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1376,6 +1378,7 @@
277E91072B2241C1005CCBCB /* dydxRewardsRewardView.swift */,
277E91492B23BB74005CCBCB /* dydxRewardsLearnMoreView.swift */,
277E918A2B27762F005CCBCB /* dydxRewardsLaunchIncentivesView.swift */,
27759F5B2B89125F002865A9 /* dydxInlineShareView.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -1988,6 +1991,7 @@
024F488E2965C91E00E40247 /* dydxPortfolioChartView.swift in Sources */,
645299F22AE86FC3000810E6 /* dydxUpdateView.swift in Sources */,
02031F052AC373B50069E00D /* dydxTradeSheetTipBuySellView.swift in Sources */,
27759F5C2B89125F002865A9 /* dydxInlineShareView.swift in Sources */,
0230377328C13BBB00412B72 /* dydxMarketsView.swift in Sources */,
02F958142A1BDEE500828F9A /* dydxKeyExportView.swift in Sources */,
0238B90B29FB38F200FCE4D0 /* dydxThemeLoader.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "Share.pdf",
"filename" : "icon_share.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// dydxInlineShareView.swift
// dydxUI
//
// Created by Michael Maguire on 2/23/24.
// Copyright © 2024 dYdX Trading Inc. All rights reserved.
//

import SwiftUI
import PlatformUI
import Utilities

public class dydxInlineShareViewModel: PlatformViewModel {
@Published public var shareAction: (() -> Void)?

private let shareCta: AttributedString = {
let localizedString = DataLocalizer.shared?.localize(path: "APP.GENERAL.SHARE_DYDX", params: nil) ?? ""
let unhighlightedString = DataLocalizer.shared?.localize(path: "APP.GENERAL.SHARE", params: nil) ?? ""

var attributedString = AttributedString(localizedString)
.themeFont(fontType: .text, fontSize: .medium)

attributedString = attributedString.themeColor(foreground: .textSecondary)
if let unhighlightedStringRange = attributedString.range(of: unhighlightedString) {
attributedString = attributedString.themeColor(foreground: .textTertiary, to: unhighlightedStringRange)
}

return attributedString
}()

public static var previewValue: dydxInlineShareViewModel = {
let vm = dydxInlineShareViewModel()
return vm
}()

public override func createView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> PlatformView {
PlatformView(viewModel: self, parentStyle: parentStyle, styleKey: styleKey) { [weak self] style in
guard let self = self else { return AnyView(PlatformView.nilView) }

return AnyView(
HStack(alignment: .center, spacing: 6) {
Text(self.shareCta)
PlatformIconViewModel(type: .asset(name: "icon_share", bundle: .dydxView),
clip: .noClip,
size: CGSize(width: 20, height: 20),
templateColor: .textSecondary)
.createView(parentStyle: style)
}
.onTapGesture { [weak self] in
self?.shareAction?()
}
)
}
}
}

#Preview {
Group {
dydxInlineShareViewModel.previewValue
.createView()
.environmentObject(ThemeSettings.shared)
.previewLayout(.sizeThatFits)
}
}
6 changes: 5 additions & 1 deletion dydx/dydxViews/dydxViews/_v4/Profile/dydxProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class dydxProfileViewModel: PlatformViewModel {
@Published public var fees: dydxProfileFeesViewModel? = dydxProfileFeesViewModel()
@Published public var balances: dydxProfileBalancesViewModel? = dydxProfileBalancesViewModel()
@Published public var rewards: dydxProfileRewardsViewModel? = dydxProfileRewardsViewModel()
@Published public var share: dydxInlineShareViewModel? = dydxInlineShareViewModel()

public init() { }

Expand Down Expand Up @@ -58,7 +59,10 @@ public class dydxProfileViewModel: PlatformViewModel {
self.history?
.createView(parentStyle: style)

Spacer(minLength: 100)
self.share?
.createView(parentStyle: style)

Spacer(minLength: 136)
}
}
.padding(.horizontal)
Expand Down
Loading