2023-06-30 09:00:04 +00:00
import QtQuick 2.15
import QtQuick . Controls 2.15
2023-03-13 16:32:14 +00:00
import StatusQ . Controls 0.1
2023-06-23 06:17:04 +00:00
import AppLayouts . Communities . layouts 1.0
import AppLayouts . Communities . views 1.0
2023-03-13 16:32:14 +00:00
import utils 1.0
2023-06-30 09:00:04 +00:00
StackView {
2023-03-13 16:32:14 +00:00
id: root
2023-06-21 14:20:39 +00:00
// id, name, image, color, owner properties expected
required property var communityDetails
2023-07-06 12:33:27 +00:00
required property bool isOwner
2023-07-13 15:51:53 +00:00
required property bool isTokenMasterOwner
required property bool isAdmin
2023-06-21 14:20:39 +00:00
2023-03-13 16:32:14 +00:00
// Token models:
required property var assetsModel
required property var collectiblesModel
2023-07-06 12:33:27 +00:00
required property var tokensModel // Community minted tokens model
2023-03-13 16:32:14 +00:00
2023-04-25 21:24:04 +00:00
required property var membersModel
2023-06-06 15:32:53 +00:00
// JS object specifing fees for the airdrop operation, should be set to
// provide response to airdropFeesRequested signal.
2023-06-26 11:48:45 +00:00
// Refer EditAirdropView::airdropFees for details.
2023-06-06 15:32:53 +00:00
property var airdropFees: null
2023-03-13 16:32:14 +00:00
property int viewWidth: 560 // by design
2023-06-30 09:00:04 +00:00
property string previousPageName: depth > 1 ? qsTr ( "Airdrops" ) : ""
2023-03-13 16:32:14 +00:00
2023-04-25 21:24:04 +00:00
signal airdropClicked ( var airdropTokens , var addresses , var membersPubKeys )
2023-06-06 15:32:53 +00:00
signal airdropFeesRequested ( var contractKeysAndAmounts , var addresses )
2023-06-14 07:19:45 +00:00
signal navigateToMintTokenSettings ( bool isAssetType )
2023-04-17 12:11:31 +00:00
2023-03-13 16:32:14 +00:00
function navigateBack ( ) {
2023-06-30 09:00:04 +00:00
pop ( StackView . Immediate )
2023-03-13 16:32:14 +00:00
}
2023-06-01 10:38:56 +00:00
function selectToken ( key , amount , type ) {
2023-06-30 09:00:04 +00:00
if ( depth > 1 )
pop ( StackView . Immediate )
root . push ( newAirdropView , StackView . Immediate )
2023-06-01 10:38:56 +00:00
d . selectToken ( key , amount , type )
2023-04-17 12:11:31 +00:00
}
2023-06-05 13:49:36 +00:00
function addAddresses ( addresses ) {
d . addAddresses ( addresses )
}
2023-03-13 16:32:14 +00:00
QtObject {
id: d
2023-07-13 15:51:53 +00:00
readonly property bool isAdminOnly: root . isAdmin && ! root . isOwner && ! root . isTokenMasterOwner
2023-06-01 10:38:56 +00:00
signal selectToken ( string key , int amount , int type )
2023-06-05 13:49:36 +00:00
signal addAddresses ( var addresses )
2023-03-13 16:32:14 +00:00
}
2023-06-30 09:00:04 +00:00
initialItem: SettingsPage {
implicitWidth: 0
2023-06-30 14:36:46 +00:00
title: qsTr ( "Airdrops" )
2023-03-13 16:32:14 +00:00
2023-06-30 09:00:04 +00:00
buttons: StatusButton {
2023-07-13 15:51:53 +00:00
2023-06-30 15:10:45 +00:00
objectName: "addNewItemButton"
2023-06-30 09:00:04 +00:00
text: qsTr ( "New Airdrop" )
2023-07-13 15:51:53 +00:00
enabled: ! d . isAdminOnly && root . tokensModel . count > 0 // TODO: Replace to checker to ensure owner token is deployed
2023-03-13 16:32:14 +00:00
2023-06-30 09:00:04 +00:00
onClicked: root . push ( newAirdropView , StackView . Immediate )
2023-03-13 16:32:14 +00:00
}
2023-06-30 09:00:04 +00:00
contentItem: WelcomeSettingsView {
2023-03-13 16:32:14 +00:00
viewWidth: root . viewWidth
image: Style . png ( "community/airdrops8_1" )
title: qsTr ( "Airdrop community tokens" )
subtitle: qsTr ( "You can mint custom tokens and collectibles for your community" )
checkersModel: [
qsTr ( "Reward individual members with custom tokens for their contribution" ) ,
qsTr ( "Incentivise joining, retention, moderation and desired behaviour" ) ,
qsTr ( "Require holding a token or NFT to obtain exclusive membership rights" )
]
2023-07-13 15:51:53 +00:00
infoBoxVisible: d . isAdminOnly || ( ( root . isOwner || root . isTokenMasterOwner ) && root . tokensModel . count === 0 ) // TODO: Replace to checker to ensure owner token is NOT deployed yet
2023-07-06 12:33:27 +00:00
infoBoxTitle: qsTr ( "Get started" )
2023-07-13 15:51:53 +00:00
infoBoxText: d . isAdminOnly ? qsTr ( "Token airdropping can only be performed by admins that hodl the Community’ s TokenMaster token. If you would like this permission, contact the Community founder (they will need to mint the Community Owner token before they can airdrop this to you)." ) :
qsTr ( "In order to Mint, Import and Airdrop community tokens, you first need to mint your Owner token which will give you permissions to access the token management features for your community." )
2023-07-06 12:33:27 +00:00
buttonText: qsTr ( "Mint Owner token" )
2023-07-13 15:51:53 +00:00
buttonVisible: root . isOwner
onClicked: root . navigateToMintTokenSettings ( false )
2023-03-13 16:32:14 +00:00
}
}
Component {
id: newAirdropView
2023-06-30 09:00:04 +00:00
SettingsPage {
2023-06-30 14:36:46 +00:00
title: qsTr ( "New airdrop" )
2023-04-17 12:11:31 +00:00
2023-06-30 09:00:04 +00:00
contentItem: EditAirdropView {
id: view
2023-03-13 16:32:14 +00:00
2023-06-30 09:00:04 +00:00
padding: 0
2023-06-06 15:32:53 +00:00
2023-06-30 09:00:04 +00:00
communityDetails: root . communityDetails
assetsModel: root . assetsModel
collectiblesModel: root . collectiblesModel
membersModel: root . membersModel
Binding on airdropFees {
value: root . airdropFees
}
onAirdropClicked: {
root . airdropClicked ( airdropTokens , addresses , membersPubKeys )
root . pop ( StackView . Immediate )
}
onNavigateToMintTokenSettings: root . navigateToMintTokenSettings ( isAssetType )
2023-04-17 12:11:31 +00:00
2023-06-30 09:00:04 +00:00
Component.onCompleted: {
d . selectToken . connect ( view . selectToken )
d . addAddresses . connect ( view . addAddresses )
airdropFeesRequested . connect ( root . airdropFeesRequested )
}
2023-06-05 13:49:36 +00:00
}
2023-03-13 16:32:14 +00:00
}
}
}