-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOB-252 : Add link to share app on profile screen (#98)
* add in-line share action * use app url instead of website * add analytics event
- Loading branch information
Showing
10 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
dydx/dydxViews/dydxViews/Media.xcassets/icon_share.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Share.pdf", | ||
"filename" : "icon_share.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
|
Binary file removed
BIN
-2.37 KB
dydx/dydxViews/dydxViews/Media.xcassets/icon_share.imageset/Share.pdf
Binary file not shown.
Binary file added
BIN
+4.15 KB
dydx/dydxViews/dydxViews/Media.xcassets/icon_share.imageset/icon_share.pdf
Binary file not shown.
64 changes: 64 additions & 0 deletions
64
dydx/dydxViews/dydxViews/_v4/Profile/TradingRewards/Components/dydxInlineShareView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters