chore(Settings/Tokens management): simplify ManageAssetsPanel and ManageCollectiblesPanel by deriving directly from DoubleFlickableWithFolding

This commit is contained in:
Michał Cieślak 2024-01-31 11:41:19 +01:00 committed by Michał
parent 2e29e847ac
commit 6f25499380
3 changed files with 84 additions and 108 deletions

View File

@ -33,7 +33,7 @@ Item {
id: componentUnderTest id: componentUnderTest
ManageCollectiblesPanel { ManageCollectiblesPanel {
width: 500 width: 500
height: contentItem.contentHeight height: contentHeight
controller: ManageTokensController { controller: ManageTokensController {
sourceModel: renamedModel sourceModel: renamedModel
settingsKey: "WalletCollectibles" settingsKey: "WalletCollectibles"

View File

@ -1,23 +1,16 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQml.Models 2.15 import QtQml.Models 2.15
import QtQml 2.15
import StatusQ.Components 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 StatusQ.Core.Utils 0.1
import StatusQ.Models 0.1
import shared.controls 1.0
import AppLayouts.Wallet.controls 1.0 import AppLayouts.Wallet.controls 1.0
import "internals" import "internals"
Control { DoubleFlickableWithFolding {
id: root id: root
required property var controller required property var controller
@ -28,8 +21,6 @@ Control {
property var getCurrencyAmount: function (balance, symbol) {} property var getCurrencyAmount: function (balance, symbol) {}
property var getCurrentCurrencyAmount: function(balance) {} property var getCurrentCurrencyAmount: function(balance) {}
background: null
function saveSettings() { function saveSettings() {
root.controller.saveSettings(); root.controller.saveSettings();
} }
@ -42,72 +33,65 @@ Control {
root.controller.clearSettings(); root.controller.clearSettings();
} }
clip: true
QtObject { QtObject {
id: d id: d
readonly property int sectionHeight: 64 readonly property int sectionHeight: 64
} }
contentItem: DoubleFlickableWithFolding { ScrollBar.vertical: StatusScrollBar {
id: doubleFlickable policy: ScrollBar.AsNeeded
visible: resolveVisibility(policy, root.height, root.contentHeight)
}
clip: true flickable1: ManageTokensListViewBase {
model: root.controller.regularTokensModel
width: root.width
ScrollBar.vertical: StatusScrollBar { header: FoldableHeader {
policy: ScrollBar.AsNeeded width: ListView.view.width
visible: resolveVisibility(policy, doubleFlickable.height, title: qsTr("Assets")
doubleFlickable.contentHeight) folded: root.flickable1Folded
onToggleFolding: root.flip1Folding()
} }
flickable1: ManageTokensListViewBase { delegate: ManageTokensDelegate {
model: root.controller.regularTokensModel controller: root.controller
width: doubleFlickable.width dragParent: root
count: root.controller.regularTokensModel.count
ScrollBar.vertical: null dragEnabled: count > 1
getCurrencyAmount: function (balance, symbol) {
header: FoldableHeader { return root.getCurrencyAmount(balance, symbol)
width: ListView.view.width
title: qsTr("Assets")
folded: doubleFlickable.flickable1Folded
onToggleFolding: doubleFlickable.flip1Folding()
} }
getCurrentCurrencyAmount: function (balance) {
delegate: ManageTokensDelegate { return root.getCurrentCurrencyAmount(balance)
controller: root.controller
dragParent: root
count: root.controller.regularTokensModel.count
dragEnabled: count > 1
getCurrencyAmount: function (balance, symbol) {
return root.getCurrencyAmount(balance, symbol)
}
getCurrentCurrencyAmount: function (balance) {
return root.getCurrentCurrencyAmount(balance)
}
} }
placeholderText: qsTr("Your assets will appear here")
} }
flickable2: ManageTokensListViewBase { placeholderText: qsTr("Your assets will appear here")
width: doubleFlickable.width }
model: root.controller.arrangeByCommunity ? communityGroupedModel flickable2: ManageTokensListViewBase {
: communityNonGroupedModel width: root.width
header: FoldableHeader { model: root.controller.arrangeByCommunity ? communityGroupedModel
width: ListView.view.width : communityNonGroupedModel
title: qsTr("Community minted")
switchText: qsTr("Arrange by community")
folded: doubleFlickable.flickable2Folded
checked: root.controller.arrangeByCommunity
onToggleFolding: doubleFlickable.flip2Folding() header: FoldableHeader {
onToggleSwitch: root.controller.arrangeByCommunity = checked width: ListView.view.width
} title: qsTr("Community minted")
switchText: qsTr("Arrange by community")
folded: root.flickable2Folded
checked: root.controller.arrangeByCommunity
placeholderText: qsTr("Your community minted assets will appear here") onToggleFolding: root.flip2Folding()
onToggleSwitch: root.controller.arrangeByCommunity = checked
} }
placeholderText: qsTr("Your community minted assets will appear here")
} }
DelegateModel { DelegateModel {

View File

@ -1,6 +1,5 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQml.Models 2.15 import QtQml.Models 2.15
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
@ -11,7 +10,7 @@ import AppLayouts.Wallet.controls 1.0
import "internals" import "internals"
Control { DoubleFlickableWithFolding {
id: root id: root
required property var controller required property var controller
@ -19,8 +18,6 @@ Control {
readonly property bool dirty: root.controller.dirty readonly property bool dirty: root.controller.dirty
readonly property bool hasSettings: root.controller.hasSettings readonly property bool hasSettings: root.controller.hasSettings
background: null
function saveSettings() { function saveSettings() {
root.controller.saveSettings(); root.controller.saveSettings();
} }
@ -33,64 +30,59 @@ Control {
root.controller.clearSettings(); root.controller.clearSettings();
} }
contentItem: DoubleFlickableWithFolding { clip: true
id: doubleFlickable
clip: true ScrollBar.vertical: StatusScrollBar {
policy: ScrollBar.AsNeeded
visible: resolveVisibility(policy, root.height, root.contentHeight)
}
ScrollBar.vertical: StatusScrollBar { flickable1: ManageTokensListViewBase {
policy: ScrollBar.AsNeeded objectName: "communityTokensListView"
visible: resolveVisibility(policy, doubleFlickable.height,
doubleFlickable.contentHeight) width: root.width
model: root.controller.arrangeByCommunity
? communityGroupedModel : communityNonGroupedModel
header: FoldableHeader {
objectName: "communityHeader"
width: ListView.view.width
title: qsTr("Community minted")
switchText: qsTr("Arrange by community")
folded: root.flickable1Folded
checked: root.controller.arrangeByCommunity
onToggleFolding: root.flip1Folding()
onToggleSwitch: root.controller.arrangeByCommunity = checked
} }
flickable1: ManageTokensListViewBase { placeholderText: qsTr("Your community minted collectibles will appear here")
objectName: "communityTokensListView" }
width: doubleFlickable.width flickable2: ManageTokensListViewBase {
objectName: "otherTokensListView"
model: root.controller.arrangeByCommunity width: root.width
? communityGroupedModel : communityNonGroupedModel
header: FoldableHeader { model: root.controller.arrangeByCollection
objectName: "communityHeader" ? otherGroupedModel : otherNonGroupedModel
width: ListView.view.width header: FoldableHeader {
title: qsTr("Community minted") objectName: "nonCommunityHeader"
switchText: qsTr("Arrange by community")
folded: doubleFlickable.flickable1Folded
checked: root.controller.arrangeByCommunity
onToggleFolding: doubleFlickable.flip1Folding() width: ListView.view.width
onToggleSwitch: root.controller.arrangeByCommunity = checked title: qsTr("Other")
} switchText: qsTr("Arrange by collection")
folded: root.flickable2Folded
checked: root.controller.arrangeByCollection
placeholderText: qsTr("Your community minted collectibles will appear here") onToggleFolding: root.flip2Folding()
onToggleSwitch: root.controller.arrangeByCollection = checked
} }
flickable2: ManageTokensListViewBase { placeholderText: qsTr("Your other collectibles will appear here")
objectName: "otherTokensListView"
width: doubleFlickable.width
model: root.controller.arrangeByCollection
? otherGroupedModel : otherNonGroupedModel
header: FoldableHeader {
objectName: "nonCommunityHeader"
width: ListView.view.width
title: qsTr("Other")
switchText: qsTr("Arrange by collection")
folded: doubleFlickable.flickable2Folded
checked: root.controller.arrangeByCollection
onToggleFolding: doubleFlickable.flip2Folding()
onToggleSwitch: root.controller.arrangeByCollection = checked
}
placeholderText: qsTr("Your other collectibles will appear here")
}
} }
DelegateModel { DelegateModel {