Skip to content

Commit

Permalink
Fix watchlist widget and update signals texts
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed May 28, 2024
1 parent 6510487 commit 733e060
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ struct MarketWatchlistSignalsView: View {
@Binding var isPresented: Bool

@State private var maxBadgeWidth: CGFloat = .zero
@State private var doNotShowAgain = false

var body: some View {
ThemeNavigationView {
Expand All @@ -32,38 +31,12 @@ struct MarketWatchlistSignalsView: View {
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ struct MarketWatchlistView: View {
Button(action: {
if viewModel.showSignals {
viewModel.showSignals = false
} else if viewModel.signalsApproved {
viewModel.showSignals = true
} else {
signalsPresented = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import HsExtensions
import MarketKit

class MarketWatchlistViewModel: ObservableObject {
private let keySignalsApproved = "market-watchlist-signals-approved"

private let marketKit = App.shared.marketKit
private let currencyManager = App.shared.currencyManager
private let watchlistManager = App.shared.watchlistManager
Expand Down Expand Up @@ -45,17 +43,10 @@ class MarketWatchlistViewModel: ObservableObject {
}
}

var signalsApproved: Bool {
didSet {
userDefaultsStorage.set(value: true, for: keySignalsApproved)
}
}

init() {
sortBy = watchlistManager.sortBy
timePeriod = watchlistManager.timePeriod
showSignals = watchlistManager.showSignals
signalsApproved = userDefaultsStorage.value(for: keySignalsApproved) ?? false
}

private func syncCoinUids() {
Expand Down
15 changes: 7 additions & 8 deletions UnstoppableWallet/UnstoppableWallet/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -803,15 +803,14 @@
"market_watchlist.empty.caption" = "Your watchlist is empty.";
"market.watchlist.signals" = "Signals";
"market.watchlist.empty" = "Your watchlist is empty";
"market.watchlist.signals.description" = "Signals are based on the Bollinger Bands + RSI strategy to determine trading signals. All calculations are candlesticks and provide based on daily advice for a moderately long term.";
"market.watchlist.signals.strong_buy.description" = "High confidence in asset price growth.";
"market.watchlist.signals.buy.description" = "Indicates likely price increase in near future.";
"market.watchlist.signals.neutral.description" = "No clear trend, market is in equilibrium.";
"market.watchlist.signals.sell.description" = "Likely price decrease, considers current market conditions.";
"market.watchlist.signals.strong_sell.description" = "High probability of price decrease.";
"market.watchlist.signals.risky.description" = "Elevated risk level, requires cautious approach.";
"market.watchlist.signals.description" = "Below signals are based on the Bollinger Bands and RSI technical price indicators over approx. the last 30 days. These signals are algorithmic and can change frequently.";
"market.watchlist.signals.strong_buy.description" = "High confidence in price increase";
"market.watchlist.signals.buy.description" = "Likely price increase in near future";
"market.watchlist.signals.neutral.description" = "No clear trend, market is in equilibrium";
"market.watchlist.signals.sell.description" = "Likely price decrease in near future";
"market.watchlist.signals.strong_sell.description" = "High probability of price decrease";
"market.watchlist.signals.risky.description" = "Elevated risk level, requires caution";
"market.watchlist.signals.warning" = "Always remember to apply risk management, and note that this is not financial advice.";
"market.watchlist.signals.dont_show_again" = "Don't show it again";
"market.watchlist.signals.turn_on" = "Turn On";

"market.advanced_search.title" = "Filters";
Expand Down
9 changes: 8 additions & 1 deletion UnstoppableWallet/Widget/Watchlist/WatchlistProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ struct WatchlistProvider: TimelineProvider {
default: limit = 6
}

let coinUids = watchlistManager.coinUids
let coinUids: [String]

switch watchlistManager.sortBy {
case .manual:
coinUids = Array(watchlistManager.coinUids.prefix(limit))
default:
coinUids = watchlistManager.coinUids
}

let coins: [Coin]

Expand Down

0 comments on commit 733e060

Please sign in to comment.