-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement watchlist signals approve view
- Loading branch information
Showing
10 changed files
with
206 additions
and
33 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
Binary file modified
BIN
-21 Bytes
(95%)
...llet/UnstoppableWallet/Assets.xcassets/Icons/check_2_24.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-29 Bytes
(95%)
...llet/UnstoppableWallet/Assets.xcassets/Icons/check_2_24.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
37 changes: 37 additions & 0 deletions
37
...oppableWallet/UnstoppableWallet/Modules/Market/Watchlist/MarketWatchlistSignalBadge.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,37 @@ | ||
import MarketKit | ||
import SwiftUI | ||
|
||
struct MarketWatchlistSignalBadge: View { | ||
let signal: TechnicalAdvice.Advice | ||
|
||
var body: some View { | ||
Text(signal.searchTitle) | ||
.font(.themeMicroSB) | ||
.foregroundColor(foregroundColor) | ||
.padding(.horizontal, .margin6) | ||
.padding(.vertical, .margin2) | ||
.background(RoundedRectangle(cornerRadius: .cornerRadius8, style: .continuous).fill(backgroundColor)) | ||
.clipShape(RoundedRectangle(cornerRadius: .cornerRadius8, style: .continuous)) | ||
} | ||
|
||
private var foregroundColor: Color { | ||
switch signal { | ||
case .neutral: return .themeBran | ||
case .buy: return .themeRemus | ||
case .sell: return .themeLucian | ||
case .strongBuy, .strongSell: return .themeTyler | ||
case .overbought, .oversold: return .themeJacob | ||
} | ||
} | ||
|
||
private var backgroundColor: Color { | ||
switch signal { | ||
case .neutral: return .themeSteel20 | ||
case .buy: return .themeGreen.opacity(0.2) | ||
case .sell: return .themeRed.opacity(0.2) | ||
case .strongBuy: return .themeRemus | ||
case .strongSell: return .themeLucian | ||
case .overbought, .oversold: return .themeYellow20 | ||
} | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
...oppableWallet/UnstoppableWallet/Modules/Market/Watchlist/MarketWatchlistSignalsView.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,121 @@ | ||
import MarketKit | ||
import SwiftUI | ||
|
||
struct MarketWatchlistSignalsView: View { | ||
@ObservedObject var viewModel: MarketWatchlistViewModel | ||
@Binding var isPresented: Bool | ||
|
||
@State private var maxBadgeWidth: CGFloat = .zero | ||
@State private var doNotShowAgain = false | ||
|
||
var body: some View { | ||
ThemeNavigationView { | ||
ThemeView { | ||
BottomGradientWrapper { | ||
ScrollView { | ||
VStack(spacing: .margin16) { | ||
Text("market.watchlist.signals.description".localized) | ||
.themeSubhead2() | ||
.padding(EdgeInsets(top: 0, leading: .margin16, bottom: .margin8, trailing: .margin16)) | ||
|
||
ListSection { | ||
row(signal: .strongBuy) | ||
row(signal: .buy) | ||
row(signal: .neutral) | ||
row(signal: .sell) | ||
row(signal: .strongSell) | ||
row(signal: .overbought) | ||
} | ||
.themeListStyle(.bordered) | ||
.onPreferenceChange(MaxWidthPreferenceKey.self) { | ||
maxBadgeWidth = $0 | ||
} | ||
|
||
HighlightedTextView(text: "market.watchlist.signals.warning".localized, style: .warning) | ||
|
||
ListSection { | ||
ClickableRow(action: { | ||
doNotShowAgain.toggle() | ||
}) { | ||
if doNotShowAgain { | ||
ZStack { | ||
Circle().fill(Color.themeJacob) | ||
Image("check_2_24").themeIcon(color: .themeDark) | ||
} | ||
.frame(width: .iconSize24, height: .iconSize24) | ||
} else { | ||
Circle() | ||
.fill(Color.themeSteel20) | ||
.frame(width: .iconSize24, height: .iconSize24) | ||
} | ||
|
||
Text("market.watchlist.signals.dont_show_again".localized).themeSubhead2(color: .themeLeah) | ||
} | ||
} | ||
.themeListStyle(.lawrence) | ||
} | ||
.padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16)) | ||
} | ||
} bottomContent: { | ||
Button(action: { | ||
viewModel.showSignals = true | ||
|
||
if doNotShowAgain { | ||
viewModel.signalsApproved = true | ||
} | ||
|
||
isPresented = false | ||
}) { | ||
Text("market.watchlist.signals.turn_on".localized) | ||
} | ||
.buttonStyle(PrimaryButtonStyle(style: .yellow)) | ||
} | ||
} | ||
.navigationTitle("market.watchlist.signals".localized) | ||
.navigationBarTitleDisplayMode(.inline) | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarTrailing) { | ||
Button("button.cancel".localized) { | ||
isPresented = false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@ViewBuilder private func row(signal: TechnicalAdvice.Advice) -> some View { | ||
ListRow { | ||
MarketWatchlistSignalBadge(signal: signal) | ||
.background( | ||
GeometryReader { geometry in | ||
Color.clear.preference(key: MaxWidthPreferenceKey.self, value: geometry.size.width) | ||
} | ||
.scaledToFill() | ||
) | ||
.frame(width: maxBadgeWidth) | ||
|
||
Text(description(signal: signal)).themeSubhead2(color: .themeLeah) | ||
} | ||
} | ||
|
||
private func description(signal: TechnicalAdvice.Advice) -> String { | ||
switch signal { | ||
case .neutral: return "market.watchlist.signals.neutral.description".localized | ||
case .buy: return "market.watchlist.signals.buy.description".localized | ||
case .sell: return "market.watchlist.signals.sell.description".localized | ||
case .strongBuy: return "market.watchlist.signals.strong_buy.description".localized | ||
case .strongSell: return "market.watchlist.signals.strong_sell.description".localized | ||
case .overbought, .oversold: return "market.watchlist.signals.risky.description".localized | ||
} | ||
} | ||
|
||
private struct MaxWidthPreferenceKey: PreferenceKey { | ||
static var defaultValue: CGFloat = .zero | ||
|
||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { | ||
let nextValue = nextValue() | ||
guard nextValue > value else { return } | ||
value = nextValue | ||
} | ||
} | ||
} |
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