Skip to content

Commit

Permalink
Questionmarks if value is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantelis Giazitsis committed May 24, 2024
1 parent f26caeb commit e064a76
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Foundation
import DomainLayer

extension NetworkStationsStatsTokens {
var supplyProgress: CGFloat {
var supplyProgress: CGFloat? {
guard let totalSupply, let circulatingSupply else {
return 0.0
return nil
}

return CGFloat(circulatingSupply) / CGFloat(totalSupply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ extension NetworkStatsViewModel {
return nil
}
let total = NetworkStatsView.AdditionalStats(title: LocalizableString.total(nil).localized,
value: dataDays.last?.value?.toCompactDecimaFormat ?? "",
value: dataDays.last?.value?.toCompactDecimaFormat ?? "?",
color: .text,
accessory: nil,
analyticsItemId: nil)

let count = dataDays.count
let lastDataDayValue = dataDays.last?.value ?? 0.0
let preLastDataDayValue = dataDays[safe: count - 2]?.value ?? 0.0
let value = (lastDataDayValue - preLastDataDayValue).toCompactDecimaFormat ?? ""
let value = (lastDataDayValue - preLastDataDayValue).toCompactDecimaFormat ?? "?"
let preLastDay = NetworkStatsView.AdditionalStats(title: LocalizableString.NetStats.lastRun.localized,
value: "+\(value)",
color: .reward_score_very_high,
Expand All @@ -52,14 +52,14 @@ extension NetworkStatsViewModel {
}
let totalValue = tokens.totalAllocated
let total = NetworkStatsView.AdditionalStats(title: LocalizableString.total(nil).localized,
value: totalValue?.toCompactDecimaFormat ?? "",
value: totalValue?.toCompactDecimaFormat ?? "?",
accessory: nil,
analyticsItemId: nil)

let count = allocatedPerDay.count
let lastTokenValue = allocatedPerDay.last?.value ?? 0.0
let preLastTokenValue = allocatedPerDay[safe: count - 2]?.value ?? 0.0
let value = (lastTokenValue - preLastTokenValue).toCompactDecimaFormat ?? ""
let value = (lastTokenValue - preLastTokenValue).toCompactDecimaFormat ?? "?"
let lastDay = NetworkStatsView.AdditionalStats(title: LocalizableString.NetStats.lastRun.localized,
value: "+\(value)",
color: .reward_score_very_high,
Expand Down Expand Up @@ -95,12 +95,12 @@ extension NetworkStatsViewModel {

}

func getTokenStatistics(response: NetworkStatsResponse?) -> NetworkStatsView.Statistics? {
guard let tokens = response?.tokens else {
return nil
}
func getTokenStatistics(response: NetworkStatsResponse?) -> NetworkStatsView.Statistics? {
guard let tokens = response?.tokens else {
return nil
}

let totalSupplyValue = tokens.totalSupply?.toCompactDecimaFormat ?? ""
let totalSupplyValue = tokens.totalSupply?.toCompactDecimaFormat ?? "?"
let totalSupply = NetworkStatsView.AdditionalStats(title: LocalizableString.NetStats.totalSupply.localized,
value: totalSupplyValue,
accessory: .init(fontIcon: .infoCircle) { [weak self] in
Expand All @@ -110,10 +110,10 @@ extension NetworkStatsViewModel {
},
analyticsItemId: .totalSupply)

let circulatingSupplyValue = tokens.circulatingSupply?.toCompactDecimaFormat ?? ""
let circulatingSupplyValue = tokens.circulatingSupply?.toCompactDecimaFormat ?? "?"
let circulatingSupply = NetworkStatsView.AdditionalStats(title: LocalizableString.NetStats.circulatingSupply.localized,
value: circulatingSupplyValue,
accessory: .init(fontIcon: .infoCircle) { [weak self] in
value: circulatingSupplyValue,
accessory: .init(fontIcon: .infoCircle) { [weak self] in
self?.showInfo(title: LocalizableString.NetStats.circulatingSupply.localized,
description: LocalizableString.NetStats.circulatingSupplyInfoText.localized,
analyticsItemId: .circulatingSupply)
Expand All @@ -126,15 +126,15 @@ extension NetworkStatsViewModel {
tokenDescription = LocalizableString.NetStats.wxmTokenDescriptionMarkdown(tokenUrl).localized.attributedMarkdown
}

return getStatistics(from: nil,
title: LocalizableString.NetStats.wxmTokenTitle.localized,
return getStatistics(from: nil,
title: LocalizableString.NetStats.wxmTokenTitle.localized,
description: tokenDescription,
showExternalLinkIcon: true,
externalLinkTapAction: { Logger.shared.trackEvent(.selectContent, parameters: [.contentType: .tokenContract]) },
accessory: nil,
additionalStats: [totalSupply, circulatingSupply],
analyticsItemId: nil)
}
showExternalLinkIcon: true,
externalLinkTapAction: { Logger.shared.trackEvent(.selectContent, parameters: [.contentType: .tokenContract]) },
accessory: nil,
additionalStats: [totalSupply, circulatingSupply],
analyticsItemId: nil)
}

func getStationStats(response: NetworkStatsResponse?) -> [NetworkStatsView.StationStatistics]? {
let total = (LocalizableString.total(nil).localized,
Expand Down

0 comments on commit e064a76

Please sign in to comment.