feat(HoldingsDropdown): airdrops tokens support added
This commit is contained in:
parent
da07230fa6
commit
1eda1911eb
|
@ -39,7 +39,7 @@ ColumnLayout {
|
|||
property int counter: 0
|
||||
|
||||
model: ListModel {
|
||||
id:listModel
|
||||
id: listModel
|
||||
}
|
||||
|
||||
addButton.onClicked: model.append(items[(counter++) % items.length])
|
||||
|
|
|
@ -7,6 +7,10 @@ import Models 1.0
|
|||
|
||||
import AppLayouts.Chat.controls.community 1.0
|
||||
|
||||
import SortFilterProxyModel 0.2
|
||||
|
||||
import utils 1.0
|
||||
|
||||
SplitView {
|
||||
id: root
|
||||
|
||||
|
@ -47,7 +51,49 @@ SplitView {
|
|||
parent: container
|
||||
anchors.centerIn: container
|
||||
|
||||
collectiblesModel: CollectiblesModel {}
|
||||
CollectiblesModel {
|
||||
id: collectiblesModel
|
||||
}
|
||||
|
||||
SortFilterProxyModel {
|
||||
id: collectiblesModelWithSupply
|
||||
|
||||
sourceModel: collectiblesModel
|
||||
|
||||
proxyRoles: [
|
||||
ExpressionRole {
|
||||
name: "supply"
|
||||
expression: ((model.index + 1) * 115).toString()
|
||||
},
|
||||
ExpressionRole {
|
||||
name: "infiniteSupply"
|
||||
expression: !(model.index % 4)
|
||||
},
|
||||
ExpressionRole {
|
||||
name: "chainName"
|
||||
expression: model.index ? "Optimism" : "Arbitrum"
|
||||
},
|
||||
ExpressionRole {
|
||||
|
||||
readonly property string icon1: Style.svg("network/Network=Optimism")
|
||||
readonly property string icon2: Style.svg("network/Network=Arbitrum")
|
||||
|
||||
name: "chainIcon"
|
||||
expression: model.index ? icon1 : icon2
|
||||
}
|
||||
]
|
||||
|
||||
filters: ValueFilter {
|
||||
roleName: "category"
|
||||
value: TokenCategories.Category.Community
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
collectiblesModel: isAirdropMode.checked
|
||||
? collectiblesModelWithSupply
|
||||
: collectiblesModel
|
||||
|
||||
assetsModel: AssetsModel {}
|
||||
isENSTab: isEnsTabChecker.checked
|
||||
isCollectiblesOnly: isCollectiblesOnlyChecker.checked
|
||||
|
@ -68,13 +114,19 @@ SplitView {
|
|||
RowLayout {
|
||||
CheckBox {
|
||||
id: isEnsTabChecker
|
||||
text: "Is ENS tab visible?"
|
||||
text: "ENS tab visible"
|
||||
checked: true
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: isCollectiblesOnlyChecker
|
||||
text: "Is collectibles only visible?"
|
||||
text: "Collectibles only"
|
||||
checked: false
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: isAirdropMode
|
||||
text: "Airdrop mode"
|
||||
checked: false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,12 @@ ListModel {
|
|||
name: "Anniversary",
|
||||
category: TokenCategories.Category.Community
|
||||
},
|
||||
{
|
||||
key: "Anniversary2",
|
||||
iconSource: ModelsData.collectibles.anniversary,
|
||||
name: "Anniversary2",
|
||||
category: TokenCategories.Category.Community,
|
||||
},
|
||||
{
|
||||
key: "CryptoKitties",
|
||||
iconSource: ModelsData.collectibles.cryptoKitties,
|
||||
|
|
|
@ -497,7 +497,8 @@ Item {
|
|||
|
||||
areSectionsVisible: !root.showAllTokensMode
|
||||
isFooterButtonVisible: !root.showAllTokensMode && !d.searchMode
|
||||
&& filteredModel.item && d.currentModel.count > filteredModel.item.count
|
||||
&& filteredModel.item && d.currentModel
|
||||
&& d.currentModel.count > filteredModel.item.count
|
||||
|
||||
onHeaderItemClicked: root.navigateToMintTokenSettings()
|
||||
onFooterButtonClicked: root.footerButtonClicked()
|
||||
|
|
|
@ -9,6 +9,7 @@ import StatusQ.Controls 0.1
|
|||
import StatusQ.Core.Utils 0.1
|
||||
|
||||
import AppLayouts.Chat.helpers 1.0
|
||||
import utils 1.0
|
||||
|
||||
StatusDropdown {
|
||||
id: root
|
||||
|
@ -368,6 +369,7 @@ StatusDropdown {
|
|||
tokenShortName: CommunityPermissionsHelpers.getTokenShortNameByKey(root.assetsModel, root.assetKey)
|
||||
tokenImage: CommunityPermissionsHelpers.getTokenIconByKey(root.assetsModel, root.assetKey)
|
||||
amountText: d.assetAmountText
|
||||
|
||||
tokenCategoryText: qsTr("Asset")
|
||||
addOrUpdateButtonEnabled: d.assetsReady
|
||||
mode: d.effectiveHoldingMode
|
||||
|
@ -402,12 +404,38 @@ StatusDropdown {
|
|||
tokenName: CommunityPermissionsHelpers.getTokenNameByKey(root.collectiblesModel, root.collectibleKey)
|
||||
tokenShortName: ""
|
||||
tokenImage: CommunityPermissionsHelpers.getTokenIconByKey(root.collectiblesModel, root.collectibleKey)
|
||||
tokenAmount: CommunityPermissionsHelpers.getTokenAmountByKey(root.collectiblesModel, root.collectibleKey)
|
||||
amountText: d.collectibleAmountText
|
||||
tokenCategoryText: qsTr("Collectible")
|
||||
addOrUpdateButtonEnabled: d.collectiblesReady
|
||||
allowDecimals: false
|
||||
mode: d.effectiveHoldingMode
|
||||
|
||||
ListModel {
|
||||
Component.onCompleted: {
|
||||
const collectible = CommunityPermissionsHelpers.getTokenByKey(
|
||||
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,
|
||||
icon: chainIcon
|
||||
})
|
||||
|
||||
collectiblePanel.networksModel = this
|
||||
}
|
||||
}
|
||||
|
||||
onEffectiveAmountChanged: root.collectibleAmount = effectiveAmount
|
||||
onAmountTextChanged: d.collectibleAmountText = amountText
|
||||
onAddClicked: root.addCollectible(root.collectibleKey, root.collectibleAmount)
|
||||
|
|
|
@ -95,6 +95,7 @@ StatusListView {
|
|||
iconSource: model.iconSource ?? ""
|
||||
showSubItemsIcon: !!model.subItems && model.subItems.count > 0
|
||||
selected: root.checkedKeys.includes(model.key)
|
||||
amount: !!model.infiniteSupply ? "∞" : model.supply ?? ""
|
||||
|
||||
onItemClicked: root.itemClicked(
|
||||
model.key, name, shortName, iconSource, model.subItems)
|
||||
|
|
|
@ -52,6 +52,17 @@ QtObject {
|
|||
return ""
|
||||
}
|
||||
|
||||
function getTokenAmountByKey(model, key) {
|
||||
const item = getTokenByKey(model, key)
|
||||
if (item) {
|
||||
if (item.infiniteSupply === true)
|
||||
return "∞"
|
||||
|
||||
return item.supply ?? ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
function setHoldingsTextFormat(type, name, amount) {
|
||||
switch (type) {
|
||||
case HoldingTypes.Type.Asset:
|
||||
|
|
Loading…
Reference in New Issue