diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Analytics/CoinAnalyticsViewModelNew.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Analytics/CoinAnalyticsViewModelNew.swift index 8498e70bd4..eedbfc4b1e 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Analytics/CoinAnalyticsViewModelNew.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Analytics/CoinAnalyticsViewModelNew.swift @@ -5,7 +5,7 @@ import HsExtensions import MarketKit class CoinAnalyticsViewModelNew: ObservableObject { - private let fullCoin: FullCoin + let coin: Coin private let marketKit = App.shared.marketKit private let currencyManager = App.shared.currencyManager private var tasks = Set() @@ -32,8 +32,8 @@ class CoinAnalyticsViewModelNew: ObservableObject { return formatter }() - init(fullCoin: FullCoin) { - self.fullCoin = fullCoin + init(coin: Coin) { + self.coin = coin } private func handle(analytics: Analytics) async { @@ -140,7 +140,7 @@ class CoinAnalyticsViewModelNew: ObservableObject { reports: data.reports ? .preview : nil, investors: data.fundsInvested ? .preview : nil, treasuries: data.treasuries ? .preview : nil, - audits: auditAddresses != nil ? .preview : nil, + audits: nil, issueBlockchains: nil ) } @@ -186,7 +186,7 @@ class CoinAnalyticsViewModelNew: ObservableObject { if let value { switch postfix { case .currency: valueString = ValueFormatter.instance.formatShort(currency: currency, value: value) - case .coin: valueString = ValueFormatter.instance.formatShort(value: value).map { [$0, fullCoin.coin.code].joined(separator: " ") } + case .coin: valueString = ValueFormatter.instance.formatShort(value: value).map { [$0, coin.code].joined(separator: " ") } case .noPostfix: valueString = ValueFormatter.instance.formatShort(value: value) } } @@ -218,7 +218,7 @@ class CoinAnalyticsViewModelNew: ObservableObject { return TransactionCountViewItem( chart: .regular(value: chartViewItem), - volume: volume.flatMap { ValueFormatter.instance.formatShort(value: $0) }.map { .regular(value: [$0, fullCoin.coin.code].joined(separator: " ")) }, + volume: volume.flatMap { ValueFormatter.instance.formatShort(value: $0) }.map { .regular(value: [$0, coin.code].joined(separator: " ")) }, rank: rank.map { .regular(value: rankString(value: $0)) }, rating: rating.flatMap { CoinAnalyticsModule.Rating(rawValue: $0) }.map { .regular(value: $0) } ) @@ -340,18 +340,6 @@ class CoinAnalyticsViewModelNew: ObservableObject { return [] } } - - private var auditAddresses: [String]? { - let addresses = fullCoin.tokens.compactMap { token in - switch (token.blockchainType, token.type) { - case let (.ethereum, .eip20(address)): return address - case let (.binanceSmartChain, .eip20(address)): return address - default: return nil - } - } - - return addresses.isEmpty ? nil : addresses - } } extension CoinAnalyticsViewModelNew { @@ -359,22 +347,18 @@ extension CoinAnalyticsViewModelNew { currencyManager.baseCurrency } - var coin: Coin { - fullCoin.coin - } - func load() { tasks = Set() state = .loading - Task { [weak self, isPurchased, marketKit, fullCoin, currency] in + Task { [weak self, isPurchased, marketKit, coin, currency] in do { if isPurchased { - let analytics = try await marketKit.analytics(coinUid: fullCoin.coin.uid, currencyCode: currency.code) + let analytics = try await marketKit.analytics(coinUid: coin.uid, currencyCode: currency.code) await self?.handle(analytics: analytics) } else { - let analyticsPreview = try await marketKit.analyticsPreview(coinUid: fullCoin.coin.uid) + let analyticsPreview = try await marketKit.analyticsPreview(coinUid: coin.uid) await self?.handle(analyticsPreview: analyticsPreview) } } catch { diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinMarkets/CoinMarketsViewModel.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinMarkets/CoinMarketsViewModel.swift index 162c28aee0..2b2a760075 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinMarkets/CoinMarketsViewModel.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinMarkets/CoinMarketsViewModel.swift @@ -4,7 +4,7 @@ import HsExtensions import MarketKit class CoinMarketsViewModel: ObservableObject { - private let coin: Coin + private let coinUid: String private let marketKit = App.shared.marketKit private let currency = App.shared.currencyManager.baseCurrency private var tasks = Set() @@ -27,8 +27,8 @@ class CoinMarketsViewModel: ObservableObject { @Published var filterTypeInfo = SelectorButtonInfo(text: "", count: 0, selectedIndex: 0) - init(coin: Coin) { - self.coin = coin + init(coinUid: String) { + self.coinUid = coinUid syncFilterTypeInfo() } @@ -40,9 +40,9 @@ class CoinMarketsViewModel: ObservableObject { state = .loading } - Task { [weak self, marketKit, coin, currency] in + Task { [weak self, marketKit, coinUid, currency] in do { - let tickers = try await marketKit.marketTickers(coinUid: coin.uid, currencyCode: currency.code) + let tickers = try await marketKit.marketTickers(coinUid: coinUid, currencyCode: currency.code) self?.tickers = tickers self?.syncState() } catch { diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageModule.swift index d85df16dd7..e1695d11cf 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageModule.swift @@ -64,15 +64,3 @@ extension CoinPageModule { } } } - -struct CoinPageViewNew: UIViewControllerRepresentable { - typealias UIViewControllerType = UIViewController - - let coinUid: String - - func makeUIViewController(context _: Context) -> UIViewController { - CoinPageModule.viewController(coinUid: coinUid) ?? UIViewController() - } - - func updateUIViewController(_: UIViewController, context _: Context) {} -} diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageView.swift index bc541798ff..79272c9c3e 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageView.swift @@ -14,12 +14,12 @@ struct CoinPageView: View { @State private var currentTab: Tab = .overview @State private var loadedTabs = [Tab]() - init(fullCoin: FullCoin) { - _viewModel = StateObject(wrappedValue: CoinPageViewModelNew(fullCoin: fullCoin)) - _overviewViewModel = StateObject(wrappedValue: CoinOverviewViewModelNew(coinUid: fullCoin.coin.uid)) - _chartViewModel = StateObject(wrappedValue: CoinChartViewModel.instance(coinUid: fullCoin.coin.uid)) - _analyticsViewModel = StateObject(wrappedValue: CoinAnalyticsViewModelNew(fullCoin: fullCoin)) - _marketsViewModel = StateObject(wrappedValue: CoinMarketsViewModel(coin: fullCoin.coin)) + init(coin: Coin) { + _viewModel = StateObject(wrappedValue: CoinPageViewModelNew(coin: coin)) + _overviewViewModel = StateObject(wrappedValue: CoinOverviewViewModelNew(coinUid: coin.uid)) + _chartViewModel = StateObject(wrappedValue: CoinChartViewModel.instance(coinUid: coin.uid)) + _analyticsViewModel = StateObject(wrappedValue: CoinAnalyticsViewModelNew(coin: coin)) + _marketsViewModel = StateObject(wrappedValue: CoinMarketsViewModel(coinUid: coin.uid)) } var body: some View { @@ -54,7 +54,7 @@ struct CoinPageView: View { } } } - .navigationTitle(viewModel.fullCoin.coin.code) + .navigationTitle(viewModel.coin.code) .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarLeading) { diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageViewModelNew.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageViewModelNew.swift index 31cce644a9..d021fdd806 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageViewModelNew.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/CoinPageViewModelNew.swift @@ -3,24 +3,24 @@ import ComponentKit import MarketKit class CoinPageViewModelNew: ObservableObject { - let fullCoin: FullCoin + let coin: Coin private let watchlistManager = App.shared.watchlistManager @Published var isFavorite: Bool { didSet { if isFavorite { - watchlistManager.add(coinUid: fullCoin.coin.uid) + watchlistManager.add(coinUid: coin.uid) HudHelper.instance.show(banner: .addedToWatchlist) } else { - watchlistManager.remove(coinUid: fullCoin.coin.uid) + watchlistManager.remove(coinUid: coin.uid) HudHelper.instance.show(banner: .removedFromWatchlist) } } } - init(fullCoin: FullCoin) { - self.fullCoin = fullCoin + init(coin: Coin) { + self.coin = coin - isFavorite = watchlistManager.isWatched(coinUid: fullCoin.coin.uid) + isFavorite = watchlistManager.isWatched(coinUid: coin.uid) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Rank/RankView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Rank/RankView.swift index 81f2ccd678..a9aac1230d 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Rank/RankView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Coin/Rank/RankView.swift @@ -59,7 +59,7 @@ struct RankView: View { } } .sheet(item: $presentedCoin) { coin in - CoinPageViewNew(coinUid: coin.uid).ignoresSafeArea() + CoinPageView(coin: coin) .onFirstAppear { stat(page: viewModel.type.statRankType, event: .openCoin(coinUid: coin.uid)) } } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Main/Workers/WidgetCoinAppShowWorker/WidgetCoinAppShowModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Main/Workers/WidgetCoinAppShowWorker/WidgetCoinAppShowModule.swift index 4000453215..1fa10ad83f 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Main/Workers/WidgetCoinAppShowWorker/WidgetCoinAppShowModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Main/Workers/WidgetCoinAppShowWorker/WidgetCoinAppShowModule.swift @@ -2,6 +2,7 @@ import UIKit class WidgetCoinAppShowModule { private let parentViewController: UIViewController? + private let marketKit = App.shared.marketKit init(parentViewController: UIViewController?) { self.parentViewController = parentViewController @@ -16,6 +17,7 @@ extension WidgetCoinAppShowModule: IEventHandler { } var coinUid: String? + switch event { case let event as String: coinUid = event @@ -26,11 +28,13 @@ extension WidgetCoinAppShowModule: IEventHandler { default: () } - guard let coinUid, let viewController = CoinPageModule.viewController(coinUid: coinUid) else { + guard let coinUid, let coin = try? marketKit.fullCoins(coinUids: [coinUid]).first?.coin else { throw EventHandler.HandleError.noSuitableHandler } + let viewController = CoinPageView(coin: coin).toViewController() parentViewController?.visibleController.present(viewController, animated: true) + stat(page: .widget, event: .openCoin(coinUid: coinUid)) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/AdvancedSearch/MarketAdvancedSearchResultsView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/AdvancedSearch/MarketAdvancedSearchResultsView.swift index f10fc9465a..5a29d48610 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/AdvancedSearch/MarketAdvancedSearchResultsView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/AdvancedSearch/MarketAdvancedSearchResultsView.swift @@ -8,7 +8,7 @@ struct MarketAdvancedSearchResultsView: View { @Binding var isParentPresented: Bool @State private var sortBySelectorPresented = false - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? init(marketInfos: [MarketInfo], timePeriod: HsTimePeriod, isParentPresented: Binding) { _viewModel = StateObject(wrappedValue: MarketAdvancedSearchResultsViewModel(marketInfos: marketInfos, timePeriod: timePeriod)) @@ -26,7 +26,7 @@ struct MarketAdvancedSearchResultsView: View { let coin = marketInfo.fullCoin.coin ClickableRow(action: { - presentedFullCoin = marketInfo.fullCoin + presentedCoin = coin }) { itemContent( coin: coin, @@ -51,9 +51,9 @@ struct MarketAdvancedSearchResultsView: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() - .onFirstAppear { stat(page: .advancedSearchResults, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin).ignoresSafeArea() + .onFirstAppear { stat(page: .advancedSearchResults, event: .openCoin(coinUid: coin.uid)) } } .alert( isPresented: $sortBySelectorPresented, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Coins/MarketCoinsView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Coins/MarketCoinsView.swift index 6e7f626de7..61effcbdcf 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Coins/MarketCoinsView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Coins/MarketCoinsView.swift @@ -10,7 +10,7 @@ struct MarketCoinsView: View { @State private var topSelectorPresented = false @State private var timePeriodSelectorPresented = false - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? var body: some View { ThemeView { @@ -33,9 +33,9 @@ struct MarketCoinsView: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageView(fullCoin: fullCoin) - .onFirstAppear { stat(page: .markets, section: .coins, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) + .onFirstAppear { stat(page: .markets, section: .coins, event: .openCoin(coinUid: coin.uid)) } } } @@ -113,7 +113,7 @@ struct MarketCoinsView: View { let coin = marketInfo.fullCoin.coin ClickableRow(action: { - presentedFullCoin = marketInfo.fullCoin + presentedCoin = coin }) { itemContent( coin: coin, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/MarketCap/MarketMarketCapView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/MarketCap/MarketMarketCapView.swift index 96bd014e1a..e7eaed3656 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/MarketCap/MarketMarketCapView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/MarketCap/MarketMarketCapView.swift @@ -8,7 +8,7 @@ struct MarketMarketCapView: View { @StateObject var watchlistViewModel: WatchlistViewModel @Binding var isPresented: Bool - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? init(isPresented: Binding) { _viewModel = StateObject(wrappedValue: MarketMarketCapViewModel()) @@ -63,9 +63,9 @@ struct MarketMarketCapView: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() - .onFirstAppear { stat(page: .globalMetricsMarketCap, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) + .onFirstAppear { stat(page: .globalMetricsMarketCap, event: .openCoin(coinUid: coin.uid)) } } } } @@ -115,7 +115,7 @@ struct MarketMarketCapView: View { let coin = marketInfo.fullCoin.coin ClickableRow(action: { - presentedFullCoin = marketInfo.fullCoin + presentedCoin = coin }) { itemContent( coin: coin, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Platform/MarketPlatformViewNew.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Platform/MarketPlatformViewNew.swift index ff7bd08ea5..47272b5b71 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Platform/MarketPlatformViewNew.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Platform/MarketPlatformViewNew.swift @@ -9,7 +9,7 @@ struct MarketPlatformViewNew: View { @Binding var isPresented: Bool @State private var sortBySelectorPresented = false - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? init(isPresented: Binding, platform: TopPlatform) { _viewModel = StateObject(wrappedValue: MarketPlatformViewModel(platform: platform)) @@ -63,9 +63,9 @@ struct MarketPlatformViewNew: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() - .onFirstAppear { stat(page: .globalMetricsTvlInDefi, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) + .onFirstAppear { stat(page: .globalMetricsTvlInDefi, event: .openCoin(coinUid: coin.uid)) } } } } @@ -128,7 +128,7 @@ struct MarketPlatformViewNew: View { let coin = marketInfo.fullCoin.coin ClickableRow(action: { - presentedFullCoin = marketInfo.fullCoin + presentedCoin = coin }) { itemContent( coin: coin, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Search/MarketSearchView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Search/MarketSearchView.swift index 6b8c83f8ef..ea733803d1 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Search/MarketSearchView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Search/MarketSearchView.swift @@ -7,7 +7,7 @@ struct MarketSearchView: View { @ObservedObject var viewModel: MarketSearchViewModel @ObservedObject var watchlistViewModel: WatchlistViewModel - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? var body: some View { ThemeView { @@ -40,8 +40,8 @@ struct MarketSearchView: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) } } @@ -50,7 +50,7 @@ struct MarketSearchView: View { ClickableRow(action: { viewModel.handleOpen(coinUid: coin.uid) - presentedFullCoin = fullCoin + presentedCoin = coin }) { CoinIconView(coin: coin) diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Tvl/MarketTvlView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Tvl/MarketTvlView.swift index 0624a1a47b..7cd0288da1 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Tvl/MarketTvlView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Tvl/MarketTvlView.swift @@ -10,7 +10,7 @@ struct MarketTvlView: View { @Environment(\.presentationMode) private var presentationMode @State private var filterBySelectorPresented = false - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? init() { _viewModel = StateObject(wrappedValue: MarketTvlViewModel()) @@ -66,9 +66,9 @@ struct MarketTvlView: View { .onReceive(chartViewModel.$periodType) { periodType in viewModel.timePeriod = HsTimePeriod(periodType) ?? .day1 } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() - .onFirstAppear { stat(page: .globalMetricsTvlInDefi, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) + .onFirstAppear { stat(page: .globalMetricsTvlInDefi, event: .openCoin(coinUid: coin.uid)) } } } @@ -157,8 +157,9 @@ struct MarketTvlView: View { } case let .fullCoin(fullCoin): let coin = fullCoin.coin + ClickableRow(action: { - presentedFullCoin = fullCoin + presentedCoin = coin }) { itemContent( coin: coin, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Volume/MarketVolumeView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Volume/MarketVolumeView.swift index c2bda31409..9c3febc35e 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Volume/MarketVolumeView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Volume/MarketVolumeView.swift @@ -8,7 +8,7 @@ struct MarketVolumeView: View { @StateObject var watchlistViewModel: WatchlistViewModel @Binding var isPresented: Bool - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? init(isPresented: Binding) { _viewModel = StateObject(wrappedValue: MarketVolumeViewModel()) @@ -63,9 +63,9 @@ struct MarketVolumeView: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() - .onFirstAppear { stat(page: .globalMetricsVolume, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) + .onFirstAppear { stat(page: .globalMetricsVolume, event: .openCoin(coinUid: coin.uid)) } } } } @@ -115,7 +115,7 @@ struct MarketVolumeView: View { let coin = marketInfo.fullCoin.coin ClickableRow(action: { - presentedFullCoin = marketInfo.fullCoin + presentedCoin = coin }) { itemContent( coin: coin, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Watchlist/MarketWatchlistView.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Watchlist/MarketWatchlistView.swift index d4e0f74b00..f2f6941a5b 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Market/Watchlist/MarketWatchlistView.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Market/Watchlist/MarketWatchlistView.swift @@ -7,7 +7,7 @@ struct MarketWatchlistView: View { @State private var sortBySelectorPresented = false @State private var timePeriodSelectorPresented = false - @State private var presentedFullCoin: FullCoin? + @State private var presentedCoin: Coin? @State private var signalsPresented = false @State private var editMode: EditMode = .inactive @@ -37,9 +37,9 @@ struct MarketWatchlistView: View { } } } - .sheet(item: $presentedFullCoin) { fullCoin in - CoinPageViewNew(coinUid: fullCoin.coin.uid).ignoresSafeArea() - .onFirstAppear { stat(page: .markets, section: .watchlist, event: .openCoin(coinUid: fullCoin.coin.uid)) } + .sheet(item: $presentedCoin) { coin in + CoinPageView(coin: coin) + .onFirstAppear { stat(page: .markets, section: .watchlist, event: .openCoin(coinUid: coin.uid)) } } } @@ -142,7 +142,7 @@ struct MarketWatchlistView: View { let coin = marketInfo.fullCoin.coin ClickableRow(action: { - presentedFullCoin = marketInfo.fullCoin + presentedCoin = coin }) { itemContent( coin: coin, diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoModule.swift b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoModule.swift index f5f7402f31..70deb68c23 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoModule.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoModule.swift @@ -26,7 +26,7 @@ extension TransactionInfoModule { enum ViewItem { case actionTitle(iconName: String?, iconDimmed: Bool, title: String, subTitle: String?) - case amount(title: String, subtitle: String?, iconUrl: String?, iconPlaceholderImageName: String, coinAmount: String, currencyAmount: String?, type: AmountType, coinUid: String?) + case amount(title: String, subtitle: String?, iconUrl: String?, iconPlaceholderImageName: String, coinAmount: String, currencyAmount: String?, type: AmountType, coin: Coin?) case nftAmount(iconUrl: String?, iconPlaceholderImageName: String, nftAmount: String, type: AmountType, providerCollectionUid: String?, nftUid: NftUid?) case status(status: TransactionStatus) case option(option: Option) diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift index 92f98236ee..1416302738 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewController.swift @@ -1,4 +1,5 @@ import ComponentKit +import MarketKit import RxSwift import SafariServices import SectionsTableView @@ -98,14 +99,11 @@ class TransactionInfoViewController: ThemeViewController { } } - private func openCoin(coinUid: String) { - guard let module = CoinPageModule.viewController(coinUid: coinUid) else { - return - } - - present(module, animated: true) + private func open(coin: Coin) { + let viewController = CoinPageView(coin: coin).toViewController() + present(viewController, animated: true) - stat(page: .transactionInfo, event: .openCoin(coinUid: coinUid)) + stat(page: .transactionInfo, event: .openCoin(coinUid: coin.uid)) } private func openNftAsset(providerCollectionUid: String, nftUid: NftUid) { @@ -485,12 +483,12 @@ class TransactionInfoViewController: ThemeViewController { switch viewItem { case let .actionTitle(iconName, iconDimmed, title, subTitle): return CellComponent.actionTitleRow(tableView: tableView, rowInfo: rowInfo, iconName: iconName, iconDimmed: iconDimmed, title: title, value: subTitle ?? "") - case let .amount(title, subtitle, iconUrl, iconPlaceholderImageName, coinAmount, currencyAmount, type, coinUid): + case let .amount(title, subtitle, iconUrl, iconPlaceholderImageName, coinAmount, currencyAmount, type, coin): var action: (() -> Void)? - if let coinUid { + if let coin { action = { [weak self] in - self?.openCoin(coinUid: coinUid) + self?.open(coin: coin) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewItemFactory.swift b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewItemFactory.swift index 8f9fc89e22..fae7eb89ec 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewItemFactory.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/TransactionInfo/TransactionInfoViewItemFactory.swift @@ -30,7 +30,7 @@ class TransactionInfoViewItemFactory { coinAmount: balanceHidden ? BalanceHiddenManager.placeholder : "∞ \(transactionValue.coinCode)", currencyAmount: balanceHidden ? BalanceHiddenManager.placeholder : "transactions.value.unlimited".localized, type: type, - coinUid: transactionValue.coin?.uid + coin: transactionValue.coin ) } else { var currencyValue: CurrencyValue? @@ -47,7 +47,7 @@ class TransactionInfoViewItemFactory { coinAmount: balanceHidden ? BalanceHiddenManager.placeholder : transactionValue.formattedFull(signType: type.signType) ?? "n/a".localized, currencyAmount: balanceHidden ? BalanceHiddenManager.placeholder : currencyValue.flatMap { ValueFormatter.instance.formatFull(currencyValue: $0) }, type: type, - coinUid: transactionValue.coin?.uid + coin: transactionValue.coin ) } } diff --git a/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Token/DataSources/WalletTokenBalance/WalletTokenBalanceDataSource.swift b/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Token/DataSources/WalletTokenBalance/WalletTokenBalanceDataSource.swift index d9eb8deff4..1755b8b5cd 100644 --- a/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Token/DataSources/WalletTokenBalance/WalletTokenBalanceDataSource.swift +++ b/UnstoppableWallet/UnstoppableWallet/Modules/Wallet/Token/DataSources/WalletTokenBalance/WalletTokenBalanceDataSource.swift @@ -59,7 +59,7 @@ class WalletTokenBalanceDataSource: NSObject { viewModel.openCoinPagePublisher .receive(on: DispatchQueue.main) .sink { [weak self] in - self?.openCoinPage(coinUid: $0.uid) + self?.openCoinPage(coin: $0) } .store(in: &cancellables) @@ -208,11 +208,11 @@ class WalletTokenBalanceDataSource: NSObject { stat(page: .tokenPage, event: .openReceive(token: wallet.token)) } - private func openCoinPage(coinUid: String) { - if let viewController = CoinPageModule.viewController(coinUid: coinUid) { - parentViewController?.present(viewController, animated: true) - stat(page: .tokenPage, event: .openCoin(coinUid: coinUid)) - } + private func openCoinPage(coin: Coin) { + let viewController = CoinPageView(coin: coin).toViewController() + parentViewController?.present(viewController, animated: true) + + stat(page: .tokenPage, event: .openCoin(coinUid: coin.uid)) } private func openBackupRequired(wallet: Wallet) {