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-09-01 04:28:50 +00:00
import AppLayouts . Communities . helpers 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-18 17:34:57 +00:00
// User profiles
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-07-18 17:34:57 +00:00
readonly property bool isPrivilegedTokenOwnerProfile: root . isOwner || root . isTokenMasterOwner
// Owner and TMaster token related properties:
readonly property bool arePrivilegedTokensDeployed: root . isOwnerTokenDeployed && root . isTMasterTokenDeployed
property bool isOwnerTokenDeployed: false
property bool isTMasterTokenDeployed: false
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-04-25 21:24:04 +00:00
required property var membersModel
2023-07-25 14:14:42 +00:00
required property var accountsModel
2023-04-25 21:24:04 +00:00
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-07-20 19:58:51 +00:00
signal airdropClicked ( var airdropTokens , var addresses , string feeAccountAddress )
2023-06-14 07:19:45 +00:00
signal navigateToMintTokenSettings ( bool isAssetType )
2023-09-01 09:27:44 +00:00
signal registerAirdropFeeSubscriber ( var feeSubscriber )
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-18 17:34:57 +00:00
readonly property bool isAdminOnly: root . isAdmin && ! root . isPrivilegedTokenOwnerProfile
2023-09-01 04:28:50 +00:00
property AirdropFeesSubscriber aidropFeeSubscriber: null
2023-08-10 12:23:59 +00:00
signal selectToken ( string key , string 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-07-18 17:34:57 +00:00
buttons: [
StatusButton {
objectName: "addNewItemButton"
text: qsTr ( "New Airdrop" )
enabled: ! d . isAdminOnly && root . arePrivilegedTokensDeployed
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-18 17:34:57 +00:00
infoBoxVisible: d . isAdminOnly || ( root . isPrivilegedTokenOwnerProfile && ! root . arePrivilegedTokensDeployed )
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)." ) :
2023-07-18 17:34:57 +00:00
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
2023-07-25 14:14:42 +00:00
accountsModel: root . accountsModel
2023-09-01 04:28:50 +00:00
totalFeeText: feesSubscriber . totalFee
feeErrorText: feesSubscriber . feesError
feesPerSelectedContract: feesSubscriber . feesPerContract
feesAvailable: ! ! feesSubscriber . airdropFeesResponse
2023-06-30 09:00:04 +00:00
onAirdropClicked: {
2023-07-20 19:58:51 +00:00
root . airdropClicked ( airdropTokens , addresses , feeAccountAddress )
2023-06-30 09:00:04 +00:00
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 )
2023-09-01 04:28:50 +00:00
}
AirdropFeesSubscriber {
id: feesSubscriber
enabled: view . visible && view . showingFees
communityId: view . communityDetails . id
contractKeysAndAmounts: view . selectedContractKeysAndAmounts
addressesToAirdrop: view . selectedAddressesToAirdrop
feeAccountAddress: view . selectedFeeAccount
2023-09-01 09:27:44 +00:00
Component.onCompleted: root . registerAirdropFeeSubscriber ( feesSubscriber )
2023-06-30 09:00:04 +00:00
}
2023-06-05 13:49:36 +00:00
}
2023-03-13 16:32:14 +00:00
}
}
}