fix(RightTabView): revert to using a StackLayout instead of a Loader

in the end it turns out the Loader causes more problems (and even
crashes in some scenarios)
This commit is contained in:
Lukáš Tinkl 2023-12-15 14:23:52 +01:00 committed by Lukáš Tinkl
parent fe3b442155
commit b58612f070
2 changed files with 57 additions and 68 deletions

View File

@ -31,8 +31,7 @@ Item {
function resetView() { function resetView() {
stack.currentIndex = 0 stack.currentIndex = 0
root.currentTabIndex = 0 root.currentTabIndex = 0
if (walletTabBar.currentIndex === 2) historyView.resetView()
mainViewLoader.item.resetView()
} }
function resetStack() { function resetStack() {
@ -129,80 +128,67 @@ Item {
highlighted: checked highlighted: checked
} }
} }
Loader { StackLayout {
id: mainViewLoader id: mainViewLoader
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
sourceComponent: { currentIndex: walletTabBar.currentIndex
switch (walletTabBar.currentIndex) {
case 0: return assetsView
case 1: return collectiblesView
case 2: return historyView
}
}
active: visible
Component { AssetsView {
id: assetsView assets: RootStore.assets
AssetsView { overview: RootStore.overview
assets: RootStore.assets networkConnectionStore: root.networkConnectionStore
overview: RootStore.overview assetDetailsLaunched: stack.currentIndex === 2
networkConnectionStore: root.networkConnectionStore filterVisible: filterButton.checked
assetDetailsLaunched: stack.currentIndex === 2 onAssetClicked: {
filterVisible: filterButton.checked assetDetailView.token = token
onAssetClicked: { RootStore.setCurrentViewedHolding(token.symbol, Constants.TokenType.ERC20)
assetDetailView.token = token stack.currentIndex = 2
RootStore.setCurrentViewedHolding(token.symbol, 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)
} }
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)
} }
Component {
id: collectiblesView CollectiblesView {
CollectiblesView { collectiblesModel: RootStore.collectiblesStore.ownedCollectibles
collectiblesModel: RootStore.collectiblesStore.ownedCollectibles sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled && !RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend
sendEnabled: root.networkConnectionStore.sendBuyBridgeEnabled && !RootStore.overview.isWatchOnlyAccount && RootStore.overview.canSend filterVisible: filterButton.checked
filterVisible: filterButton.checked onCollectibleClicked: {
onCollectibleClicked: { RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId)
RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId) RootStore.setCurrentViewedHolding(uid, Constants.TokenType.ERC721)
RootStore.setCurrentViewedHolding(uid, Constants.TokenType.ERC721) stack.currentIndex = 1
stack.currentIndex = 1
}
onSendRequested: (symbol) => {
root.sendModal.preSelectedSendType = Constants.SendType.Transfer
root.sendModal.preSelectedHoldingID = symbol
root.sendModal.preSelectedHoldingType = Constants.TokenType.ERC721
root.sendModal.onlyAssets = false
root.sendModal.open()
}
onReceiveRequested: (symbol) => root.launchShareAddressModal()
onSwitchToCommunityRequested: (communityId) => Global.switchToCommunity(communityId)
onManageTokensRequested: Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.wallet,
Constants.walletSettingsSubsection.manageCollectibles)
} }
onSendRequested: (symbol) => {
root.sendModal.preSelectedSendType = Constants.SendType.Transfer
root.sendModal.preSelectedHoldingID = symbol
root.sendModal.preSelectedHoldingType = Constants.TokenType.ERC721
root.sendModal.onlyAssets = false
root.sendModal.open()
}
onReceiveRequested: (symbol) => root.launchShareAddressModal()
onSwitchToCommunityRequested: (communityId) => Global.switchToCommunity(communityId)
onManageTokensRequested: Global.changeAppSectionBySectionType(Constants.appSection.profile, Constants.settingsSubsection.wallet,
Constants.walletSettingsSubsection.manageCollectibles)
} }
Component {
HistoryView {
id: historyView id: historyView
HistoryView { overview: RootStore.overview
overview: RootStore.overview showAllAccounts: root.showAllAccounts
showAllAccounts: root.showAllAccounts sendModal: root.sendModal
sendModal: root.sendModal onLaunchTransactionDetail: function (entry, entryIndex) {
onLaunchTransactionDetail: function (entry, entryIndex) { transactionDetailView.transactionIndex = entryIndex
transactionDetailView.transactionIndex = entryIndex transactionDetailView.transaction = entry
transactionDetailView.transaction = entry stack.currentIndex = 3
stack.currentIndex = 3
}
} }
} }
} }

View File

@ -39,7 +39,10 @@ ColumnLayout {
} }
} }
Component.onCompleted: { onVisibleChanged: {
if (!visible)
return
filterPanelLoader.active = true filterPanelLoader.active = true
if (RootStore.transactionActivityStatus.isFilterDirty) { if (RootStore.transactionActivityStatus.isFilterDirty) {
WalletStores.RootStore.currentActivityFiltersStore.applyAllFilters() WalletStores.RootStore.currentActivityFiltersStore.applyAllFilters()