Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 32 additions & 35 deletions Features/MarketInsight/Sources/Scenes/ChartScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GRDBQuery
import Store
import PrimitivesComponents
import Localization
import InfoSheet

public struct ChartScene: View {
@State private var model: ChartSceneViewModel
Expand Down Expand Up @@ -49,35 +50,10 @@ public struct ChartScene: View {
}

if let priceDataModel = model.priceDataModel {
if priceDataModel.showMarketValues {
Section {
ForEach(priceDataModel.marketValues, id: \.title) { link in
if let url = link.url {
SafariNavigationLink(url: url) {
ListItemView(title: link.title, subtitle: link.subtitle)
}
.contextMenu(
link.value.map { [.copy(value: $0)] } ?? []
)
} else {
ListItemView(
title: link.title,
titleTag: link.titleTag,
titleTagStyle: link.titleTagStyle ?? .body,
subtitle: link.subtitle
)
}
}
if model.hasMarketData {
NavigationCustomLink(
with: ListItemView(title: Localized.Wallet.more)
) {
model.onSelectPriceDetails()
}
}
}
}

marketSection(priceDataModel.marketValues)
marketSection(priceDataModel.supplyValues)
marketSection(priceDataModel.allTimeValues)

if priceDataModel.showLinks {
Section(Localized.Social.links) {
SocialLinksView(model: priceDataModel.linksViewModel)
Expand All @@ -94,13 +70,34 @@ public struct ChartScene: View {
}
.listSectionSpacing(.compact)
.navigationTitle(model.title)
.sheet(item: $model.isPresentingMarkets) { priceData in
NavigationStack {
AssetPriceDetailsView(
model: AssetPriceDetailsViewModel(priceData: priceData)
)
.sheet(item: $model.isPresentingInfoSheet) {
InfoSheetScene(type: $0)
}
}

private func marketSection(_ items: [MarketValueViewModel]) -> some View {
Section {
ForEach(items, id: \.title) { item in
if let url = item.url {
SafariNavigationLink(url: url) {
ListItemView(title: item.title, subtitle: item.subtitle)
}
.contextMenu(
item.value.map { [.copy(value: $0)] } ?? []
)
} else {
ListItemView(
title: item.title,
titleTag: item.titleTag,
titleTagStyle: item.titleTagStyle ?? .body,
titleExtra: item.titleExtra,
subtitle: item.subtitle,
subtitleExtra: item.subtitleExtra,
subtitleStyleExtra: item.subtitleExtraStyle ?? .calloutSecondary,
infoAction: item.infoSheetType.map { type in { model.isPresentingInfoSheet = type } }
)
}
}
.presentationBackground(Colors.grayBackground)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ struct AssetDetailsInfoViewModel {
}
}

var showMarketValues: Bool { !marketValues.isEmpty }

var marketValues: [MarketValueViewModel] {
guard let market else { return [contractViewModel].withValues() }
return [market.marketCap, market.circulatingSupply, market.totalSupply, contractViewModel].withValues()
return [contractViewModel, market.marketCap, market.tradingVolume, market.fdv].withValues()
}

var supplyValues: [MarketValueViewModel] {
guard let market else { return [] }
return [market.circulatingSupply, market.totalSupply, market.maxSupply].withValues()
}

var allTimeValues: [MarketValueViewModel] {
guard let market else { return [] }
return [market.allTimeHigh, market.allTimeLow].withValues()
}

var showLinks: Bool { !priceData.links.isEmpty }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Preferences
import PriceAlertService
import SwiftUI
import Formatters
import InfoSheet

@MainActor
@Observable
Expand All @@ -34,14 +35,13 @@ public final class ChartSceneViewModel {

var priceData: PriceData?
var priceRequest: PriceRequest
var isPresentingInfoSheet: InfoSheetType?

public var isPresentingSetPriceAlert: Binding<AssetId?>
var isPresentingMarkets: PriceData?

var title: String { assetModel.name }
var emptyTitle: String { Localized.Common.notAvailable }
var errorTitle: String { Localized.Errors.errorOccured }
var hasMarketData: Bool { priceData?.market != nil }

var priceAlertsViewModel: PriceAlertsViewModel { PriceAlertsViewModel(priceAlerts: priceData?.priceAlerts ?? []) }
var showPriceAlerts: Bool { priceAlertsViewModel.hasPriceAlerts && isPriceAvailable }
Expand Down Expand Up @@ -113,8 +113,4 @@ extension ChartSceneViewModel {
public func onSelectSetPriceAlerts() {
isPresentingSetPriceAlert.wrappedValue = assetModel.asset.id
}

public func onSelectPriceDetails() {
isPresentingMarkets = priceData
}
}
51 changes: 0 additions & 51 deletions Features/MarketInsight/Sources/Views/AssetPriceDetailsView.swift

This file was deleted.