mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-20 10:38:47 +00:00
feat(HoldingsDropdown): airdrops tokens support added
This commit is contained in:
parent
da07230fa6
commit
1eda1911eb
@ -39,7 +39,7 @@ ColumnLayout {
|
|||||||
property int counter: 0
|
property int counter: 0
|
||||||
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id:listModel
|
id: listModel
|
||||||
}
|
}
|
||||||
|
|
||||||
addButton.onClicked: model.append(items[(counter++) % items.length])
|
addButton.onClicked: model.append(items[(counter++) % items.length])
|
||||||
|
@ -7,6 +7,10 @@ import Models 1.0
|
|||||||
|
|
||||||
import AppLayouts.Chat.controls.community 1.0
|
import AppLayouts.Chat.controls.community 1.0
|
||||||
|
|
||||||
|
import SortFilterProxyModel 0.2
|
||||||
|
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
SplitView {
|
SplitView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
@ -47,7 +51,49 @@ SplitView {
|
|||||||
parent: container
|
parent: container
|
||||||
anchors.centerIn: 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 {}
|
assetsModel: AssetsModel {}
|
||||||
isENSTab: isEnsTabChecker.checked
|
isENSTab: isEnsTabChecker.checked
|
||||||
isCollectiblesOnly: isCollectiblesOnlyChecker.checked
|
isCollectiblesOnly: isCollectiblesOnlyChecker.checked
|
||||||
@ -68,13 +114,19 @@ SplitView {
|
|||||||
RowLayout {
|
RowLayout {
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: isEnsTabChecker
|
id: isEnsTabChecker
|
||||||
text: "Is ENS tab visible?"
|
text: "ENS tab visible"
|
||||||
checked: true
|
checked: true
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: isCollectiblesOnlyChecker
|
id: isCollectiblesOnlyChecker
|
||||||
text: "Is collectibles only visible?"
|
text: "Collectibles only"
|
||||||
|
checked: false
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: isAirdropMode
|
||||||
|
text: "Airdrop mode"
|
||||||
checked: false
|
checked: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,12 @@ ListModel {
|
|||||||
name: "Anniversary",
|
name: "Anniversary",
|
||||||
category: TokenCategories.Category.Community
|
category: TokenCategories.Category.Community
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "Anniversary2",
|
||||||
|
iconSource: ModelsData.collectibles.anniversary,
|
||||||
|
name: "Anniversary2",
|
||||||
|
category: TokenCategories.Category.Community,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "CryptoKitties",
|
key: "CryptoKitties",
|
||||||
iconSource: ModelsData.collectibles.cryptoKitties,
|
iconSource: ModelsData.collectibles.cryptoKitties,
|
||||||
|
@ -497,7 +497,8 @@ Item {
|
|||||||
|
|
||||||
areSectionsVisible: !root.showAllTokensMode
|
areSectionsVisible: !root.showAllTokensMode
|
||||||
isFooterButtonVisible: !root.showAllTokensMode && !d.searchMode
|
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()
|
onHeaderItemClicked: root.navigateToMintTokenSettings()
|
||||||
onFooterButtonClicked: root.footerButtonClicked()
|
onFooterButtonClicked: root.footerButtonClicked()
|
||||||
|
@ -9,6 +9,7 @@ import StatusQ.Controls 0.1
|
|||||||
import StatusQ.Core.Utils 0.1
|
import StatusQ.Core.Utils 0.1
|
||||||
|
|
||||||
import AppLayouts.Chat.helpers 1.0
|
import AppLayouts.Chat.helpers 1.0
|
||||||
|
import utils 1.0
|
||||||
|
|
||||||
StatusDropdown {
|
StatusDropdown {
|
||||||
id: root
|
id: root
|
||||||
@ -368,6 +369,7 @@ StatusDropdown {
|
|||||||
tokenShortName: CommunityPermissionsHelpers.getTokenShortNameByKey(root.assetsModel, root.assetKey)
|
tokenShortName: CommunityPermissionsHelpers.getTokenShortNameByKey(root.assetsModel, root.assetKey)
|
||||||
tokenImage: CommunityPermissionsHelpers.getTokenIconByKey(root.assetsModel, root.assetKey)
|
tokenImage: CommunityPermissionsHelpers.getTokenIconByKey(root.assetsModel, root.assetKey)
|
||||||
amountText: d.assetAmountText
|
amountText: d.assetAmountText
|
||||||
|
|
||||||
tokenCategoryText: qsTr("Asset")
|
tokenCategoryText: qsTr("Asset")
|
||||||
addOrUpdateButtonEnabled: d.assetsReady
|
addOrUpdateButtonEnabled: d.assetsReady
|
||||||
mode: d.effectiveHoldingMode
|
mode: d.effectiveHoldingMode
|
||||||
@ -402,12 +404,38 @@ StatusDropdown {
|
|||||||
tokenName: CommunityPermissionsHelpers.getTokenNameByKey(root.collectiblesModel, root.collectibleKey)
|
tokenName: CommunityPermissionsHelpers.getTokenNameByKey(root.collectiblesModel, root.collectibleKey)
|
||||||
tokenShortName: ""
|
tokenShortName: ""
|
||||||
tokenImage: CommunityPermissionsHelpers.getTokenIconByKey(root.collectiblesModel, root.collectibleKey)
|
tokenImage: CommunityPermissionsHelpers.getTokenIconByKey(root.collectiblesModel, root.collectibleKey)
|
||||||
|
tokenAmount: CommunityPermissionsHelpers.getTokenAmountByKey(root.collectiblesModel, root.collectibleKey)
|
||||||
amountText: d.collectibleAmountText
|
amountText: d.collectibleAmountText
|
||||||
tokenCategoryText: qsTr("Collectible")
|
tokenCategoryText: qsTr("Collectible")
|
||||||
addOrUpdateButtonEnabled: d.collectiblesReady
|
addOrUpdateButtonEnabled: d.collectiblesReady
|
||||||
allowDecimals: false
|
allowDecimals: false
|
||||||
mode: d.effectiveHoldingMode
|
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
|
onEffectiveAmountChanged: root.collectibleAmount = effectiveAmount
|
||||||
onAmountTextChanged: d.collectibleAmountText = amountText
|
onAmountTextChanged: d.collectibleAmountText = amountText
|
||||||
onAddClicked: root.addCollectible(root.collectibleKey, root.collectibleAmount)
|
onAddClicked: root.addCollectible(root.collectibleKey, root.collectibleAmount)
|
||||||
|
@ -95,6 +95,7 @@ StatusListView {
|
|||||||
iconSource: model.iconSource ?? ""
|
iconSource: model.iconSource ?? ""
|
||||||
showSubItemsIcon: !!model.subItems && model.subItems.count > 0
|
showSubItemsIcon: !!model.subItems && model.subItems.count > 0
|
||||||
selected: root.checkedKeys.includes(model.key)
|
selected: root.checkedKeys.includes(model.key)
|
||||||
|
amount: !!model.infiniteSupply ? "∞" : model.supply ?? ""
|
||||||
|
|
||||||
onItemClicked: root.itemClicked(
|
onItemClicked: root.itemClicked(
|
||||||
model.key, name, shortName, iconSource, model.subItems)
|
model.key, name, shortName, iconSource, model.subItems)
|
||||||
|
@ -52,6 +52,17 @@ QtObject {
|
|||||||
return ""
|
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) {
|
function setHoldingsTextFormat(type, name, amount) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HoldingTypes.Type.Asset:
|
case HoldingTypes.Type.Asset:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user