-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI-638: prediction markets UI (#222)
* add feature flag * support filtering to prediction markets * add banner * comment * add feature flag to debug menu --------- Co-authored-by: Mike <[email protected]>
- Loading branch information
Showing
9 changed files
with
188 additions
and
16 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
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
75 changes: 75 additions & 0 deletions
75
dydx/dydxViews/dydxViews/_v4/Markets/Components/dydxMarketsBannerViewModel.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,75 @@ | ||
// | ||
// dydxMarketsHeaderView.swift | ||
// dydxViews | ||
// | ||
// Created by Rui Huang on 9/1/22. | ||
// Copyright © 2022 dYdX Trading Inc. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import PlatformUI | ||
import Utilities | ||
|
||
public class dydxMarketsBannerViewModel: PlatformViewModel { | ||
public var navigationAction: (() -> Void) | ||
|
||
static var previewValue: dydxMarketsBannerViewModel = { | ||
let vm = dydxMarketsBannerViewModel(navigationAction: {}) | ||
return vm | ||
}() | ||
|
||
public init(navigationAction: @escaping (() -> Void)) { | ||
self.navigationAction = navigationAction | ||
} | ||
|
||
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 dydxMarketsBannerView(viewModel: self) | ||
.wrappedInAnyView() | ||
} | ||
} | ||
} | ||
|
||
private struct dydxMarketsBannerView: View { | ||
var viewModel: dydxMarketsBannerViewModel | ||
|
||
var textStack: some View { | ||
HStack(alignment: .top, spacing: 6) { | ||
Text("🇺🇸") | ||
.themeFont(fontType: .base, fontSize: .medium) | ||
VStack(alignment: .leading, spacing: 4) { | ||
Text(localizerPathKey: "APP.PREDICTION_MARKET.LEVERAGE_TRADE_US_ELECTION_SHORT") | ||
.themeFont(fontType: .base, fontSize: .medium) | ||
.themeColor(foreground: .textPrimary) | ||
Text(localizerPathKey: "APP.PREDICTION_MARKET.WITH_PREDICTION_MARKETS") | ||
.themeFont(fontType: .base, fontSize: .small) | ||
.themeColor(foreground: .textSecondary) | ||
} | ||
} | ||
} | ||
|
||
var navButton: some View { | ||
Button(action: viewModel.navigationAction) { | ||
Text("→") | ||
.themeFont(fontType: .base, fontSize: .large) | ||
.themeColor(foreground: .textSecondary) | ||
.centerAligned() | ||
} | ||
.frame(width: 32, height: 32) | ||
.themeColor(background: .layer6) | ||
.borderAndClip(style: .circle, borderColor: .layer6) | ||
} | ||
|
||
var body: some View { | ||
HStack(spacing: 0) { | ||
textStack | ||
Spacer(minLength: 8) | ||
navButton | ||
} | ||
.padding(.horizontal, 16) | ||
.padding(.vertical, 12) | ||
.themeColor(background: .layer1) | ||
.clipShape(.rect(cornerRadius: 16)) | ||
} | ||
} |
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