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
ManageCollectiblesPanel {
width: 500
height: contentItem.contentHeight
height: contentHeight
controller: ManageTokensController {
sourceModel: renamedModel
settingsKey: "WalletCollectibles"

View File

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

View File

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