Skip to content

Commit

Permalink
Fix small issues in Coin Page
Browse files Browse the repository at this point in the history
- Issues not shown in some coins
- Change blockchains sorting
  • Loading branch information
rafaelekol committed Apr 12, 2024
1 parent 512d43c commit 3d888d1
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModul
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.BoxItem.TitleWithInfo
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.BoxItem.Value
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.ChartViewItem
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.FooterType.DetectorFooterItem
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.FooterType.FooterItem
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.PreviewBlockViewItem
import io.horizontalsystems.bankwallet.modules.coin.analytics.CoinAnalyticsModule.PreviewChartType
Expand Down Expand Up @@ -419,6 +418,64 @@ class CoinAnalyticsViewModel(
)
)
}
analytics.issues?.let { issues ->
val detectorFooterItems = mutableListOf<CoinAnalyticsModule.FooterType.DetectorFooterItem>()

val sortedList = issues.mapNotNull {
val blockchain = service.blockchain(it.blockchain) ?: return@mapNotNull null
CoinAnalyticsModule.BlockchainAndIssues(blockchain, it)
}.sortedBy { it.blockchain.type.order }

sortedList.forEach { blockchainAndIssues ->
val blockchain = blockchainAndIssues.blockchain
val blockchainTitle = blockchain.name
val icon =
ImageSource.Remote(blockchain.type.imageUrl, R.drawable.coin_placeholder)
val blockchainIssues = blockchainAndIssues.issues
detectorFooterItems.add(
CoinAnalyticsModule.FooterType.DetectorFooterItem(
title = IconTitle(
icon,
TranslatableString.PlainString(blockchainTitle)
),
value = Value(
Translator.getString(
R.string.CoinAnalytics_CountItems,
blockchainIssues.issues.size
)
),
action = ActionType.OpenDetectorsDetails(
title = blockchainTitle,
issues = blockchainIssues.issues.map {
IssueParcelable(
issue = it.issue,
title = it.title,
description = it.description,
issues = it.issues?.map { issueItem ->
IssueItemParcelable(
impact = issueItem.impact,
confidence = issueItem.confidence,
description = issueItem.description.trim()
)
}
)
}
),
issues = getIssueSnippet(blockchainIssues.issues)
)
)
}
blocks.add(
BlockViewItem(
title = R.string.CoinAnalytics_SmartContractAnalysis,
info = null,
analyticChart = null,
footerItems = detectorFooterItems,
sectionDescription = Translator.getString(R.string.CoinAnalytics_PoweredByDeFi)
)
)
}

if (analytics.reports != null || analytics.fundsInvested != null || analytics.treasuries != null || analytics.audits != null) {
val footerItems = mutableListOf<FooterItem>()
analytics.reports?.let { reportsCount ->
Expand Down Expand Up @@ -449,58 +506,6 @@ class CoinAnalyticsViewModel(
)
}

analytics.issues?.let { issues ->
val detectorFooterItems = mutableListOf<DetectorFooterItem>()

val sortedList = issues.mapNotNull {
val blockchain = service.blockchain(it.blockchain) ?: return@mapNotNull null
CoinAnalyticsModule.BlockchainAndIssues(blockchain, it)
}.sortedBy { it.blockchain.type.order }

sortedList.forEach { blockchainAndIssues ->
val blockchain = blockchainAndIssues.blockchain
val blockchainTitle = blockchain.name
val icon = ImageSource.Remote(blockchain.type.imageUrl, R.drawable.coin_placeholder)
val blockchainIssues = blockchainAndIssues.issues
detectorFooterItems.add(
DetectorFooterItem(
title = IconTitle(
icon,
TranslatableString.PlainString(blockchainTitle)
),
value = Value(Translator.getString(R.string.CoinAnalytics_CountItems, blockchainIssues.issues.size)),
action = ActionType.OpenDetectorsDetails(
title = blockchainTitle,
issues = blockchainIssues.issues.map {
IssueParcelable(
issue = it.issue,
title = it.title,
description = it.description,
issues = it.issues?.map { issueItem ->
IssueItemParcelable(
impact = issueItem.impact,
confidence = issueItem.confidence,
description = issueItem.description.trim()
)
}
)
}
),
issues = getIssueSnippet(blockchainIssues.issues)
)
)
}
blocks.add(
BlockViewItem(
title = R.string.CoinAnalytics_SmartContractAnalysis,
info = null,
analyticChart = null,
footerItems = detectorFooterItems,
sectionDescription = Translator.getString(R.string.CoinAnalytics_PoweredByDeFi)
)
)
}

analytics.audits?.let { audits ->
val auditsParcelable = audits.map {
CoinAuditsModule.AuditParcelable(
Expand Down
Loading

0 comments on commit 3d888d1

Please sign in to comment.