chore(MintedTokensSettingsPanel): simplified by integrating welcome page into MintedTokensView

Welcome info is a placeholder when list of tokens is empty. For that
reason is hander to keep in MintedTokensView instead of in MintedTokensSettingsPanel
and maintain additional state for that.
This commit is contained in:
Michał Cieślak 2023-06-27 23:56:45 +02:00 committed by Michał
parent c4e68b50db
commit 8a83aba05a
2 changed files with 157 additions and 148 deletions

View File

@ -74,12 +74,12 @@ SettingsPageLayout {
QtObject { QtObject {
id: d id: d
readonly property string initialViewState: "WELCOME_OR_LIST_TOKENS" readonly property string initialViewState: "TOKENS_LIST"
readonly property string newTokenViewState: "NEW_TOKEN" readonly property string newTokenViewState: "NEW_TOKEN"
readonly property string previewTokenViewState: "PREVIEW_TOKEN" readonly property string previewTokenViewState: "PREVIEW_TOKEN"
readonly property string tokenViewState: "VIEW_TOKEN" readonly property string tokenViewState: "VIEW_TOKEN"
readonly property string welcomePageTitle: qsTr("Tokens") readonly property string tokensListPageTitle: qsTr("Tokens")
readonly property string newCollectiblePageTitle: qsTr("Mint collectible") readonly property string newCollectiblePageTitle: qsTr("Mint collectible")
readonly property string newAssetPageTitle: qsTr("Mint asset") readonly property string newAssetPageTitle: qsTr("Mint asset")
readonly property string newTokenButtonText: qsTr("Mint token") readonly property string newTokenButtonText: qsTr("Mint token")
@ -101,29 +101,16 @@ SettingsPageLayout {
property TokenObject currentToken property TokenObject currentToken
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
signal airdropClicked() signal airdropClicked()
signal remoteDestructAddressClicked(string address) signal remoteDestructAddressClicked(string address)
signal retryMintClicked() signal retryMintClicked()
function updateInitialStackView() {
if(stackManager.stackView) {
if(initialItem === welcomeView)
stackManager.stackView.replace(mintedTokensView, welcomeView, StackView.Immediate)
if(initialItem === mintedTokensView)
stackManager.stackView.replace(welcomeView, mintedTokensView, StackView.Immediate)
}
}
onInitialItemChanged: updateInitialStackView()
} }
secondaryHeaderButton.type: StatusBaseButton.Type.Danger secondaryHeaderButton.type: StatusBaseButton.Type.Danger
content: StackView { content: StackView {
anchors.fill: parent anchors.fill: parent
initialItem: d.initialItem initialItem: mintedTokensView
Component.onCompleted: stackManager.pushInitialState(d.initialViewState) Component.onCompleted: stackManager.pushInitialState(d.initialViewState)
} }
@ -132,26 +119,21 @@ SettingsPageLayout {
states: [ states: [
State { State {
name: d.initialViewState name: d.initialViewState
PropertyChanges {target: root; title: d.welcomePageTitle} PropertyChanges {target: root; title: d.tokensListPageTitle}
PropertyChanges {target: root; subTitle: ""} PropertyChanges {target: root; subTitle: ""}
PropertyChanges {target: root; previousPageName: ""} PropertyChanges {target: root; previousPageName: ""}
PropertyChanges {target: root; primaryHeaderButton.visible: true} PropertyChanges {target: root; primaryHeaderButton.visible: true}
PropertyChanges {target: root; primaryHeaderButton.text: d.newTokenButtonText} PropertyChanges {target: root; primaryHeaderButton.text: d.newTokenButtonText}
PropertyChanges {target: root; secondaryHeaderButton.visible: false}
}, },
State { State {
name: d.newTokenViewState name: d.newTokenViewState
PropertyChanges {target: root; title: d.isAssetView ? d.newAssetPageTitle : d.newCollectiblePageTitle } PropertyChanges {target: root; title: d.isAssetView ? d.newAssetPageTitle : d.newCollectiblePageTitle }
PropertyChanges {target: root; subTitle: ""} PropertyChanges {target: root; subTitle: ""}
PropertyChanges {target: root; previousPageName: d.backButtonText} PropertyChanges {target: root; previousPageName: d.backButtonText}
PropertyChanges {target: root; primaryHeaderButton.visible: false}
PropertyChanges {target: root; secondaryHeaderButton.visible: false}
}, },
State { State {
name: d.previewTokenViewState name: d.previewTokenViewState
PropertyChanges {target: root; previousPageName: d.backButtonText} PropertyChanges {target: root; previousPageName: d.backButtonText}
PropertyChanges {target: root; primaryHeaderButton.visible: false}
PropertyChanges {target: root; secondaryHeaderButton.visible: false}
}, },
State { State {
name: d.tokenViewState name: d.tokenViewState
@ -222,22 +204,6 @@ SettingsPageLayout {
} }
// Mint tokens possible view contents: // Mint tokens possible view contents:
Component {
id: welcomeView
WelcomeSettingsView {
viewWidth: root.viewWidth
image: Style.png("community/mint2_1")
title: qsTr("Community tokens")
subtitle: qsTr("You can mint custom tokens and import tokens for your community")
checkersModel: [
qsTr("Create remotely destructible soulbound tokens for admin permissions"),
qsTr("Reward individual members with custom tokens for their contribution"),
qsTr("Mint tokens for use with community and channel permissions")
]
}
}
Component { Component {
id: newTokenView id: newTokenView

View File

@ -10,6 +10,7 @@ import utils 1.0
import shared.controls 1.0 import shared.controls 1.0
import AppLayouts.Wallet.views.collectibles 1.0 import AppLayouts.Wallet.views.collectibles 1.0
import AppLayouts.Communities.panels 1.0
StatusScrollView { StatusScrollView {
id: root id: root
@ -17,12 +18,16 @@ StatusScrollView {
property int viewWidth: 560 // by design property int viewWidth: 560 // by design
property var model property var model
readonly property int count: assetsModel.count + collectiblesModel.count
signal itemClicked(string tokenKey, signal itemClicked(string tokenKey,
int chainId, int chainId,
string chainName, string chainName,
string accountName, string accountName,
string accountAddress) string accountAddress)
padding: 0
QtObject { QtObject {
id: d id: d
@ -45,129 +50,167 @@ StatusScrollView {
} }
} }
padding: 0 SortFilterProxyModel {
id: assetsModel
ColumnLayout { sourceModel: root.model
id: mainLayout filters: ValueFilter {
roleName: "tokenType"
width: root.viewWidth value: Constants.TokenType.ERC20
spacing: Style.current.halfPadding
StatusBaseText {
Layout.leftMargin: Style.current.padding
text: qsTr("Assets")
font.pixelSize: Theme.primaryTextFontSize
color: Theme.palette.baseColor1
} }
}
StatusListView { SortFilterProxyModel {
id: assetsList id: collectiblesModel
Layout.fillWidth: true sourceModel: root.model
Layout.preferredHeight: childrenRect.height filters: ValueFilter {
roleName: "tokenType"
value: Constants.TokenType.ERC721
}
}
visible: count > 0 Loader {
model: SortFilterProxyModel { sourceComponent: root.count === 0 ? introComponent : mainLayoutComponent
sourceModel: root.model }
filters: ValueFilter {
roleName: "tokenType" Component {
value: Constants.TokenType.ERC20 id: introComponent
IntroPanel {
width: root.viewWidth
image: Style.png("community/mint2_1")
title: qsTr("Community tokens")
subtitle: qsTr("You can mint custom tokens and import tokens for your community")
checkersModel: [
qsTr("Create remotely destructible soulbound tokens for admin permissions"),
qsTr("Reward individual members with custom tokens for their contribution"),
qsTr("Mint tokens for use with community and channel permissions")
]
}
}
Component {
id: mainLayoutComponent
ColumnLayout {
id: mainLayout
width: root.viewWidth
spacing: Style.current.halfPadding
StatusBaseText {
Layout.leftMargin: Style.current.padding
text: qsTr("Assets")
font.pixelSize: Theme.primaryTextFontSize
color: Theme.palette.baseColor1
}
StatusListView {
id: assetsList
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height
visible: count > 0
model: assetsModel
delegate: StatusListItem {
height: 64
width: mainLayout.width
title: model.name
subTitle: model.symbol
asset.name: model.image ? model.image : ""
asset.isImage: true
components: [
StatusBaseText {
anchors.verticalCenter: parent.verticalCenter
text: d.getSubtitle(model.deployState,
model.remainingSupply,
model.supply, false,
model.infiniteSupply)
color: model.deployState === Constants.ContractTransactionStatus.Failed
? Theme.palette.dangerColor1 : Theme.palette.baseColor1
font.pixelSize: 13
},
StatusIcon {
anchors.verticalCenter: parent.verticalCenter
icon: "next"
color: Theme.palette.baseColor1
}
]
onClicked: root.itemClicked(model.contractUniqueKey,
model.chainId, model.chainName,
model.accountName, model.address)
} }
} }
delegate: StatusListItem {
height: 64 // Empty placeholder when no assets; dashed rounded rectangle
width: mainLayout.width ShapeRectangle {
title: model.name Layout.alignment: Qt.AlignHCenter
subTitle: model.symbol Layout.preferredWidth: parent.width - 4 // The rectangular path is rendered outside
asset.name: model.image ? model.image : "" Layout.preferredHeight: 44
asset.isImage: true visible: assetsList.count === 0
components: [ text: qsTr("You currently have no minted assets")
StatusBaseText { }
anchors.verticalCenter: parent.verticalCenter
text: d.getSubtitle(model.deployState, StatusBaseText {
model.remainingSupply, Layout.leftMargin: Style.current.padding
model.supply, false, Layout.topMargin: Style.current.halfPadding
model.infiniteSupply)
color: model.deployState === Constants.ContractTransactionStatus.Failed text: qsTr("Collectibles")
? Theme.palette.dangerColor1 : Theme.palette.baseColor1 font.pixelSize: Theme.primaryTextFontSize
font.pixelSize: 13 color: Theme.palette.baseColor1
}, }
StatusIcon {
anchors.verticalCenter: parent.verticalCenter StatusGridView {
icon: "next" id: collectiblesGrid
color: Theme.palette.baseColor1
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height
visible: count > 0
model: SortFilterProxyModel {
sourceModel: root.model
filters: ValueFilter {
roleName: "tokenType"
value: Constants.TokenType.ERC721
} }
] }
onClicked: root.itemClicked(model.contractUniqueKey, cellHeight: 229
model.chainId, model.chainName, cellWidth: 176
model.accountName, model.address) leftMargin: 16
} delegate: CollectibleView {
} height: collectiblesGrid.cellHeight
width: collectiblesGrid.cellWidth
title: model.name ? model.name : "..."
subTitle: d.getSubtitle(model.deployState,
model.remainingSupply,
model.supply, true,
model.infiniteSupply)
subTitleColor: model.deployState === Constants.ContractTransactionStatus.Failed
? Theme.palette.dangerColor1 : Theme.palette.baseColor1
fallbackImageUrl: model.image ? model.image : ""
backgroundColor: "transparent"
isLoading: false
navigationIconVisible: true
// Empty placeholder when no assets; dashed rounded rectangle onClicked: root.itemClicked(model.contractUniqueKey,
ShapeRectangle { model.chainId, model.chainName,
Layout.alignment: Qt.AlignHCenter model.accountName, model.address)
Layout.preferredWidth: parent.width - 4 // The rectangular path is rendered outside
Layout.preferredHeight: 44
visible: assetsList.count === 0
text: qsTr("You currently have no minted assets")
}
StatusBaseText {
Layout.leftMargin: Style.current.padding
Layout.topMargin: Style.current.halfPadding
text: qsTr("Collectibles")
font.pixelSize: Theme.primaryTextFontSize
color: Theme.palette.baseColor1
}
StatusGridView {
id: collectiblesGrid
Layout.fillWidth: true
Layout.preferredHeight: childrenRect.height
visible: count > 0
model: SortFilterProxyModel {
sourceModel: root.model
filters: ValueFilter {
roleName: "tokenType"
value: Constants.TokenType.ERC721
} }
} }
cellHeight: 229
cellWidth: 176
leftMargin: 16
delegate: CollectibleView {
height: collectiblesGrid.cellHeight
width: collectiblesGrid.cellWidth
title: model.name ? model.name : "..."
subTitle: d.getSubtitle(model.deployState,
model.remainingSupply,
model.supply, true,
model.infiniteSupply)
subTitleColor: model.deployState === Constants.ContractTransactionStatus.Failed
? Theme.palette.dangerColor1 : Theme.palette.baseColor1
fallbackImageUrl: model.image ? model.image : ""
backgroundColor: "transparent"
isLoading: false
navigationIconVisible: true
onClicked: root.itemClicked(model.contractUniqueKey, // Empty placeholder when no collectibles; dashed rounded rectangle
model.chainId, model.chainName, ShapeRectangle {
model.accountName, model.address) Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: parent.width - 4 // The rectangular path is rendered outside
Layout.preferredHeight: 44
visible: collectiblesGrid.count === 0
text: qsTr("You currently have no minted collectibles")
} }
} }
// Empty placeholder when no collectibles; dashed rounded rectangle
ShapeRectangle {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: parent.width - 4 // The rectangular path is rendered outside
Layout.preferredHeight: 44
visible: collectiblesGrid.count == 0
text: qsTr("You currently have no minted collectibles")
}
} }
} }