From 3db1ce70d1711076c4a201efcd6be55fd4b075ae Mon Sep 17 00:00:00 2001 From: Noelia Date: Tue, 28 Mar 2023 15:55:34 +0200 Subject: [PATCH] fix(MintToken): Fixed `deployState` property binding Created `instantiator` object as a mediator to establish appropriate binding between property model and `CommunityCollectibleView` Closes #10013 --- .../CommunityMintTokensSettingsPanel.qml | 71 ++++++++++++++----- .../communities/CommunityMintedTokensView.qml | 31 +------- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml b/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml index 72b1656f70..dc3fd3a5de 100644 --- a/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml @@ -13,6 +13,7 @@ import AppLayouts.Chat.views.communities 1.0 import AppLayouts.Chat.popups.community 1.0 import utils 1.0 +import SortFilterProxyModel 0.2 SettingsPageLayout { id: root @@ -157,7 +158,7 @@ SettingsPageLayout { onPreviewClicked: { d.accountAddress = accountAddress stackManager.push(d.previewCollectibleViewState, - collectibleView, + previewCollectibleView, { preview: true, name, @@ -179,10 +180,10 @@ SettingsPageLayout { } Component { - id: collectibleView + id: previewCollectibleView CommunityCollectibleView { - id: view + id: preview function signMintTransaction() { root.isFeeLoading = true @@ -210,7 +211,7 @@ SettingsPageLayout { Binding { target: root property: "title" - value: view.name + value: preview.name } SignMintTokenTransactionPopup { @@ -252,22 +253,58 @@ SettingsPageLayout { collectibleView, { preview: false, - deployState, - name, - artworkSource, - symbol, - description, - supplyAmount: supply, - infiniteSupply, - transferable, - selfDestruct, - chainId, - chainName, - chainIcon, - accountName + index }, StackView.Immediate) } } } + + Component { + id: collectibleView + + CommunityCollectibleView { + id: view + + property int index // TODO: Update it to key when model has role key implemented + + viewWidth: root.viewWidth + holdersModel: root.holdersModel + + Binding { + target: root + property: "title" + value: view.name + } + + Instantiator { + id: instantiator + + model: SortFilterProxyModel { + sourceModel: root.tokensModel + filters: IndexFilter { + minimumIndex: view.index + maximumIndex: view.index + } + } + delegate: QtObject { + component Bind: Binding { target: view } + readonly property list bindings: [ + Bind { property: "deployState"; value: model.deployState }, + Bind { property: "name"; value: model.name }, + Bind { property: "artworkSource"; value: model.image }, + Bind { property: "symbol"; value: model.symbol }, + Bind { property: "description"; value: model.description }, + Bind { property: "supplyAmount"; value: model.supply }, + Bind { property: "infiniteSupply"; value: model.infiniteSupply }, + Bind { property: "selfDestruct"; value: model.remoteSelfDestruct }, + Bind { property: "chainId"; value: model.chainId }, + Bind { property: "chainName"; value: model.chainName }, + Bind { property: "chainIcon"; value: model.chainIcon }, + Bind { property: "accountName"; value: model.accountName } + ] + } + } + } + } } diff --git a/ui/app/AppLayouts/Chat/views/communities/CommunityMintedTokensView.qml b/ui/app/AppLayouts/Chat/views/communities/CommunityMintedTokensView.qml index e141b4e5c8..fb01267638 100644 --- a/ui/app/AppLayouts/Chat/views/communities/CommunityMintedTokensView.qml +++ b/ui/app/AppLayouts/Chat/views/communities/CommunityMintedTokensView.qml @@ -15,20 +15,7 @@ StatusScrollView { property int viewWidth: 560 // by design property var model - signal itemClicked(int deployState, - string name, - string artworkSource, - string symbol, - string description, - int supply, - bool infiniteSupply, - bool transferable, - bool selfDestruct, - int chainId, - string chainName, - string chainIcon, - string accountName) - + signal itemClicked(int index) enum DeployState { Failed, @@ -85,21 +72,7 @@ StatusScrollView { isLoading: false navigationIconVisible: true - onClicked: root.itemClicked(model.deployState, - model.name, - model.image, - model.symbol, - model.description, - model.supply, - model.infiniteSupply, - model.transferable, - model.remoteSelfDestruct, - model.chainId, - model.chainName, - model.chainIcon, - model.accountName) - - + onClicked: root.itemClicked(model.index) // TODO: Replace to model.key when role exists in backend } } }