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

TRCL-3318 : Trading Rewards Details Screen Help Card #38

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 8 additions & 4 deletions dydx/dydxPresenters/dydxPresenters.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
276908FF2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 276908FE2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift */; };
277E8FC92B1E576B005CCBCB /* dydxProfileRewardsViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E8FC82B1E576B005CCBCB /* dydxProfileRewardsViewPresenter.swift */; };
277E90152B1EA0E3005CCBCB /* dydxTradingRewardsViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90142B1EA0E3005CCBCB /* dydxTradingRewardsViewPresenter.swift */; };
277E90192B1EA3C3005CCBCB /* dydxTradingRewardsViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90182B1EA3C3005CCBCB /* dydxTradingRewardsViewBuilder.swift */; };
277E90192B1EA3C3005CCBCB /* dydxRewardsSummaryPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90182B1EA3C3005CCBCB /* dydxRewardsSummaryPresenter.swift */; };
277E90332B1FAE9A005CCBCB /* dydxRewardsHelpViewBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90322B1FAE9A005CCBCB /* dydxRewardsHelpViewBuilder.swift */; };
27C027532AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */; };
27DB2EA32AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27DB2EA22AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift */; };
314BBDE9F332ECA910BC414E /* Pods_iOS_dydxPresenters.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F1551C00FFF41C29CFC5BD94 /* Pods_iOS_dydxPresenters.framework */; };
Expand Down Expand Up @@ -473,7 +474,8 @@
276908FE2AAFB22F0075B2D6 /* dydxPortfolioTransfersViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxPortfolioTransfersViewPresenter.swift; sourceTree = "<group>"; };
277E8FC82B1E576B005CCBCB /* dydxProfileRewardsViewPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxProfileRewardsViewPresenter.swift; sourceTree = "<group>"; };
277E90142B1EA0E3005CCBCB /* dydxTradingRewardsViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTradingRewardsViewPresenter.swift; sourceTree = "<group>"; };
277E90182B1EA3C3005CCBCB /* dydxTradingRewardsViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTradingRewardsViewBuilder.swift; sourceTree = "<group>"; };
277E90182B1EA3C3005CCBCB /* dydxRewardsSummaryPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRewardsSummaryPresenter.swift; sourceTree = "<group>"; };
277E90322B1FAE9A005CCBCB /* dydxRewardsHelpViewBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRewardsHelpViewBuilder.swift; sourceTree = "<group>"; };
27C027522AFD761300E92CCB /* dydxSettingsHelpRowViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxSettingsHelpRowViewPresenter.swift; sourceTree = "<group>"; };
27DB2EA22AC1E7B20047BC39 /* dydxTradeRestrictedViewPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxTradeRestrictedViewPresenter.swift; sourceTree = "<group>"; };
64487FFE2AA248340068DD87 /* dydxAlertsWorker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = dydxAlertsWorker.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1294,7 +1296,8 @@
277E90172B1EA376005CCBCB /* Components */ = {
isa = PBXGroup;
children = (
277E90182B1EA3C3005CCBCB /* dydxTradingRewardsViewBuilder.swift */,
277E90182B1EA3C3005CCBCB /* dydxRewardsSummaryPresenter.swift */,
277E90322B1FAE9A005CCBCB /* dydxRewardsHelpViewBuilder.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -1797,7 +1800,7 @@
0208631028F5186E00C9D3A0 /* OrderbookLineDataPoint.swift in Sources */,
0276FA992A0DB8FD000BDF0B /* Model+Ext.swift in Sources */,
6488BBC7296F2CD50096502F /* AbacusUtils.swift in Sources */,
277E90192B1EA3C3005CCBCB /* dydxTradingRewardsViewBuilder.swift in Sources */,
277E90192B1EA3C3005CCBCB /* dydxRewardsSummaryPresenter.swift in Sources */,
026FC3E42AFACA3300C52F20 /* dydxPresentersBundleClass.swift in Sources */,
025841F228EE9D7C007338D3 /* dydxMarketAssetListViewPresenter.swift in Sources */,
02F95A8E2A1D6AAD00828F9A /* dydxProfileHistoryViewPresenter.swift in Sources */,
Expand All @@ -1809,6 +1812,7 @@
02A565AF2A5E310B0035469F /* dydxAlertsProvider.swift in Sources */,
025841F428EE9DE8007338D3 /* dydxAssetItemChartViewPresenter.swift in Sources */,
02860A9F29C15E760079E644 /* dydxOnboardScanViewBuilder.swift in Sources */,
277E90332B1FAE9A005CCBCB /* dydxRewardsHelpViewBuilder.swift in Sources */,
02FAFA5C29D4E08E001A0903 /* dydxDebugViewBuilder.swift in Sources */,
02F700FE29EA0FD9004DEB5E /* dydxReceiptPresenter.swift in Sources */,
027E1EF829CA27CD0098666F /* dydxSettingsLandingViewBuilder.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// dydxRewardsHelpViewBuilder.swift
// dydxPresenters
//
// Created by Michael Maguire on 12/5/23.
//

import dydxViews
import PlatformParticles
import ParticlesKit
import RoutingKit

public protocol dydxRewardsHelpViewPresenterProtocol: HostedViewPresenterProtocol {
var viewModel: dydxRewardsHelpViewModel? { get }
}

public class dydxRewardsHelpViewPresenter: HostedViewPresenter<dydxRewardsHelpViewModel>, dydxRewardsHelpViewPresenterProtocol {
override init() {
super.init()

viewModel = dydxRewardsHelpViewModel()

viewModel?.learnMoreTapped = {
// TODO get url from abacus
// Router.shared?.navigate(to: .init(url: ...), animated: true, completion: nil)
}

// TODO get todos from abacus
viewModel?.faqs = [
.init(question: "What is the question?", answer: "The answer to your question is he answer to your question is The answer to your question is The answer to your question is "),
.init(question: "What is the question if the question is the question about a question?", answer: "The answer to your question is he answer to your question is The answer to your question is The answer to your question is "),
.init(question: "What is the question again?", answer: "The answer to your question is he answer to your question is The answer to your question is The answer to your question is "),
.init(question: "What is the question again again again?", answer: "The answer to your question is he answer to your question is The answer to your question is The answer to your question is ")
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ private protocol dydxTradingRewardsViewPresenterProtocol: HostedViewPresenterPro
}

private class dydxTradingRewardsViewPresenter: HostedViewPresenter<dydxTradingRewardsViewModel>, dydxTradingRewardsViewPresenterProtocol {

private let helpPresenter = dydxRewardsHelpViewPresenter()

override init() {
super.init()

viewModel = dydxTradingRewardsViewModel()
let viewModel = dydxTradingRewardsViewModel()

viewModel?.headerViewModel.title = DataLocalizer.localize(path: "APP.GENERAL.TRADING_REWARDS")
viewModel?.headerViewModel.backButtonAction = {
viewModel.headerViewModel.title = DataLocalizer.localize(path: "APP.GENERAL.TRADING_REWARDS")
viewModel.headerViewModel.backButtonAction = {
Router.shared?.navigate(to: RoutingRequest(path: "/action/dismiss"), animated: true, completion: nil)
}

helpPresenter.$viewModel.assign(to: &viewModel.$help)

self.viewModel = viewModel
}
}
8 changes: 8 additions & 0 deletions dydx/dydxViews/dydxViews.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@
277E8FCB2B1E5798005CCBCB /* dydxProfileRewardsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E8FCA2B1E5798005CCBCB /* dydxProfileRewardsViewModel.swift */; };
277E90132B1EA0D3005CCBCB /* dydxTradingRewardsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90122B1EA0D3005CCBCB /* dydxTradingRewardsView.swift */; };
277E901B2B1EA4F9005CCBCB /* dydxRewardsSummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E901A2B1EA4F9005CCBCB /* dydxRewardsSummaryView.swift */; };
277E90412B1FAEAF005CCBCB /* dydxRewardsHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E90402B1FAEAF005CCBCB /* dydxRewardsHelpView.swift */; };
277E904F2B1FAFCB005CCBCB /* dydxFAQView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277E904E2B1FAFCB005CCBCB /* dydxFAQView.swift */; };
27A799B92A66EC2D007C3D04 /* ThemeClassicDark.json in Resources */ = {isa = PBXBuildFile; fileRef = 27A799B82A66EC2D007C3D04 /* ThemeClassicDark.json */; };
27AAA9862ACE34C800AF3C56 /* SwiftMessages+Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27AAA9852ACE34C800AF3C56 /* SwiftMessages+Banner.swift */; };
27C027452AFD734800E92CCB /* dydxSettingsHelpRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27C027442AFD734800E92CCB /* dydxSettingsHelpRowView.swift */; };
Expand Down Expand Up @@ -500,6 +502,8 @@
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>"; };
277E901A2B1EA4F9005CCBCB /* dydxRewardsSummaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRewardsSummaryView.swift; sourceTree = "<group>"; };
277E90402B1FAEAF005CCBCB /* dydxRewardsHelpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxRewardsHelpView.swift; sourceTree = "<group>"; };
277E904E2B1FAFCB005CCBCB /* dydxFAQView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxFAQView.swift; sourceTree = "<group>"; };
27A799B82A66EC2D007C3D04 /* ThemeClassicDark.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = ThemeClassicDark.json; sourceTree = "<group>"; };
27AAA9852ACE34C800AF3C56 /* SwiftMessages+Banner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SwiftMessages+Banner.swift"; sourceTree = "<group>"; };
27C027442AFD734800E92CCB /* dydxSettingsHelpRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = dydxSettingsHelpRowView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1356,6 +1360,8 @@
isa = PBXGroup;
children = (
277E901A2B1EA4F9005CCBCB /* dydxRewardsSummaryView.swift */,
277E90402B1FAEAF005CCBCB /* dydxRewardsHelpView.swift */,
277E904E2B1FAFCB005CCBCB /* dydxFAQView.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -1850,6 +1856,7 @@
0284201629AD71B600C0E7CC /* Enums.swift in Sources */,
02678FA629666BE600EE346B /* dydxPortfolioOrdersView.swift in Sources */,
020DBF0F29E0924E0068AAA6 /* dydxTransferDepositView.swift in Sources */,
277E90412B1FAEAF005CCBCB /* dydxRewardsHelpView.swift in Sources */,
02714C9F29E0C7C500CC1C44 /* TokensComboBox.swift in Sources */,
64A4DC652968A17C008D8E20 /* dydxTradeInputSideView.swift in Sources */,
024FEB7E2ACB82A10087A55E /* NavHeader.swift in Sources */,
Expand Down Expand Up @@ -1901,6 +1908,7 @@
02D3C46E28F74F5400683843 /* dydxMarketResourcesView.swift in Sources */,
02FA5B6F2A12FB040045F2F5 /* dydxTransferWithdrawalView.swift in Sources */,
0230377628C13DA500412B72 /* dydxMarketsHeaderView.swift in Sources */,
277E904F2B1FAFCB005CCBCB /* dydxFAQView.swift in Sources */,
277E8F9F2B1A847D005CCBCB /* dydxTitledCardView.swift in Sources */,
024B44F129834D1F00E35D54 /* dydxTradeStatusCtaButtonView.swift in Sources */,
0230A2A228B84A140036DDF3 /* UIHostingController+Ext.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "icon_collapse.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "icon_expand.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class dydxProfileFeesViewModel: dydxTitledCardViewModel, Equatable {
return vm
}

override func createContent(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
override func createContentView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
VStack(spacing: 16) {
HStack {
VStack(spacing: 8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class dydxProfileHistoryViewModel: dydxTitledCardViewModel {
return vm
}

public override func createContent(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
public override func createContentView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
VStack(spacing: 0) {
GeometryReader { metrics in
VStack(spacing: 8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class dydxProfileRewardsViewModel: dydxTitledCardViewModel {
super.init(title: DataLocalizer.shared?.localize(path: "APP.GENERAL.TRADING_REWARDS", params: nil) ?? "")
}

override func createContent(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
override func createContentView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
HStack(spacing: 0) {
VStack(alignment: .leading, spacing: 10) {
titleValueStack(title: DataLocalizer.shared?.localize(path: "APP.PROFILES_PAGE.REWARDS_LAST_7_DAYS", params: nil) ?? "", value: last7DaysRewardsAmount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ import Utilities
public class dydxTitledCardViewModel: PlatformViewModel {

public let title: String
public let verticalContentPadding: CGFloat
public let horizontalContentPadding: CGFloat
@Published public var tapAction: (() -> Void)?

public init(title: String) {
public init(title: String,
verticalContentPadding: CGFloat = 10,
horizontalContentPadding: CGFloat = 18) {
self.title = title
self.verticalContentPadding = verticalContentPadding
self.horizontalContentPadding = horizontalContentPadding
super.init()
}

Expand All @@ -24,8 +30,17 @@ public class dydxTitledCardViewModel: PlatformViewModel {
return vm
}

func createContent(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
PlatformView.nilView?.wrappedInAnyView()
func createContentView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
AnyView(PlatformView.nilView)
}

/// defaults to a right facing chevron. override if you want a different accessory view or no accessory view at all
func createTitleAccessoryView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? {
PlatformIconViewModel(type: .system(name: "chevron.right"),
size: CGSize(width: 10, height: 10),
templateColor: .textSecondary)
.createView(parentStyle: parentStyle)
.wrappedInAnyView()
}

public override func createView(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> PlatformView {
Expand All @@ -36,21 +51,17 @@ public class dydxTitledCardViewModel: PlatformViewModel {
HStack {
Text(self.title)
.themeFont(fontSize: .small)
.themeColor(foreground: .textSecondary)
Spacer()
if self.tapAction != nil {
PlatformIconViewModel(type: .system(name: "chevron.right"),
size: CGSize(width: 10, height: 10),
templateColor: .textSecondary)
.createView(parentStyle: style)
}
self.createTitleAccessoryView(parentStyle: parentStyle)
}
.padding()

DividerModel()
.createView(parentStyle: style)
self.createContent(parentStyle: style)
.padding(.vertical, 10)
.padding(.horizontal, 18)
self.createContentView(parentStyle: parentStyle)
.padding(.vertical, self.verticalContentPadding)
.padding(.horizontal, self.horizontalContentPadding)
}
.themeColor(background: .layer3)
.cornerRadius(12, corners: .allCorners)
Expand Down
Loading
Loading