chore(Wallet): Integrate refactored AssetView and related adaptor
This commit is contained in:
parent
b12caa3f9a
commit
38914df0f0
|
@ -39,7 +39,7 @@ Item {
|
||||||
readonly property string symbol: !!root.token? root.token.symbol?? "" : ""
|
readonly property string symbol: !!root.token? root.token.symbol?? "" : ""
|
||||||
property bool marketDetailsLoading: !!root.token? root.token.marketDetailsLoading?? false : false
|
property bool marketDetailsLoading: !!root.token? root.token.marketDetailsLoading?? false : false
|
||||||
property bool tokenDetailsLoading: !!root.token? root.token.detailsLoading?? 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 {
|
readonly property LeftJoinModel addressPerChainModel: LeftJoinModel {
|
||||||
leftModel: token && token.addressPerChain ? token.addressPerChain: null
|
leftModel: token && token.addressPerChain ? token.addressPerChain: null
|
||||||
|
@ -79,10 +79,10 @@ Item {
|
||||||
}
|
}
|
||||||
asset.isImage: true
|
asset.isImage: true
|
||||||
primaryText: token && token.name ? token.name : Constants.dummyText
|
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: {
|
tertiaryText: {
|
||||||
if (!d.isCommunityAsset) {
|
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 currencyStore.formatCurrencyAmount(totalCurrencyBalance, currencyStore.currentCurrency)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import StatusQ.Core 0.1
|
|
||||||
import StatusQ.Controls 0.1
|
import StatusQ.Controls 0.1
|
||||||
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
import shared.controls 1.0
|
import shared.controls 1.0
|
||||||
|
@ -141,36 +142,100 @@ RightTabBaseView {
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: assetsView
|
id: assetsView
|
||||||
AssetsView {
|
|
||||||
areAssetsLoading: RootStore.overview.balanceLoading
|
AssetsViewNew {
|
||||||
controller: RootStore.walletAssetsStore.assetsController
|
|
||||||
networkFilters: RootStore.networkFilters
|
AssetsViewAdaptor {
|
||||||
addressFilters: RootStore.addressFilters
|
id: assetsViewAdaptor
|
||||||
overview: RootStore.overview
|
|
||||||
currencyStore: RootStore.currencyStore
|
accounts: RootStore.addressFilters
|
||||||
networkConnectionStore: root.networkConnectionStore
|
chains: RootStore.networkFilters
|
||||||
tokensStore: RootStore.tokensStore
|
|
||||||
assetDetailsLaunched: stack.currentIndex === 2
|
marketValueThreshold:
|
||||||
filterVisible: filterButton.checked
|
RootStore.tokensStore.displayAssetsBelowBalance
|
||||||
|
? RootStore.tokensStore.getDisplayAssetsBelowBalanceThresholdDisplayAmount()
|
||||||
|
: 0
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: RootStore.tokensStore
|
||||||
|
|
||||||
|
function displayAssetsBelowBalanceThresholdChanged() {
|
||||||
|
assetsViewAdaptor.marketValueThresholdChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tokensModel: RootStore.walletAssetsStore.groupedAccountAssetsModel
|
||||||
|
controller: RootStore.walletAssetsStore.assetsController
|
||||||
|
|
||||||
|
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: {
|
onAssetClicked: {
|
||||||
|
const token = ModelUtils.getByKey(model, "key", key)
|
||||||
|
|
||||||
|
SharedStores.RootStore.getHistoricalDataForToken(
|
||||||
|
token.symbol, RootStore.currencyStore.currentCurrency)
|
||||||
|
|
||||||
assetDetailView.token = token
|
assetDetailView.token = token
|
||||||
RootStore.setCurrentViewedHolding(token.symbol, token.tokensKey, Constants.TokenType.ERC20)
|
RootStore.setCurrentViewedHolding(token.symbol, token.key, Constants.TokenType.ERC20)
|
||||||
stack.currentIndex = 2
|
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 {
|
Component {
|
||||||
id: collectiblesView
|
id: collectiblesView
|
||||||
CollectiblesView {
|
CollectiblesView {
|
||||||
|
|
|
@ -64,6 +64,7 @@ QtObject {
|
||||||
readonly property string stickersNetworkUnavailableText: qsTr("Requires POKT/Infura for %1, which is currently unavailable").arg(appNetworkName)
|
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")
|
readonly property string appNetworkName: ModelUtils.getByKey(networksModule.flatNetworks, "chainId", mainModule.appNetworkId, "chainName")
|
||||||
|
|
||||||
|
// DEPRECATED, use getBlockchainNetworkDownText instead
|
||||||
function getBlockchainNetworkDownTextForToken(balances) {
|
function getBlockchainNetworkDownTextForToken(balances) {
|
||||||
if(!!balances && !networkConnectionModule.blockchainNetworkConnection.completelyDown && !notOnlineWithNoCache) {
|
if(!!balances && !networkConnectionModule.blockchainNetworkConnection.completelyDown && !notOnlineWithNoCache) {
|
||||||
let chainIdsDown = []
|
let chainIdsDown = []
|
||||||
|
@ -81,6 +82,28 @@ QtObject {
|
||||||
return ""
|
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() {
|
function getMarketNetworkDownText() {
|
||||||
if(notOnlineWithNoCache)
|
if(notOnlineWithNoCache)
|
||||||
return notOnlineWithNoCacheText
|
return notOnlineWithNoCacheText
|
||||||
|
|
Loading…
Reference in New Issue