-
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.
add rewards card to profile landing screen
- Loading branch information
Showing
7 changed files
with
129 additions
and
2 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
31 changes: 31 additions & 0 deletions
31
...ydxPresenters/dydxPresenters/_v4/Profile/Components/dydxProfileRewardsViewPresenter.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,31 @@ | ||
// | ||
// dydxProfileRewardsViewPresenter.swift | ||
// dydxPresenters | ||
// | ||
// Created by Rui Huang on 9/18/23. | ||
// | ||
|
||
import Utilities | ||
import dydxViews | ||
import PlatformParticles | ||
import RoutingKit | ||
import ParticlesKit | ||
import PlatformUI | ||
import Abacus | ||
import dydxStateManager | ||
import dydxFormatter | ||
import Combine | ||
|
||
public protocol dydxProfileRewardsViewPresenterProtocol: HostedViewPresenterProtocol { | ||
var viewModel: dydxProfileRewardsViewModel? { get } | ||
} | ||
|
||
public class dydxProfileRewardsViewPresenter: HostedViewPresenter<dydxProfileRewardsViewModel>, dydxProfileRewardsViewPresenterProtocol { | ||
override init() { | ||
super.init() | ||
|
||
viewModel = dydxProfileRewardsViewModel() | ||
viewModel?.last7DaysRewardsAmount = "PLACEHOLDER" | ||
viewModel?.allTimeRewardsAmount = "PLACEHOLDER" | ||
} | ||
} |
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
87 changes: 87 additions & 0 deletions
87
dydx/dydxViews/dydxViews/_v4/Profile/Components/dydxProfileRewardsViewModel.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,87 @@ | ||
// | ||
// dydxProfileRewardsViewModel.swift | ||
// dydxUI | ||
// | ||
// Created by Rui Huang on 9/18/23. | ||
// Copyright © 2023 dYdX Trading Inc. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import PlatformUI | ||
import Utilities | ||
|
||
public class dydxProfileRewardsViewModel: dydxTitledCardViewModel { | ||
@Published public var last7DaysRewardsAmount: String? | ||
@Published public var allTimeRewardsAmount: String? | ||
|
||
public init() { | ||
super.init(title: DataLocalizer.shared?.localize(path: "APP.GENERAL.TRADING_REWARDS", params: nil) ?? "") | ||
} | ||
|
||
override func createContent(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) | ||
titleValueStack(title: DataLocalizer.shared?.localize(path: "APP.PROFILES_PAGE.REWARDS_ALL_TIME", params: nil) ?? "", value: allTimeRewardsAmount) | ||
} | ||
Spacer() | ||
} | ||
.wrappedInAnyView() | ||
} | ||
|
||
private func titleValueStack(title: String, value: String?) -> some View { | ||
VStack(alignment: .leading, spacing: 4) { | ||
Text(title) | ||
.themeColor(foreground: .textTertiary) | ||
.themeFont(fontType: .text, fontSize: .smaller) | ||
HStack(spacing: 6) { | ||
Text(value ?? "-") | ||
.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() | ||
} | ||
} | ||
|
||
} | ||
|
||
public static var previewValue: dydxProfileRewardsViewModel { | ||
let vm = dydxProfileRewardsViewModel() | ||
vm.last7DaysRewardsAmount = "20.00" | ||
vm.allTimeRewardsAmount = "30.00" | ||
return vm | ||
} | ||
|
||
} | ||
|
||
#if DEBUG | ||
struct dydxProfileRewardsViewModel_Previews_Dark: PreviewProvider { | ||
@StateObject static var themeSettings = ThemeSettings.shared | ||
|
||
static var previews: some View { | ||
ThemeSettings.applyDarkTheme() | ||
ThemeSettings.applyStyles() | ||
return dydxProfileRewardsViewModel.previewValue | ||
.createView() | ||
.themeColor(background: .layer0) | ||
.environmentObject(themeSettings) | ||
// .edgesIgnoringSafeArea(.bottom) | ||
.previewLayout(.sizeThatFits) | ||
} | ||
} | ||
|
||
struct dydxProfileRewardsViewModel_Previews_Light: PreviewProvider { | ||
@StateObject static var themeSettings = ThemeSettings.shared | ||
|
||
static var previews: some View { | ||
ThemeSettings.applyLightTheme() | ||
ThemeSettings.applyStyles() | ||
return dydxProfileRewardsViewModel.previewValue | ||
.createView() | ||
.themeColor(background: .layer0) | ||
.environmentObject(themeSettings) | ||
// .edgesIgnoringSafeArea(.bottom) | ||
.previewLayout(.sizeThatFits) | ||
} | ||
} | ||
#endif |
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