2023-03-20 19:19:51 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml 2.15
|
2022-06-09 15:27:14 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-11-25 17:35:30 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2023-06-30 12:34:42 +00:00
|
|
|
import AppLayouts.Communities.controls 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.helpers 1.0
|
2023-04-25 20:27:33 +00:00
|
|
|
import utils 1.0
|
2022-12-06 11:19:20 +00:00
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
StatusDropdown {
|
|
|
|
id: root
|
|
|
|
|
2023-06-21 14:20:39 +00:00
|
|
|
property string communityId
|
2023-02-22 17:51:49 +00:00
|
|
|
property var assetsModel
|
|
|
|
property var collectiblesModel
|
2023-03-13 16:32:14 +00:00
|
|
|
property bool isENSTab: true
|
2023-03-23 18:26:38 +00:00
|
|
|
property string noDataText: {
|
2023-11-07 22:45:47 +00:00
|
|
|
if(d.currentHoldingType === Constants.TokenType.ERC20)
|
2023-06-14 07:19:45 +00:00
|
|
|
return noDataTextForAssets
|
2023-11-07 22:45:47 +00:00
|
|
|
if(d.currentHoldingType === Constants.TokenType.ERC721)
|
2023-06-14 07:19:45 +00:00
|
|
|
return noDataTextForCollectibles
|
2023-03-23 18:26:38 +00:00
|
|
|
return qsTr("No data found")
|
|
|
|
}
|
2023-06-14 07:19:45 +00:00
|
|
|
property string noDataTextForAssets: qsTr("No assets found")
|
|
|
|
property string noDataTextForCollectibles: qsTr("No collectibles found")
|
2023-02-22 17:51:49 +00:00
|
|
|
|
2023-07-27 13:42:12 +00:00
|
|
|
property alias allTokensMode: d.allTokensMode
|
|
|
|
|
2023-01-24 21:49:07 +00:00
|
|
|
property var usedTokens: []
|
|
|
|
property var usedEnsNames: []
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2023-01-12 13:18:52 +00:00
|
|
|
property string assetKey: ""
|
2023-08-10 12:23:59 +00:00
|
|
|
property string assetAmount: "0"
|
|
|
|
property int assetMultiplierIndex: 0
|
2022-09-15 10:12:38 +00:00
|
|
|
|
|
|
|
property string collectibleKey: ""
|
2023-08-10 12:23:59 +00:00
|
|
|
property string collectibleAmount: "1"
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2022-08-31 12:35:28 +00:00
|
|
|
property string ensDomainName: ""
|
2023-08-08 19:32:46 +00:00
|
|
|
property bool showTokenAmount: true
|
2022-08-31 12:35:28 +00:00
|
|
|
|
2023-08-10 12:23:59 +00:00
|
|
|
signal addAsset(string key, string amount)
|
|
|
|
signal addCollectible(string key, string amount)
|
2023-01-17 23:03:08 +00:00
|
|
|
signal addEns(string domain)
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2023-08-10 12:23:59 +00:00
|
|
|
signal updateAsset(string key, string amount)
|
|
|
|
signal updateCollectible(string key, string amount)
|
2023-01-17 23:03:08 +00:00
|
|
|
signal updateEns(string domain)
|
2022-09-07 09:40:25 +00:00
|
|
|
|
|
|
|
signal removeClicked
|
2023-06-14 07:19:45 +00:00
|
|
|
signal navigateToMintTokenSettings(bool isAssetType)
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
enum FlowType {
|
2023-03-23 21:45:45 +00:00
|
|
|
Selected, List_Deep1, List_Deep1_All, List_Deep2
|
2023-01-18 19:54:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openUpdateFlow() {
|
2023-01-24 21:49:07 +00:00
|
|
|
d.initialHoldingMode = HoldingTypes.Mode.UpdateOrRemove
|
2023-11-07 22:45:47 +00:00
|
|
|
if(d.currentHoldingType !== Constants.TokenType.ENS) {
|
2023-01-18 19:54:14 +00:00
|
|
|
if(statesStack.size === 0)
|
|
|
|
statesStack.push(HoldingsDropdown.FlowType.List_Deep1)
|
|
|
|
|
|
|
|
statesStack.push(HoldingsDropdown.FlowType.Selected)
|
|
|
|
}
|
|
|
|
open()
|
|
|
|
}
|
|
|
|
|
|
|
|
function setActiveTab(holdingType) {
|
2023-06-14 07:19:45 +00:00
|
|
|
d.currentHoldingType = holdingType
|
2023-01-18 19:54:14 +00:00
|
|
|
}
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
function reset() {
|
2023-11-07 22:45:47 +00:00
|
|
|
d.currentHoldingType = Constants.TokenType.ERC20
|
2023-01-24 21:49:07 +00:00
|
|
|
d.initialHoldingMode = HoldingTypes.Mode.Add
|
2023-01-18 19:54:14 +00:00
|
|
|
|
2023-01-12 13:18:52 +00:00
|
|
|
root.assetKey = ""
|
2022-09-07 09:40:25 +00:00
|
|
|
root.collectibleKey = ""
|
2022-08-31 12:35:28 +00:00
|
|
|
root.ensDomainName = ""
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-24 21:49:07 +00:00
|
|
|
d.setDefaultAmounts()
|
2023-01-18 19:54:14 +00:00
|
|
|
d.setInitialFlow()
|
2022-09-07 09:40:25 +00:00
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
// Internal management properties and signals:
|
2023-01-18 19:54:14 +00:00
|
|
|
readonly property var holdingTypes: [
|
2023-11-07 22:45:47 +00:00
|
|
|
Constants.TokenType.ERC20, Constants.TokenType.ERC721, Constants.TokenType.ENS
|
2023-01-18 19:54:14 +00:00
|
|
|
]
|
2023-03-13 16:32:14 +00:00
|
|
|
readonly property var tabsModel: [qsTr("Assets"), qsTr("Collectibles"), qsTr("ENS")]
|
|
|
|
readonly property var tabsModelNoEns: [qsTr("Assets"), qsTr("Collectibles")]
|
2023-08-10 12:23:59 +00:00
|
|
|
|
|
|
|
readonly property bool assetsReady: root.assetAmount !== "0" && root.assetKey
|
|
|
|
readonly property bool collectiblesReady: root.collectibleAmount !== "0" && root.collectibleKey
|
|
|
|
|
2023-01-17 23:03:08 +00:00
|
|
|
readonly property bool ensReady: d.ensDomainNameValid
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-01-12 13:18:52 +00:00
|
|
|
property int extendedDropdownType: ExtendedDropdownContent.Type.Assets
|
2023-11-07 22:45:47 +00:00
|
|
|
property int currentHoldingType: Constants.TokenType.ERC20
|
2023-01-24 21:49:07 +00:00
|
|
|
|
|
|
|
property bool updateSelected: false
|
|
|
|
|
|
|
|
property int initialHoldingMode: HoldingTypes.Mode.Add
|
|
|
|
property int effectiveHoldingMode: initialHoldingMode === HoldingTypes.Mode.UpdateOrRemove
|
|
|
|
? HoldingTypes.Mode.UpdateOrRemove
|
|
|
|
: (updateSelected ? HoldingTypes.Mode.Update : HoldingTypes.Mode.Add)
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
property bool extendedDeepNavigation: false
|
2023-03-23 21:45:45 +00:00
|
|
|
property bool allTokensMode: false
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
property var currentSubItems
|
|
|
|
property string currentItemKey: ""
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
property string assetAmountText: ""
|
|
|
|
property string collectibleAmountText: "1"
|
2022-09-07 09:40:25 +00:00
|
|
|
property bool ensDomainNameValid: false
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
// By design values:
|
2022-08-30 16:27:00 +00:00
|
|
|
readonly property int padding: 8
|
2022-06-09 15:27:14 +00:00
|
|
|
readonly property int defaultWidth: 289
|
2023-07-27 13:42:12 +00:00
|
|
|
readonly property int tabBarHeight: 36
|
2023-01-18 19:54:14 +00:00
|
|
|
readonly property int tabBarTextSize: 13
|
2022-09-07 09:40:25 +00:00
|
|
|
readonly property int backButtonWidth: 56
|
|
|
|
readonly property int backButtonHeight: 24
|
|
|
|
readonly property int backButtonToContentSpace: 8
|
2023-03-20 19:19:51 +00:00
|
|
|
readonly property int bottomInset: 20
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
function setInitialFlow() {
|
|
|
|
statesStack.clear()
|
2023-11-07 22:45:47 +00:00
|
|
|
if(d.currentHoldingType !== Constants.TokenType.ENS)
|
2023-01-18 19:54:14 +00:00
|
|
|
statesStack.push(HoldingsDropdown.FlowType.List_Deep1)
|
|
|
|
else
|
|
|
|
statesStack.push(HoldingsDropdown.FlowType.Selected)
|
|
|
|
}
|
2023-01-24 21:49:07 +00:00
|
|
|
|
|
|
|
function setDefaultAmounts() {
|
|
|
|
d.assetAmountText = ""
|
|
|
|
d.collectibleAmountText = ""
|
2023-08-10 12:23:59 +00:00
|
|
|
root.assetAmount = "0"
|
|
|
|
root.collectibleAmount = "1"
|
2023-01-24 21:49:07 +00:00
|
|
|
}
|
2023-03-20 19:19:51 +00:00
|
|
|
|
|
|
|
function forceLayout() {
|
|
|
|
root.height = 0 //setting height to 0 before because Popup cannot properly resize if the current contentHeight exceeds the available height
|
|
|
|
root.height = undefined //use implicit height
|
|
|
|
}
|
2022-09-07 09:40:25 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
StatesStack {
|
2022-09-07 09:40:25 +00:00
|
|
|
id: statesStack
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
width: d.defaultWidth
|
2023-07-27 13:42:12 +00:00
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: 0
|
|
|
|
topPadding: d.padding
|
2023-03-20 19:19:51 +00:00
|
|
|
bottomInset: d.bottomInset
|
2023-07-27 13:42:12 +00:00
|
|
|
bottomPadding: d.bottomInset + (loader.sourceComponent == listLayout ? 0 : d.padding)
|
2023-03-20 19:19:51 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
contentItem: ColumnLayout {
|
|
|
|
id: content
|
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
spacing: d.backButtonToContentSpace
|
2023-03-09 11:12:49 +00:00
|
|
|
state: statesStack.currentState
|
2022-08-30 16:27:00 +00:00
|
|
|
|
|
|
|
StatusIconTextButton {
|
|
|
|
id: backButton
|
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
Layout.preferredWidth: d.backButtonWidth
|
|
|
|
Layout.preferredHeight: d.backButtonHeight
|
2023-07-27 13:42:12 +00:00
|
|
|
Layout.leftMargin: d.padding
|
|
|
|
Layout.rightMargin: d.padding
|
2022-09-07 09:40:25 +00:00
|
|
|
visible: statesStack.size > 1
|
2022-08-30 16:27:00 +00:00
|
|
|
spacing: 0
|
2022-09-07 09:40:25 +00:00
|
|
|
leftPadding: 4
|
2023-04-17 09:35:44 +00:00
|
|
|
statusIcon: "previous"
|
2022-08-30 16:27:00 +00:00
|
|
|
icon.width: 12
|
|
|
|
icon.height: 12
|
|
|
|
text: qsTr("Back")
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
StatusSwitchTabBar {
|
|
|
|
id: tabBar
|
|
|
|
|
2023-06-14 07:19:45 +00:00
|
|
|
visible: !backButton.visible
|
2023-07-27 13:42:12 +00:00
|
|
|
Layout.preferredHeight: d.tabBarHeight
|
2023-01-18 19:54:14 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-27 13:42:12 +00:00
|
|
|
Layout.leftMargin: d.padding
|
|
|
|
Layout.rightMargin: d.padding
|
2023-01-18 19:54:14 +00:00
|
|
|
currentIndex: d.holdingTypes.indexOf(d.currentHoldingType)
|
|
|
|
state: d.currentHoldingType
|
|
|
|
states: [
|
|
|
|
State {
|
2023-11-07 22:45:47 +00:00
|
|
|
name: Constants.TokenType.ERC20
|
2023-01-18 19:54:14 +00:00
|
|
|
PropertyChanges {target: loader; sourceComponent: listLayout}
|
|
|
|
PropertyChanges {target: d; extendedDropdownType: ExtendedDropdownContent.Type.Assets}
|
|
|
|
},
|
|
|
|
State {
|
2023-11-07 22:45:47 +00:00
|
|
|
name: Constants.TokenType.ERC721
|
2023-01-18 19:54:14 +00:00
|
|
|
PropertyChanges {target: loader; sourceComponent: listLayout}
|
|
|
|
PropertyChanges {target: d; extendedDropdownType: ExtendedDropdownContent.Type.Collectibles}
|
|
|
|
},
|
|
|
|
State {
|
2023-11-07 22:45:47 +00:00
|
|
|
name: Constants.TokenType.ENS
|
2023-01-18 19:54:14 +00:00
|
|
|
PropertyChanges {target: loader; sourceComponent: ensLayout}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
onCurrentIndexChanged: {
|
2023-03-13 16:32:14 +00:00
|
|
|
if(currentIndex >= 0) {
|
2023-06-14 07:19:45 +00:00
|
|
|
d.currentHoldingType = d.holdingTypes[currentIndex]
|
2023-03-13 16:32:14 +00:00
|
|
|
d.setInitialFlow()
|
|
|
|
}
|
2023-01-18 19:54:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: tabLabelsRepeater
|
2023-03-13 16:32:14 +00:00
|
|
|
model: root.isENSTab ? d.tabsModel : d.tabsModelNoEns
|
2023-01-18 19:54:14 +00:00
|
|
|
|
|
|
|
StatusSwitchTabButton {
|
|
|
|
text: modelData
|
|
|
|
fontPixelSize: d.tabBarTextSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
Layout.fillWidth: true
|
2023-07-27 13:42:12 +00:00
|
|
|
Layout.leftMargin: loader.sourceComponent == listLayout ? 0 : d.padding
|
|
|
|
Layout.rightMargin: loader.sourceComponent == listLayout ? 0 : d.padding
|
2022-08-30 16:27:00 +00:00
|
|
|
Layout.fillHeight: true
|
2023-03-20 19:19:51 +00:00
|
|
|
onItemChanged: d.forceLayout()
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
states: [
|
|
|
|
State {
|
2023-01-18 19:54:14 +00:00
|
|
|
name: HoldingsDropdown.FlowType.Selected
|
2023-03-23 21:45:45 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: loader
|
|
|
|
sourceComponent: {
|
2023-11-07 22:45:47 +00:00
|
|
|
if (d.currentHoldingType === Constants.TokenType.ERC20)
|
2023-03-23 21:45:45 +00:00
|
|
|
return assetLayout
|
2023-11-07 22:45:47 +00:00
|
|
|
if (d.currentHoldingType === Constants.TokenType.ERC721)
|
2023-03-23 21:45:45 +00:00
|
|
|
return collectibleLayout
|
|
|
|
return ensLayout
|
|
|
|
}
|
|
|
|
}
|
2022-09-07 09:40:25 +00:00
|
|
|
},
|
|
|
|
State {
|
2023-01-18 19:54:14 +00:00
|
|
|
name: HoldingsDropdown.FlowType.List_Deep1
|
|
|
|
PropertyChanges {target: loader; sourceComponent: listLayout}
|
2023-03-13 16:32:14 +00:00
|
|
|
PropertyChanges {target: d; extendedDeepNavigation: false}
|
2022-08-30 16:27:00 +00:00
|
|
|
},
|
2023-03-23 21:45:45 +00:00
|
|
|
State {
|
|
|
|
name: HoldingsDropdown.FlowType.List_Deep1_All
|
|
|
|
extend: HoldingsDropdown.FlowType.List_Deep1
|
|
|
|
PropertyChanges {target: d; extendedDeepNavigation: false; allTokensMode: true }
|
|
|
|
},
|
2022-08-30 16:27:00 +00:00
|
|
|
State {
|
2023-01-18 19:54:14 +00:00
|
|
|
name: HoldingsDropdown.FlowType.List_Deep2
|
|
|
|
extend: HoldingsDropdown.FlowType.List_Deep1
|
|
|
|
PropertyChanges {target: d; extendedDeepNavigation: true}
|
2022-08-23 08:46:37 +00:00
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
onClosed: root.reset()
|
2023-03-23 16:10:56 +00:00
|
|
|
onIsENSTabChanged: root.reset()
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
Component {
|
|
|
|
id: listLayout
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
ExtendedDropdownContent {
|
|
|
|
id: listPanel
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-06-21 14:20:39 +00:00
|
|
|
communityId: root.communityId
|
2023-02-22 17:51:49 +00:00
|
|
|
assetsModel: root.assetsModel
|
|
|
|
collectiblesModel: root.collectiblesModel
|
2023-03-23 18:26:38 +00:00
|
|
|
noDataText: root.noDataText
|
2023-02-22 17:51:49 +00:00
|
|
|
|
2023-01-24 21:49:07 +00:00
|
|
|
checkedKeys: root.usedTokens.map(entry => entry.key)
|
2023-01-18 19:54:14 +00:00
|
|
|
type: d.extendedDropdownType
|
2023-03-23 21:45:45 +00:00
|
|
|
showAllTokensMode: d.allTokensMode
|
2023-08-08 19:32:46 +00:00
|
|
|
showTokenAmount: root.showTokenAmount
|
2023-03-23 21:45:45 +00:00
|
|
|
|
2023-03-24 13:54:58 +00:00
|
|
|
Binding on showAllTokensMode {
|
|
|
|
value: true
|
|
|
|
|
|
|
|
when: d.extendedDropdownType === ExtendedDropdownContent.Type.Assets
|
|
|
|
&& root.assetsModel.rowCount() > 0
|
|
|
|
&& ModelUtils.get(root.assetsModel, 0, "category") === TokenCategories.Category.General
|
|
|
|
}
|
|
|
|
|
|
|
|
Binding on showAllTokensMode {
|
|
|
|
value: true
|
|
|
|
|
|
|
|
when: d.extendedDropdownType === ExtendedDropdownContent.Type.Collectibles
|
|
|
|
&& root.collectiblesModel.rowCount() > 0
|
|
|
|
&& ModelUtils.get(root.collectiblesModel, 0, "category") === TokenCategories.Category.General
|
|
|
|
}
|
|
|
|
|
2024-05-28 13:11:29 +00:00
|
|
|
onTypeChanged: forceActiveFocus()
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
onItemClicked: {
|
2023-01-24 21:49:07 +00:00
|
|
|
d.assetAmountText = ""
|
|
|
|
d.collectibleAmountText = ""
|
|
|
|
|
|
|
|
if (checkedKeys.includes(key)) {
|
2024-05-29 17:59:13 +00:00
|
|
|
|
|
|
|
const amountBasicUnit = root.usedTokens.find(entry => entry.key === key).amount
|
|
|
|
const decimals = PermissionsHelpers.getTokenByKey(root.assetsModel, key).decimals
|
|
|
|
const amount = AmountsArithmetic.toNumber(amountBasicUnit, decimals)
|
2023-01-24 21:49:07 +00:00
|
|
|
|
|
|
|
if(d.extendedDropdownType === ExtendedDropdownContent.Type.Assets)
|
|
|
|
root.assetAmount = amount
|
|
|
|
else
|
|
|
|
root.collectibleAmount = amount
|
|
|
|
|
|
|
|
d.updateSelected = true
|
|
|
|
} else {
|
|
|
|
d.setDefaultAmounts()
|
|
|
|
d.updateSelected = false
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
if(d.extendedDropdownType === ExtendedDropdownContent.Type.Assets)
|
|
|
|
root.assetKey = key
|
|
|
|
else
|
2023-08-08 19:32:46 +00:00
|
|
|
{
|
2023-01-18 19:54:14 +00:00
|
|
|
root.collectibleKey = key
|
2023-08-18 10:00:46 +00:00
|
|
|
const item = PermissionsHelpers.getTokenByKey(root.collectiblesModel, root.collectibleKey)
|
|
|
|
|
2023-08-08 19:32:46 +00:00
|
|
|
//When the collectible is unique, there is no need for the user to select amount
|
|
|
|
//Just send the add/update events
|
2024-05-13 10:59:49 +00:00
|
|
|
if((!item.infiniteSupply && (item.supply && item.supply.toString() === "1")
|
|
|
|
|| (item.remainingSupply && item.remainingSupply.toString() === "1"))) {
|
2023-08-18 10:00:46 +00:00
|
|
|
root.collectibleAmount = "1"
|
|
|
|
d.updateSelected ? root.updateCollectible(root.collectibleKey, "1")
|
2023-11-29 15:48:33 +00:00
|
|
|
: root.addCollectible(root.collectibleKey, "1")
|
2023-08-08 19:32:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
statesStack.push(HoldingsDropdown.FlowType.Selected)
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
onNavigateDeep: {
|
|
|
|
d.currentSubItems = subItems
|
|
|
|
d.currentItemKey = key
|
|
|
|
statesStack.push(HoldingsDropdown.FlowType.List_Deep2)
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-03-23 21:45:45 +00:00
|
|
|
onFooterButtonClicked: statesStack.push(
|
|
|
|
HoldingsDropdown.FlowType.List_Deep1_All)
|
|
|
|
|
2023-03-20 19:19:51 +00:00
|
|
|
onLayoutChanged: d.forceLayout()
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
if(d.extendedDeepNavigation)
|
|
|
|
listPanel.goForward(d.currentItemKey,
|
2023-06-26 11:48:45 +00:00
|
|
|
PermissionsHelpers.getTokenNameByKey(root.collectiblesModel, d.currentItemKey),
|
|
|
|
PermissionsHelpers.getTokenIconByKey(root.collectiblesModel, d.currentItemKey),
|
2023-01-18 19:54:14 +00:00
|
|
|
d.currentSubItems)
|
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-06-14 07:19:45 +00:00
|
|
|
onNavigateToMintTokenSettings: root.navigateToMintTokenSettings(type === ExtendedDropdownContent.Type.Assets)
|
2023-03-24 12:41:46 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
Connections {
|
|
|
|
target: backButton
|
|
|
|
|
|
|
|
function onClicked() {
|
2023-01-18 19:54:14 +00:00
|
|
|
if (listPanel.canGoBack)
|
|
|
|
listPanel.goBack()
|
2023-03-23 21:45:45 +00:00
|
|
|
|
2022-09-07 09:40:25 +00:00
|
|
|
statesStack.pop()
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-18 19:54:14 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root
|
|
|
|
|
|
|
|
function onClosed() { listPanel.goBack() }
|
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2023-01-18 19:54:14 +00:00
|
|
|
id: assetLayout
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
TokenPanel {
|
|
|
|
id: assetPanel
|
2022-09-15 10:12:38 +00:00
|
|
|
|
2023-08-10 12:23:59 +00:00
|
|
|
readonly property string effectiveAmount: amountValid ? amount : "0"
|
|
|
|
property bool completed: false
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
tokenName: PermissionsHelpers.getTokenNameByKey(root.assetsModel, root.assetKey)
|
|
|
|
tokenShortName: PermissionsHelpers.getTokenShortNameByKey(root.assetsModel, root.assetKey)
|
|
|
|
tokenImage: PermissionsHelpers.getTokenIconByKey(root.assetsModel, root.assetKey)
|
2024-05-28 13:11:29 +00:00
|
|
|
tokenDecimals: PermissionsHelpers.getTokenDecimalsByKey(root.assetsModel, root.assetKey)
|
2023-08-18 10:00:46 +00:00
|
|
|
tokenAmount: PermissionsHelpers.getTokenRemainingSupplyByKey(root.assetsModel, root.assetKey)
|
2023-01-18 19:54:14 +00:00
|
|
|
amountText: d.assetAmountText
|
|
|
|
tokenCategoryText: qsTr("Asset")
|
|
|
|
addOrUpdateButtonEnabled: d.assetsReady
|
2023-01-24 21:49:07 +00:00
|
|
|
mode: d.effectiveHoldingMode
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-06-14 07:19:45 +00:00
|
|
|
ListModel {
|
|
|
|
Component.onCompleted: {
|
2023-06-26 11:48:45 +00:00
|
|
|
const asset = PermissionsHelpers.getTokenByKey(
|
2023-06-14 07:19:45 +00:00
|
|
|
root.assetsModel,
|
|
|
|
root.assetKey)
|
|
|
|
|
|
|
|
if (!asset)
|
|
|
|
return
|
|
|
|
|
|
|
|
const chainName = asset.chainName ?? ""
|
|
|
|
const chainIcon = asset.chainIcon
|
|
|
|
? Style.svg(asset.chainIcon) : ""
|
|
|
|
|
|
|
|
if (!chainName)
|
|
|
|
return
|
|
|
|
|
|
|
|
append({
|
2023-08-10 12:23:59 +00:00
|
|
|
name: chainName,
|
2023-06-14 07:19:45 +00:00
|
|
|
icon: chainIcon,
|
2023-08-18 10:00:46 +00:00
|
|
|
amount: asset.remainingSupply,
|
2024-03-05 14:12:03 +00:00
|
|
|
decimals: asset.decimals,
|
2023-08-10 12:23:59 +00:00
|
|
|
multiplierIndex: asset.multiplierIndex,
|
2023-06-14 07:19:45 +00:00
|
|
|
infiniteAmount: asset.infiniteSupply
|
|
|
|
})
|
|
|
|
|
|
|
|
assetPanel.networksModel = this
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-10 12:23:59 +00:00
|
|
|
onEffectiveAmountChanged: {
|
|
|
|
if (completed)
|
|
|
|
root.assetAmount = effectiveAmount
|
|
|
|
}
|
|
|
|
|
|
|
|
onMultiplierIndexChanged: root.assetMultiplierIndex = multiplierIndex
|
2023-01-18 19:54:14 +00:00
|
|
|
onAmountTextChanged: d.assetAmountText = amountText
|
|
|
|
onAddClicked: root.addAsset(root.assetKey, root.assetAmount)
|
|
|
|
onUpdateClicked: root.updateAsset(root.assetKey, root.assetAmount)
|
|
|
|
onRemoveClicked: root.removeClicked()
|
2022-09-15 10:12:38 +00:00
|
|
|
|
|
|
|
Connections {
|
2023-01-18 19:54:14 +00:00
|
|
|
target: backButton
|
2022-09-15 10:12:38 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
function onClicked() { statesStack.pop() }
|
2022-09-15 10:12:38 +00:00
|
|
|
}
|
2023-03-23 21:45:45 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2023-08-10 12:23:59 +00:00
|
|
|
completed = true
|
|
|
|
|
|
|
|
if (d.assetAmountText.length === 0 && root.assetAmount !== "0")
|
|
|
|
assetPanel.setAmount(root.assetAmount,
|
|
|
|
root.assetMultiplierIndex)
|
2023-03-23 21:45:45 +00:00
|
|
|
}
|
2022-08-30 16:27:00 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
Component {
|
2023-01-18 19:54:14 +00:00
|
|
|
id: collectibleLayout
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
TokenPanel {
|
|
|
|
id: collectiblePanel
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-08-10 12:23:59 +00:00
|
|
|
readonly property string effectiveAmount: amountValid ? amount : "0"
|
|
|
|
property bool completed: false
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-06-26 11:48:45 +00:00
|
|
|
tokenName: PermissionsHelpers.getTokenNameByKey(root.collectiblesModel, root.collectibleKey)
|
2023-01-18 19:54:14 +00:00
|
|
|
tokenShortName: ""
|
2023-06-26 11:48:45 +00:00
|
|
|
tokenImage: PermissionsHelpers.getTokenIconByKey(root.collectiblesModel, root.collectibleKey)
|
2023-08-18 10:00:46 +00:00
|
|
|
tokenAmount: PermissionsHelpers.getTokenRemainingSupplyByKey(root.collectiblesModel, root.collectibleKey)
|
2024-05-28 13:11:29 +00:00
|
|
|
tokenDecimals: PermissionsHelpers.getTokenDecimalsByKey(root.collectiblesModel, root.assetKey)
|
2023-01-18 19:54:14 +00:00
|
|
|
amountText: d.collectibleAmountText
|
|
|
|
tokenCategoryText: qsTr("Collectible")
|
|
|
|
addOrUpdateButtonEnabled: d.collectiblesReady
|
|
|
|
allowDecimals: false
|
2023-01-24 21:49:07 +00:00
|
|
|
mode: d.effectiveHoldingMode
|
2022-08-30 16:27:00 +00:00
|
|
|
|
2023-04-25 20:27:33 +00:00
|
|
|
ListModel {
|
|
|
|
Component.onCompleted: {
|
2023-06-26 11:48:45 +00:00
|
|
|
const collectible = PermissionsHelpers.getTokenByKey(
|
2023-04-25 20:27:33 +00:00
|
|
|
root.collectiblesModel,
|
|
|
|
root.collectibleKey)
|
|
|
|
|
|
|
|
if (!collectible)
|
|
|
|
return
|
|
|
|
|
|
|
|
const chainName = collectible.chainName ?? ""
|
|
|
|
const chainIcon = collectible.chainIcon
|
|
|
|
? Style.svg(collectible.chainIcon) : ""
|
|
|
|
|
|
|
|
if (!chainName)
|
|
|
|
return
|
|
|
|
|
|
|
|
append({
|
|
|
|
name:chainName,
|
2023-04-27 21:38:09 +00:00
|
|
|
icon: chainIcon,
|
2023-08-18 10:00:46 +00:00
|
|
|
amount: collectible.remainingSupply,
|
2023-08-10 12:23:59 +00:00
|
|
|
multiplierIndex: collectible.multiplierIndex,
|
2023-04-27 21:38:09 +00:00
|
|
|
infiniteAmount: collectible.infiniteSupply
|
2023-04-25 20:27:33 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
collectiblePanel.networksModel = this
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-10 12:23:59 +00:00
|
|
|
onEffectiveAmountChanged: {
|
|
|
|
if (completed)
|
|
|
|
root.collectibleAmount = effectiveAmount
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
onAmountTextChanged: d.collectibleAmountText = amountText
|
|
|
|
onAddClicked: root.addCollectible(root.collectibleKey, root.collectibleAmount)
|
|
|
|
onUpdateClicked: root.updateCollectible(root.collectibleKey, root.collectibleAmount)
|
|
|
|
onRemoveClicked: root.removeClicked()
|
2022-08-23 08:46:37 +00:00
|
|
|
|
2022-09-15 10:12:38 +00:00
|
|
|
Component.onCompleted: {
|
2023-08-10 12:23:59 +00:00
|
|
|
completed = true
|
|
|
|
|
2023-03-13 16:32:14 +00:00
|
|
|
if (d.collectibleAmountText.length === 0 && root.collectibleAmount)
|
|
|
|
collectiblePanel.setAmount(root.collectibleAmount)
|
2022-09-15 10:12:38 +00:00
|
|
|
}
|
|
|
|
|
2022-08-30 16:27:00 +00:00
|
|
|
Connections {
|
2023-01-18 19:54:14 +00:00
|
|
|
target: backButton
|
2022-09-07 09:40:25 +00:00
|
|
|
|
2023-01-18 19:54:14 +00:00
|
|
|
function onClicked() { statesStack.pop() }
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2022-08-23 08:46:37 +00:00
|
|
|
id: ensLayout
|
2022-08-31 12:35:28 +00:00
|
|
|
|
|
|
|
EnsPanel {
|
2023-01-18 19:54:14 +00:00
|
|
|
addButtonEnabled: d.ensReady
|
2022-08-31 12:35:28 +00:00
|
|
|
domainName: root.ensDomainName
|
2023-01-24 21:49:07 +00:00
|
|
|
mode: d.initialHoldingMode
|
|
|
|
reservedNames: root.usedEnsNames
|
2023-01-18 19:54:14 +00:00
|
|
|
|
2022-08-31 12:35:28 +00:00
|
|
|
onDomainNameChanged: root.ensDomainName = domainName
|
2022-09-07 09:40:25 +00:00
|
|
|
onDomainNameValidChanged: d.ensDomainNameValid = domainNameValid
|
2023-01-18 19:54:14 +00:00
|
|
|
onAddClicked: root.addEns(root.ensDomainName)
|
|
|
|
onUpdateClicked: root.updateEns(root.ensDomainName)
|
|
|
|
onRemoveClicked: root.removeClicked()
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|
2022-09-15 10:12:38 +00:00
|
|
|
}
|
2022-06-09 15:27:14 +00:00
|
|
|
}
|