chore(Wallet): Integrate refactored AssetView and related adaptor

This commit is contained in:
Michał Cieślak 2024-06-14 19:50:52 +02:00 committed by Michał
parent b12caa3f9a
commit 38914df0f0
3 changed files with 116 additions and 28 deletions

View File

@ -39,7 +39,7 @@ Item {
readonly property string symbol: !!root.token? root.token.symbol?? "" : ""
property bool marketDetailsLoading: !!root.token? root.token.marketDetailsLoading?? false : false
property bool tokenDetailsLoading: !!root.token? root.token.detailsLoading?? false: false
property bool isCommunityAsset: !!root.token && token.isCommunityAsset !== undefined ? token.isCommunityAsset : false
property bool isCommunityAsset: !!root.token && !!token.communityId
readonly property LeftJoinModel addressPerChainModel: LeftJoinModel {
leftModel: token && token.addressPerChain ? token.addressPerChain: null
@ -79,10 +79,10 @@ Item {
}
asset.isImage: true
primaryText: token && token.name ? token.name : Constants.dummyText
secondaryText: token ? LocaleUtils.currencyAmountToLocaleString(root.currencyStore.getCurrencyAmount(token.currentBalance, token.symbol)) : Constants.dummyText
secondaryText: token ? token.balanceText : Constants.dummyText
tertiaryText: {
if (!d.isCommunityAsset) {
let totalCurrencyBalance = token && token.currentCurrencyBalance && token.symbol ? token.currentCurrencyBalance : 0
let totalCurrencyBalance = token ? token.balance * token.marketPrice : 0
return currencyStore.formatCurrencyAmount(totalCurrencyBalance, currencyStore.currentCurrency)
}
return ""

View File

@ -1,9 +1,10 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1
import utils 1.0
import shared.controls 1.0
@ -141,36 +142,100 @@ RightTabBaseView {
Component {
id: assetsView
AssetsView {
areAssetsLoading: RootStore.overview.balanceLoading
AssetsViewNew {
AssetsViewAdaptor {
id: assetsViewAdaptor
accounts: RootStore.addressFilters
chains: RootStore.networkFilters
marketValueThreshold:
RootStore.tokensStore.displayAssetsBelowBalance
? RootStore.tokensStore.getDisplayAssetsBelowBalanceThresholdDisplayAmount()
: 0
Connections {
target: RootStore.tokensStore
function displayAssetsBelowBalanceThresholdChanged() {
assetsViewAdaptor.marketValueThresholdChanged()
}
}
tokensModel: RootStore.walletAssetsStore.groupedAccountAssetsModel
controller: RootStore.walletAssetsStore.assetsController
networkFilters: RootStore.networkFilters
addressFilters: RootStore.addressFilters
overview: RootStore.overview
currencyStore: RootStore.currencyStore
networkConnectionStore: root.networkConnectionStore
tokensStore: RootStore.tokensStore
assetDetailsLaunched: stack.currentIndex === 2
filterVisible: filterButton.checked
formatBalance: (balance, symbol) => {
return LocaleUtils.currencyAmountToLocaleString(
RootStore.currencyStore.getCurrencyAmount(balance, symbol))
}
chainsError: (chains) => {
if (!root.networkConnectionStore)
return ""
return root.networkConnectionStore.getBlockchainNetworkDownText(chains)
}
}
loading: RootStore.overview.balanceLoading
sorterVisible: filterButton.checked
customOrderAvailable: RootStore.walletAssetsStore.assetsController.hasSettings
model: assetsViewAdaptor.model
marketDataError: !!root.networkConnectionStore
? root.networkConnectionStore.getMarketNetworkDownText()
: ""
balanceError: {
if (!root.networkConnectionStore)
return ""
return (root.networkConnectionStore.noBlockchainConnectionAndNoCache
&& !root.networkConnectionStore.noMarketConnectionAndNoCache)
? root.networkConnectionStore.noBlockchainConnectionAndNoCacheText
: ""
}
formatFiat: balance => RootStore.currencyStore.formatCurrencyAmount(
balance, RootStore.currencyStore.currentCurrency)
sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled &&
!RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend
swapEnabled: !RootStore.overview.isWatchOnlyAccount
swapVisible: Global.featureFlags.swapEnabled
onSendRequested: {
const symbol = ModelUtils.getByKey(model, "key", key, "symbol")
const modal = root.sendModal
modal.preSelectedSendType = Constants.SendType.Transfer
modal.preSelectedHoldingID = symbol
modal.preSelectedHoldingType = Constants.TokenType.ERC20
modal.onlyAssets = true
modal.open()
}
onSwapRequested: root.launchSwapModal(key)
onReceiveRequested: root.launchShareAddressModal()
onCommunityClicked: Global.switchToCommunity(communityKey)
onManageTokensRequested: Global.changeAppSectionBySectionType(
Constants.appSection.profile,
Constants.settingsSubsection.wallet,
Constants.walletSettingsSubsection.manageAssets)
onAssetClicked: {
const token = ModelUtils.getByKey(model, "key", key)
SharedStores.RootStore.getHistoricalDataForToken(
token.symbol, RootStore.currencyStore.currentCurrency)
assetDetailView.token = token
RootStore.setCurrentViewedHolding(token.symbol, token.tokensKey, Constants.TokenType.ERC20)
RootStore.setCurrentViewedHolding(token.symbol, token.key, Constants.TokenType.ERC20)
stack.currentIndex = 2
}
onSendRequested: (symbol) => {
root.sendModal.preSelectedSendType = Constants.SendType.Transfer
root.sendModal.preSelectedHoldingID = symbol
root.sendModal.preSelectedHoldingType = Constants.TokenType.ERC20
root.sendModal.onlyAssets = true
root.sendModal.open()
}
onReceiveRequested: (symbol) => root.launchShareAddressModal()
onSwitchToCommunityRequested: (communityId) => Global.switchToCommunity(communityId)
onManageTokensRequested: Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.wallet,
Constants.walletSettingsSubsection.manageAssets)
onLaunchSwapModal: root.launchSwapModal(tokensKey)
}
}
Component {
id: collectiblesView
CollectiblesView {

View File

@ -64,6 +64,7 @@ QtObject {
readonly property string stickersNetworkUnavailableText: qsTr("Requires POKT/Infura for %1, which is currently unavailable").arg(appNetworkName)
readonly property string appNetworkName: ModelUtils.getByKey(networksModule.flatNetworks, "chainId", mainModule.appNetworkId, "chainName")
// DEPRECATED, use getBlockchainNetworkDownText instead
function getBlockchainNetworkDownTextForToken(balances) {
if(!!balances && !networkConnectionModule.blockchainNetworkConnection.completelyDown && !notOnlineWithNoCache) {
let chainIdsDown = []
@ -81,6 +82,28 @@ QtObject {
return ""
}
function getBlockchainNetworkDownText(chains) {
if (chains.length === 0
|| networkConnectionModule.blockchainNetworkConnection.completelyDown
|| notOnlineWithNoCache)
return ""
let chainIdsDown = []
for (let i = 0; i < chains.length; i++) {
const chainId = chains[i]
if(blockchainNetworksDown.includes(chainId))
chainIdsDown.push(chainId)
}
if(chainIdsDown.length > 0) {
return qsTr("Pocket Network (POKT) & Infura are currently both unavailable for %1. %1 balances are as of %2.")
.arg(getChainIdsJointString(chainIdsDown))
.arg(LocaleUtils.formatDateTime(new Date(networkConnectionModule.blockchainNetworkConnection.lastCheckedAt * 1000)))
}
return ""
}
function getMarketNetworkDownText() {
if(notOnlineWithNoCache)
return notOnlineWithNoCacheText