feat(Mint/Airdrop Collectible): Implement Airdrop footer option
It enables navigation from mint token page to airdrop page selecting a specific collectible to be airdropped. It is now used `symbol` property as the identifier for a collectible but will be needed to update it to `key` once this key property is build in backend by hash(chainId + contractAddress). Closes #10047
This commit is contained in:
parent
4e5f7763db
commit
73b2ec2903
|
@ -22,11 +22,15 @@ SettingsPageLayout {
|
|||
signal airdropClicked(var airdropTokens, var addresses)
|
||||
signal navigateToMintTokenSettings
|
||||
|
||||
// TODO: Update with stackmanager when #8736 is integrated
|
||||
|
||||
function navigateBack() {
|
||||
stackManager.pop(StackView.Immediate)
|
||||
}
|
||||
|
||||
function selectCollectible(key, amount) {
|
||||
d.selectCollectible(key, amount)
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
|
@ -35,6 +39,8 @@ SettingsPageLayout {
|
|||
|
||||
readonly property string welcomePageTitle: qsTr("Airdrops")
|
||||
readonly property string newAirdropViewPageTitle: qsTr("New airdrop")
|
||||
|
||||
signal selectCollectible(string key, int amount)
|
||||
}
|
||||
|
||||
content: StackView {
|
||||
|
@ -92,6 +98,8 @@ SettingsPageLayout {
|
|||
id: newAirdropView
|
||||
|
||||
CommunityNewAirdropView {
|
||||
id: view
|
||||
|
||||
assetsModel: root.assetsModel
|
||||
collectiblesModel: root.collectiblesModel
|
||||
|
||||
|
@ -100,6 +108,8 @@ SettingsPageLayout {
|
|||
stackManager.clear(d.welcomeViewState, StackView.Immediate)
|
||||
}
|
||||
onNavigateToMintTokenSettings: root.navigateToMintTokenSettings()
|
||||
|
||||
Component.onCompleted: d.selectCollectible.connect(view.selectCollectible)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,12 +51,6 @@ SettingsPageLayout {
|
|||
|
||||
signal signMintTransactionOpened(int chainId, string accountAddress)
|
||||
|
||||
function setFeeLoading() {
|
||||
root.isFeeLoading = true
|
||||
root.feeText = ""
|
||||
root.errorText = ""
|
||||
}
|
||||
|
||||
signal remoteSelfDestructCollectibles(var holdersModel,
|
||||
int chainId,
|
||||
string accountName,
|
||||
|
@ -64,6 +58,14 @@ SettingsPageLayout {
|
|||
|
||||
signal signSelfDestructTransactionOpened(int chainId)
|
||||
|
||||
signal airdropCollectible(string key)
|
||||
|
||||
function setFeeLoading() {
|
||||
root.isFeeLoading = true
|
||||
root.feeText = ""
|
||||
root.errorText = ""
|
||||
}
|
||||
|
||||
function navigateBack() {
|
||||
stackManager.pop(StackView.Immediate)
|
||||
}
|
||||
|
@ -90,6 +92,8 @@ SettingsPageLayout {
|
|||
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
||||
onInitialItemChanged: updateInitialStackView()
|
||||
|
||||
signal airdropClicked()
|
||||
|
||||
function updateInitialStackView() {
|
||||
if(stackManager.stackView) {
|
||||
if(initialItem === welcomeView)
|
||||
|
@ -267,11 +271,12 @@ SettingsPageLayout {
|
|||
signSelfDestructPopup.close()
|
||||
}
|
||||
|
||||
airdropEnabled: false
|
||||
airdropEnabled: true
|
||||
retailEnabled: false
|
||||
remotelySelfDestructEnabled: true
|
||||
burnEnabled: false
|
||||
|
||||
onAirdropClicked: d.airdropClicked()
|
||||
onRemotelySelfDestructClicked: remoteSelfdestructPopup.open()
|
||||
|
||||
RemoteSelfDestructPopup {
|
||||
|
@ -387,6 +392,14 @@ SettingsPageLayout {
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: d
|
||||
|
||||
function onAirdropClicked() {
|
||||
root.airdropCollectible(view.symbol) // TODO: Backend. It should just be the key (hash(chainId + contractAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,6 +332,7 @@ StatusSectionLayout {
|
|||
accountName,
|
||||
accountAddress)
|
||||
}
|
||||
onAirdropCollectible: root.goTo(Constants.CommunitySettingsSections.Airdrops)
|
||||
|
||||
Connections {
|
||||
target: rootStore.communityTokensStore
|
||||
|
@ -385,6 +386,8 @@ StatusSectionLayout {
|
|||
}
|
||||
|
||||
CommunityAirdropsSettingsPanel {
|
||||
id: airdropPanel
|
||||
|
||||
readonly property CommunityTokensStore communityTokensStore:
|
||||
rootStore.communityTokensStore
|
||||
|
||||
|
@ -394,6 +397,18 @@ StatusSectionLayout {
|
|||
onPreviousPageNameChanged: root.backButtonName = previousPageName
|
||||
onAirdropClicked: communityTokensStore.airdrop(root.community.id, airdropTokens, addresses)
|
||||
onNavigateToMintTokenSettings: root.goTo(Constants.CommunitySettingsSections.MintTokens)
|
||||
|
||||
Connections {
|
||||
target: mintPanel
|
||||
|
||||
function onAirdropCollectible(key) {
|
||||
// Here it is forced a navigation to the new airdrop form, like if it was clicked the header button
|
||||
airdropPanel.headerButtonClicked()
|
||||
|
||||
// Force a token selection to be airdroped with default amount 1
|
||||
airdropPanel.selectCollectible(key, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: root.backButtonName = centerPanelContentLoader.item.children[d.currentIndex].previousPageName
|
||||
|
@ -412,8 +427,8 @@ StatusSectionLayout {
|
|||
|
||||
function goTo(section: int, subSection: int) {
|
||||
//find and enable section
|
||||
const matchingIndex = listView.model.findIndex((modelItem, index) => modelItem.id == section && modelItem.enabled)
|
||||
if(matchingIndex != -1) {
|
||||
const matchingIndex = listView.model.findIndex((modelItem, index) => modelItem.id === section && modelItem.enabled)
|
||||
if(matchingIndex !== -1) {
|
||||
d.currentIndex = matchingIndex
|
||||
//find and enable subsection if subSection navigation is available
|
||||
if(d.currentItem && d.currentItem.goTo) {
|
||||
|
|
|
@ -34,12 +34,24 @@ StatusScrollView {
|
|||
signal airdropClicked(var airdropTokens, var addresses)
|
||||
signal navigateToMintTokenSettings
|
||||
|
||||
function selectCollectible(key, amount) {
|
||||
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
||||
root.collectiblesModel, key)
|
||||
d.addItem(HoldingTypes.Type.Collectible, modelItem, amount)
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
readonly property int maxAirdropTokens: 5
|
||||
readonly property int dropdownHorizontalOffset: 4
|
||||
readonly property int dropdownVerticalOffset: 1
|
||||
|
||||
function addItem(type, item, amount) {
|
||||
const key = item.key
|
||||
|
||||
root.selectedHoldingsModel.append({ type, key, amount })
|
||||
}
|
||||
}
|
||||
|
||||
contentWidth: mainLayout.width
|
||||
|
@ -81,13 +93,6 @@ StatusScrollView {
|
|||
isCollectiblesOnly: true
|
||||
noDataText: qsTr("First you need to mint or import a collectible before you can perform an airdrop")
|
||||
|
||||
function addItem(type, item, amount) {
|
||||
const key = item.key
|
||||
|
||||
root.selectedHoldingsModel.append(
|
||||
{ type, key, amount })
|
||||
}
|
||||
|
||||
function getHoldingIndex(key) {
|
||||
return ModelUtils.indexOf(root.selectedHoldingsModel, "key", key)
|
||||
}
|
||||
|
@ -112,14 +117,14 @@ StatusScrollView {
|
|||
onAddAsset: {
|
||||
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
||||
root.assetsModel, key)
|
||||
addItem(HoldingTypes.Type.Asset, modelItem, amount)
|
||||
d.addItem(HoldingTypes.Type.Asset, modelItem, amount)
|
||||
dropdown.close()
|
||||
}
|
||||
|
||||
onAddCollectible: {
|
||||
const modelItem = CommunityPermissionsHelpers.getTokenByKey(
|
||||
root.collectiblesModel, key)
|
||||
addItem(HoldingTypes.Type.Collectible, modelItem, amount)
|
||||
d.addItem(HoldingTypes.Type.Collectible, modelItem, amount)
|
||||
dropdown.close()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue