feat(CollectiblesView): Always visualize section header if community minted collectibles are present

- If only minted collectibles, section header visible. Otherwise, if only regular collectibles, section hidden.
- Updated header used to `FoldableHeader`.

Closes #13315
This commit is contained in:
Noelia 2024-03-12 16:48:59 +01:00 committed by Noelia
parent 5b71ead227
commit f31d6131c3
2 changed files with 51 additions and 122 deletions

View File

@ -115,10 +115,9 @@ ColumnLayout {
markerRoleName: "sourceGroup"
}
readonly property bool hasCollectibles: d.nonCommunityModel.count || d.loadingItemsModel.count
readonly property bool hasRegularCollectibles: d.nonCommunityModel.count || d.loadingItemsModel.count
readonly property bool hasCommunityCollectibles: d.communityModel.count || d.loadingItemsModel.count
readonly property bool onlyOneType: !hasCollectibles || !hasCommunityCollectibles
readonly property bool onlyRegularCollectiblesType: hasRegularCollectibles && !hasCommunityCollectibles
readonly property var nwFilters: root.networkFilters.split(":")
readonly property var addrFilters: root.addressFilters.split(":").map((addr) => addr.toLowerCase())
@ -325,7 +324,7 @@ ColumnLayout {
ShapeRectangle {
Layout.fillWidth: true
Layout.topMargin: Style.current.padding
visible: !d.hasCollectibles && !d.hasCommunityCollectibles
visible: !d.hasRegularCollectibles && !d.hasCommunityCollectibles
text: qsTr("Collectibles will appear here")
}
@ -340,123 +339,52 @@ ColumnLayout {
flickable1: CustomGridView {
id: communityCollectiblesView
header: HeaderDelegate {
height: d.headerHeight
width: doubleFlickable.width
z: 1
text: qsTr("Community minted")
scrolled: !doubleFlickable.atYBeginning
checked: doubleFlickable.flickable1Folded
onToggleClicked: doubleFlickable.flip1Folding()
onInfoClicked: Global.openPopup(communityInfoPopupCmp)
}
Binding {
target: communityCollectiblesView
property: "header"
when: d.onlyOneType
value: null
restoreMode: Binding.RestoreBindingOrValue
}
header: d.hasCommunityCollectibles ? communityHeaderComponent : null
width: doubleFlickable.width
cellHeight: d.communityCellHeight
model: d.communityModelWithLoadingItems
Component {
id: communityHeaderComponent
FoldableHeader {
height: d.headerHeight
width: doubleFlickable.width
title: qsTr("Community minted")
titleColor: Theme.palette.baseColor1
folded: doubleFlickable.flickable1Folded
rightAdditionalComponent: StatusFlatButton {
icon.name: "info"
textColor: Theme.palette.baseColor1
onClicked: Global.openPopup(communityInfoPopupCmp)
}
onToggleFolding:doubleFlickable.flip1Folding()
}
}
}
flickable2: CustomGridView {
id: regularCollectiblesView
header: HeaderDelegate {
height: d.headerHeight
width: doubleFlickable.width
z: 1
text: qsTr("Others")
checked: doubleFlickable.flickable2Folded
scrolled: (doubleFlickable.contentY >
communityCollectiblesView.contentHeight
- d.headerHeight)
showInfoButton: false
onToggleClicked: doubleFlickable.flip2Folding()
}
Binding {
target: regularCollectiblesView
property: "header"
when: d.onlyOneType
value: null
restoreMode: Binding.RestoreBindingOrValue
}
header: !d.hasRegularCollectibles || d.onlyRegularCollectiblesType ? null : regularHeaderComponent
width: doubleFlickable.width
cellHeight: d.cellHeight
model: d.nonCommunityModelWithLoadingItems
Component {
id: regularHeaderComponent
FoldableHeader {
height: d.headerHeight
width: doubleFlickable.width
title: qsTr("Others")
titleColor: Theme.palette.baseColor1
folded: doubleFlickable.flickable2Folded
onToggleFolding:doubleFlickable.flip2Folding()
}
}
component HeaderDelegate: Rectangle {
id: sectionDelegate
property alias text: headerLabel.text
property alias checked: toggleButton.checked
property bool scrolled: false
property alias showInfoButton: infoButton.visible
signal toggleClicked
signal infoClicked
color: Theme.palette.statusListItem.backgroundColor
RowLayout {
anchors.fill: parent
StatusFlatButton {
id: toggleButton
checkable: true
size: StatusBaseButton.Size.Small
icon.name: checked ? "next" : "chevron-down"
textColor: Theme.palette.baseColor1
textHoverColor: Theme.palette.directColor1
onToggled: sectionDelegate.toggleClicked()
}
StatusBaseText {
id: headerLabel
Layout.fillWidth: true
color: Theme.palette.baseColor1
elide: Text.ElideRight
}
StatusFlatButton {
id: infoButton
icon.name: "info"
textColor: Theme.palette.baseColor1
onClicked: sectionDelegate.infoClicked()
}
}
Rectangle {
width: parent.width
height: 4
anchors.top: parent.bottom
color: Theme.palette.directColor8
visible: !sectionDelegate.checked && sectionDelegate.scrolled
}
}

View File

@ -10,6 +10,7 @@ Rectangle {
property bool folded: false
property alias title: label.text
property alias titleColor: label.color
property alias switchText: modeSwitch.text
property alias checked: modeSwitch.checked
property Component rightAdditionalComponent