Skip to content

Commit

Permalink
Migrate MarketAdvancedSearch module to SwiftUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Jun 3, 2024
1 parent c2f3a19 commit 5e5206f
Show file tree
Hide file tree
Showing 26 changed files with 848 additions and 1,434 deletions.
66 changes: 33 additions & 33 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SettingsBackup: Codable {
case balanceAutoHide = "balance_auto_hide"
case appIcon = "app_icon"
}

init(
evmSyncSources: EvmSyncSourceManager.SyncSourceBackup,
btcModes: [BtcBlockchainManager.BtcRestoreModeBackup],
Expand All @@ -60,24 +60,25 @@ class SettingsBackup: Codable {
balanceHideButtons: Bool,
balancePrimaryValue: BalancePrimaryValue,
balanceAutoHide: Bool,
appIcon: String) {
self.evmSyncSources = evmSyncSources
self.btcModes = btcModes
self.remoteContactsSync = remoteContactsSync
self.swapProviders = swapProviders
self.chartIndicators = chartIndicators
self.indicatorsShown = indicatorsShown
self.currentLanguage = currentLanguage
self.baseCurrency = baseCurrency
self.mode = mode
self.showMarketTab = showMarketTab
self.priceChangeMode = priceChangeMode
self.launchScreen = launchScreen
self.conversionTokenQueryId = conversionTokenQueryId
self.balanceHideButtons = balanceHideButtons
self.balancePrimaryValue = balancePrimaryValue
self.balanceAutoHide = balanceAutoHide
self.appIcon = appIcon
appIcon: String
) {
self.evmSyncSources = evmSyncSources
self.btcModes = btcModes
self.remoteContactsSync = remoteContactsSync
self.swapProviders = swapProviders
self.chartIndicators = chartIndicators
self.indicatorsShown = indicatorsShown
self.currentLanguage = currentLanguage
self.baseCurrency = baseCurrency
self.mode = mode
self.showMarketTab = showMarketTab
self.priceChangeMode = priceChangeMode
self.launchScreen = launchScreen
self.conversionTokenQueryId = conversionTokenQueryId
self.balanceHideButtons = balanceHideButtons
self.balancePrimaryValue = balancePrimaryValue
self.balanceAutoHide = balanceAutoHide
self.appIcon = appIcon
}

required init(from decoder: Decoder) throws {
Expand All @@ -100,7 +101,6 @@ class SettingsBackup: Codable {
balanceAutoHide = try container.decode(Bool.self, forKey: .balanceAutoHide)
appIcon = try container.decode(String.self, forKey: .appIcon)
}

}

extension SettingsBackup {
Expand Down
18 changes: 18 additions & 0 deletions UnstoppableWallet/UnstoppableWallet/Extensions/Advice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import MarketKit

extension TechnicalAdvice.Advice: Identifiable {
public var id: Self {
self
}

var shortTitle: String {
switch self {
case .oversold, .overbought: return "market.signal.risky".localized
case .strongBuy: return "market.signal.strong_buy".localized
case .buy: return "market.signal.buy".localized
case .neutral: return "market.signal.neutral".localized
case .sell: return "market.signal.sell".localized
case .strongSell: return "market.signal.strong_sell".localized
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import MarketKit

extension HsTimePeriod: Identifiable {
public var id: String {
rawValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ extension HsTimePeriod {
extension MarketEtfViewModel.TimePeriod {
var statPeriod: StatPeriod {
switch self {
case .all: return .all
case let .period(timePeriod): return timePeriod.statPeriod
case .all: return .all
case let .period(timePeriod): return timePeriod.statPeriod
}
}
}
Expand Down Expand Up @@ -129,8 +129,11 @@ extension MarketModule.Top {
switch self {
case .top100: return .top100
case .top200: return .top200
case .top250: return .top250
case .top300: return .top300
case .top500: return .top500
case .top1000: return .top1000
case .top1500: return .top1500
}
}
}
Expand Down Expand Up @@ -223,8 +226,8 @@ extension MarketModule.MarketTvlField {
extension MarketTvlViewModel.DiffType {
var statField: String {
switch self {
case .percent: return "percent"
case .currencyValue: return "currency"
case .percent: return "percent"
case .currencyValue: return "currency"
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion UnstoppableWallet/UnstoppableWallet/Models/Stats.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ enum StatSection: String {
case watchlist
}

enum StatEvent {
enum StatEvent {
case add(entity: StatEntity)
case addEvmSource(chainUid: String)
case addToken(token: Token)
Expand Down Expand Up @@ -460,8 +460,11 @@ enum StatField: String {
enum StatMarketTop: String {
case top100
case top200
case top250
case top300
case top500
case top1000
case top1500
}

enum StatEntity: String {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import Kingfisher
import MarketKit
import SwiftUI

struct MarketAdvancedSearchBlockchainsView: View {
@ObservedObject var viewModel: MarketAdvancedSearchViewModel
@Binding var isPresented: Bool

var body: some View {
ThemeNavigationView {
ScrollableThemeView {
VStack(spacing: .margin24) {
ListSection {
ClickableRow {
viewModel.blockchains = Set()
} content: {
Text("selector.any".localized).themeBody(color: .themeGray)

if viewModel.blockchains.isEmpty {
Image("check_1_20").themeIcon(color: .themeJacob)
}
}

ForEach(viewModel.allBlockchains) { blockchain in
ClickableRow {
if viewModel.blockchains.contains(blockchain) {
viewModel.blockchains.remove(blockchain)
} else {
viewModel.blockchains.insert(blockchain)
}
} content: {
KFImage.url(URL(string: blockchain.type.imageUrl))
.resizable()
.placeholder { RoundedRectangle(cornerRadius: .cornerRadius8).fill(Color.themeSteel20) }
.clipShape(RoundedRectangle(cornerRadius: .cornerRadius8))
.frame(width: .iconSize32, height: .iconSize32)

Text(blockchain.name).themeBody()

if viewModel.blockchains.contains(blockchain) {
Image("check_1_20").themeIcon(color: .themeJacob)
}
}
}
}
}
.padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16))
}
.navigationTitle("market.advanced_search.blockchains".localized)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("button.done".localized) {
isPresented = false
}
}
}
}
}
}
Loading

0 comments on commit 5e5206f

Please sign in to comment.