-
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.
TRCL-3317 : Trading Rewards Detail Screen Rewards Summary Card (#37)
* add routing to trading rewards and trading rewards summary card * adjust for long value wrapping * remove unnecessary imports * clean up * add enable_trading_rewards feature flag
- Loading branch information
Showing
13 changed files
with
324 additions
and
8 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
24 changes: 24 additions & 0 deletions
24
.../dydxPresenters/_v4/Profile/TradingRewards/Components/dydxTradingRewardsViewBuilder.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,24 @@ | ||
// | ||
// dydxRewardsSummaryPresenter.swift | ||
// dydxPresenters | ||
// | ||
// Created by Michael Maguire on 12/4/23. | ||
// | ||
|
||
import dydxViews | ||
import PlatformParticles | ||
import ParticlesKit | ||
|
||
public protocol dydxRewardsSummaryPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxProfileRewardsViewModel? { get } | ||
} | ||
|
||
public class dydxRewardsSummaryViewPresenter: HostedViewPresenter<dydxProfileRewardsViewModel>, dydxProfileRewardsViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxProfileRewardsViewModel() | ||
viewModel?.last7DaysRewardsAmount = "PLACEHOLDER" | ||
viewModel?.allTimeRewardsAmount = "PLACEHOLDER" | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...resenters/dydxPresenters/_v4/Profile/TradingRewards/dydxTradingRewardsViewPresenter.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,45 @@ | ||
// | ||
// dydxTradingRewardsViewPresenter.swift | ||
// dydxPresenters | ||
// | ||
// Created by Michael Maguire on 12/4/23. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import RoutingKit | ||
import PlatformUI | ||
|
||
public class dydxTradingRewardsViewBuilder: NSObject, ObjectBuilderProtocol { | ||
public func build<T>() -> T? { | ||
let presenter = dydxTradingRewardsViewPresenter() | ||
let view = presenter.viewModel?.createView() ?? PlatformViewModel().createView() | ||
return dydxTradingRewardsViewController(presenter: presenter, view: view, configuration: .tabbarItemView) as? T | ||
} | ||
} | ||
|
||
private class dydxTradingRewardsViewController: HostingViewController<PlatformView, dydxTradingRewardsViewModel> { | ||
override public func arrive(to request: RoutingRequest?, animated: Bool) -> Bool { | ||
if request?.path == "/trading-rewards" { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
|
||
private protocol dydxTradingRewardsViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxTradingRewardsViewModel? { get } | ||
} | ||
|
||
private class dydxTradingRewardsViewPresenter: HostedViewPresenter<dydxTradingRewardsViewModel>, dydxTradingRewardsViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxTradingRewardsViewModel() | ||
|
||
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) | ||
} | ||
} | ||
} |
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
91 changes: 91 additions & 0 deletions
91
dydx/dydxViews/dydxViews/_v4/Profile/TradingRewards/Components/dydxRewardsSummaryView.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,91 @@ | ||
// | ||
// dydxRewardsSummaryView.swift | ||
// dydxViews | ||
// | ||
// Created by Michael Maguire on 12/4/23. | ||
// | ||
|
||
import SwiftUI | ||
import PlatformUI | ||
import Utilities | ||
|
||
public class dydxRewardsSummaryViewModel: dydxTitledCardViewModel { | ||
@Published public var last7DaysRewardsAmount: String? | ||
@Published public var last7DaysRewardsPeriod: String? | ||
@Published public var allTimeRewardsAmount: String? | ||
@Published public var allTimeRewardsValue: String? | ||
|
||
public init() { | ||
super.init(title: DataLocalizer.shared?.localize(path: "APP.GENERAL.TRADING_REWARDS_SUMMARY", params: nil) ?? "") | ||
} | ||
|
||
override func createContent(parentStyle: ThemeStyle = ThemeStyle.defaultStyle, styleKey: String? = nil) -> AnyView? { | ||
HStack(spacing: 18) { | ||
HStack { | ||
titleValueStack(title: DataLocalizer.shared?.localize(path: "APP.PROFILES_PAGE.REWARDS_LAST_7_DAYS", params: nil) ?? "", primaryValue: last7DaysRewardsAmount, secondaryValue: last7DaysRewardsPeriod) | ||
titleValueStack(title: DataLocalizer.shared?.localize(path: "APP.PROFILES_PAGE.REWARDS_ALL_TIME", params: nil) ?? "", primaryValue: last7DaysRewardsAmount, secondaryValue: allTimeRewardsValue) | ||
} | ||
} | ||
.wrappedInAnyView() | ||
} | ||
|
||
private func titleValueStack(title: String, primaryValue: String?, secondaryValue: String?) -> some View { | ||
VStack(alignment: .leading, spacing: 4) { | ||
Text(title) | ||
.themeColor(foreground: .textTertiary) | ||
.themeFont(fontType: .text, fontSize: .smaller) | ||
HStack(spacing: 6) { | ||
Text(primaryValue ?? "-") | ||
.themeColor(foreground: .textSecondary) | ||
.themeFont(fontType: .number, fontSize: .medium) | ||
PlatformIconViewModel(type: .asset(name: "icon_dydx", bundle: .dydxView), clip: .noClip, size: .init(width: 24, height: 24), templateColor: nil) | ||
.createView() | ||
} | ||
Text(secondaryValue ?? "-") | ||
.themeColor(foreground: .textTertiary) | ||
.themeFont(fontType: .text, fontSize: .small) | ||
} | ||
.leftAligned() | ||
|
||
} | ||
|
||
public static var previewValue: dydxRewardsSummaryViewModel { | ||
let vm = dydxRewardsSummaryViewModel() | ||
vm.last7DaysRewardsAmount = "20.00" | ||
vm.allTimeRewardsAmount = "30.00" | ||
return vm | ||
} | ||
|
||
} | ||
|
||
#if DEBUG | ||
struct dydxRewardsSummaryViewModel_Previews_Dark: PreviewProvider { | ||
@StateObject static var themeSettings = ThemeSettings.shared | ||
|
||
static var previews: some View { | ||
ThemeSettings.applyDarkTheme() | ||
ThemeSettings.applyStyles() | ||
return dydxRewardsSummaryViewModel.previewValue | ||
.createView() | ||
.themeColor(background: .layer0) | ||
.environmentObject(themeSettings) | ||
// .edgesIgnoringSafeArea(.bottom) | ||
.previewLayout(.sizeThatFits) | ||
} | ||
} | ||
|
||
struct dydxRewardsSummaryViewModel_Previews_Light: PreviewProvider { | ||
@StateObject static var themeSettings = ThemeSettings.shared | ||
|
||
static var previews: some View { | ||
ThemeSettings.applyLightTheme() | ||
ThemeSettings.applyStyles() | ||
return dydxRewardsSummaryViewModel.previewValue | ||
.createView() | ||
.themeColor(background: .layer0) | ||
.environmentObject(themeSettings) | ||
// .edgesIgnoringSafeArea(.bottom) | ||
.previewLayout(.sizeThatFits) | ||
} | ||
} | ||
#endif |
Oops, something went wrong.