2023-03-10 15:55:50 +00:00
import QtQuick 2.0
import QtQuick . Layouts 1.14
2023-08-01 10:31:50 +00:00
import StatusQ . Controls 0.1
2023-03-10 15:55:50 +00:00
import StatusQ . Core 0.1
import StatusQ . Components 0.1
import StatusQ . Core . Theme 0.1
2023-08-01 10:31:50 +00:00
import StatusQ . Core . Utils 0.1 as StatusQUtils
2023-03-10 15:55:50 +00:00
2023-05-25 14:45:46 +00:00
import SortFilterProxyModel 0.2
2023-03-10 15:55:50 +00:00
import utils 1.0
2023-05-25 14:45:46 +00:00
import shared . controls 1.0
2023-03-10 15:55:50 +00:00
import AppLayouts . Wallet . views . collectibles 1.0
2023-06-27 21:56:45 +00:00
import AppLayouts . Communities . panels 1.0
2023-07-18 17:34:57 +00:00
import AppLayouts . Communities . helpers 1.0
2023-03-10 15:55:50 +00:00
StatusScrollView {
id: root
2023-07-18 17:34:57 +00:00
// User profile props
2023-07-06 12:33:27 +00:00
required property bool isOwner
2023-07-12 14:06:07 +00:00
required property bool isAdmin
2023-07-06 12:33:27 +00:00
2023-07-18 17:34:57 +00:00
// General props
2023-03-10 15:55:50 +00:00
property int viewWidth: 560 // by design
property var model
2023-07-18 17:34:57 +00:00
property string communityName
2023-11-28 17:07:17 +00:00
property string communityId
2023-08-01 10:31:50 +00:00
property bool anyPrivilegedTokenFailed: false
2023-06-27 21:56:45 +00:00
readonly property int count: assetsModel . count + collectiblesModel . count
2023-06-01 10:38:56 +00:00
signal itemClicked ( string tokenKey ,
2023-03-31 12:52:51 +00:00
int chainId ,
string chainName ,
string accountName ,
string accountAddress )
2023-03-10 15:55:50 +00:00
2023-08-01 10:31:50 +00:00
signal mintOwnerTokenClicked ( )
signal retryOwnerTokenClicked ( string tokenKey ,
int chainId ,
string accountName ,
string accountAddress )
2023-07-06 12:33:27 +00:00
2023-06-27 21:56:45 +00:00
padding: 0
2023-03-10 15:55:50 +00:00
QtObject {
id: d
2023-05-25 14:45:46 +00:00
readonly property int delegateAssetsHeight: 64
2023-07-18 17:34:57 +00:00
function getDeployStateInfo ( deployState ) {
2023-06-27 19:36:31 +00:00
if ( deployState === Constants . ContractTransactionStatus . Failed )
2023-05-17 10:00:52 +00:00
return qsTr ( "Minting failed" )
2023-03-10 15:55:50 +00:00
2023-06-27 19:36:31 +00:00
if ( deployState === Constants . ContractTransactionStatus . InProgress )
2023-03-10 15:55:50 +00:00
return qsTr ( "Minting..." )
2023-05-11 17:14:11 +00:00
2023-07-18 17:34:57 +00:00
return ""
}
2023-08-04 16:41:21 +00:00
function getRemainingInfo ( isOwnerToken , isTMasterToken ,
2023-07-18 17:34:57 +00:00
remainingSupply , supply , isInfiniteSupply ) {
2024-01-15 12:48:28 +00:00
// Owner token and owner profile use case:
if ( isOwnerToken && root . isOwner )
2023-07-18 17:34:57 +00:00
return qsTr ( "1 of 1 (you hodl)" )
2024-01-15 12:48:28 +00:00
// Owner token but no owner profile use case:
if ( isOwnerToken && ! root . isOwner )
return qsTr ( "1 of 1" )
2023-07-18 17:34:57 +00:00
// TMaster token use case:
2023-08-04 16:41:21 +00:00
if ( isTMasterToken )
2023-07-18 17:34:57 +00:00
return "∞"
// Rest of collectible cases:
2023-06-27 19:36:31 +00:00
if ( isInfiniteSupply )
2023-07-18 17:34:57 +00:00
return qsTr ( "∞ remaining" )
2023-06-27 19:36:31 +00:00
2023-07-18 17:34:57 +00:00
return qsTr ( "%L1 / %L2 remaining" ) . arg ( remainingSupply ) . arg ( supply )
2023-03-10 15:55:50 +00:00
}
}
2023-06-27 21:56:45 +00:00
SortFilterProxyModel {
id: assetsModel
2023-03-10 15:55:50 +00:00
2023-06-27 21:56:45 +00:00
sourceModel: root . model
filters: ValueFilter {
roleName: "tokenType"
value: Constants . TokenType . ERC20
}
}
2023-03-10 15:55:50 +00:00
2023-06-27 21:56:45 +00:00
SortFilterProxyModel {
id: collectiblesModel
2023-03-10 15:55:50 +00:00
2023-06-27 21:56:45 +00:00
sourceModel: root . model
filters: ValueFilter {
roleName: "tokenType"
value: Constants . TokenType . ERC721
}
}
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
Loader {
sourceComponent: root . count === 0 ? introComponent : mainLayoutComponent
}
Component {
id: introComponent
2023-07-06 12:33:27 +00:00
ColumnLayout {
width: root . viewWidth
spacing: 20
IntroPanel {
Layout.fillWidth: true
2023-06-27 21:56:45 +00:00
2023-07-06 12:33:27 +00:00
image: Style . png ( "community/mint2_1" )
title: qsTr ( "Community tokens" )
subtitle: qsTr ( "You can mint custom tokens and import tokens for your community" )
checkersModel: [
qsTr ( "Create remotely destructible soulbound tokens for admin permissions" ) ,
qsTr ( "Reward individual members with custom tokens for their contribution" ) ,
qsTr ( "Mint tokens for use with community and channel permissions" )
]
}
StatusInfoBoxPanel {
2023-07-12 14:06:07 +00:00
readonly property bool isAdminOnly: root . isAdmin && ! root . isOwner
2023-07-06 12:33:27 +00:00
Layout.fillWidth: true
Layout.bottomMargin: 20
title: qsTr ( "Get started" )
2023-07-12 14:06:07 +00:00
text: isAdminOnly ? qsTr ( "Token minting 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-12 14:06:07 +00:00
buttonVisible: root . isOwner
2023-07-06 12:33:27 +00:00
horizontalPadding: 16
verticalPadding: 20
onClicked: root . mintOwnerTokenClicked ( )
}
2023-05-25 14:45:46 +00:00
}
2023-06-27 21:56:45 +00:00
}
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
Component {
id: mainLayoutComponent
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
ColumnLayout {
id: mainLayout
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
width: root . viewWidth
spacing: Style . current . halfPadding
StatusBaseText {
Layout.leftMargin: Style . current . padding
text: qsTr ( "Assets" )
font.pixelSize: Theme . primaryTextFontSize
color: Theme . palette . baseColor1
2023-05-25 14:45:46 +00:00
}
2023-06-27 21:56:45 +00:00
StatusListView {
id: assetsList
Layout.fillWidth: true
2023-08-10 12:23:59 +00:00
Layout.preferredHeight: contentHeight
2024-02-05 11:06:05 +00:00
interactive: false
2023-06-27 21:56:45 +00:00
visible: count > 0
model: assetsModel
delegate: StatusListItem {
height: 64
2024-02-05 11:06:05 +00:00
width: ListView . view . width
2023-09-12 09:26:25 +00:00
title: model . name ? ? ""
subTitle: model . symbol ? ? ""
2023-06-27 21:56:45 +00:00
asset.name: model . image ? model.image : ""
asset.isImage: true
components: [
StatusBaseText {
anchors.verticalCenter: parent . verticalCenter
2023-07-18 17:34:57 +00:00
text: d . getDeployStateInfo ( model . deployState )
2023-06-27 21:56:45 +00:00
color: model . deployState === Constants . ContractTransactionStatus . Failed
? Theme.palette.dangerColor1 : Theme . palette . baseColor1
font.pixelSize: 13
} ,
StatusIcon {
anchors.verticalCenter: parent . verticalCenter
icon: "next"
color: Theme . palette . baseColor1
}
]
onClicked: root . itemClicked ( model . contractUniqueKey ,
model . chainId , model . chainName ,
model . accountName , model . address )
}
2023-05-25 14:45:46 +00:00
}
2023-06-27 21:56:45 +00:00
// Empty placeholder when no assets; dashed rounded rectangle
ShapeRectangle {
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: parent . width - 4 // The rectangular path is rendered outside
Layout.preferredHeight: 44
visible: assetsList . count === 0
text: qsTr ( "You currently have no minted assets" )
}
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
StatusBaseText {
Layout.leftMargin: Style . current . padding
Layout.topMargin: Style . current . halfPadding
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
text: qsTr ( "Collectibles" )
font.pixelSize: Theme . primaryTextFontSize
color: Theme . palette . baseColor1
}
2023-03-10 15:55:50 +00:00
2023-06-27 21:56:45 +00:00
StatusGridView {
id: collectiblesGrid
2023-03-10 15:55:50 +00:00
2023-06-27 21:56:45 +00:00
Layout.fillWidth: true
Layout.preferredHeight: childrenRect . height
2024-02-05 11:06:05 +00:00
interactive: false
2023-05-25 14:45:46 +00:00
2023-06-27 21:56:45 +00:00
visible: count > 0
model: SortFilterProxyModel {
sourceModel: root . model
filters: ValueFilter {
roleName: "tokenType"
value: Constants . TokenType . ERC721
}
}
cellHeight: 229
cellWidth: 176
leftMargin: 16
delegate: CollectibleView {
height: collectiblesGrid . cellHeight
width: collectiblesGrid . cellWidth
title: model . name ? model.name : "..."
2023-07-18 17:34:57 +00:00
subTitle: deployState === Constants . ContractTransactionStatus . Completed ?
2023-08-04 16:41:21 +00:00
d . getRemainingInfo ( model . privilegesLevel === Constants . TokenPrivilegesLevel . Owner ,
model . privilegesLevel === Constants . TokenPrivilegesLevel . TMaster ,
2023-07-18 17:34:57 +00:00
model . remainingSupply ,
model . supply ,
model . infiniteSupply ) :
d . getDeployStateInfo ( model . deployState )
2023-06-27 21:56:45 +00:00
subTitleColor: model . deployState === Constants . ContractTransactionStatus . Failed
? Theme.palette.dangerColor1 : Theme . palette . baseColor1
fallbackImageUrl: model . image ? model.image : ""
backgroundColor: "transparent"
isLoading: false
2023-07-18 17:34:57 +00:00
navigationIconVisible: false
2023-08-04 16:41:21 +00:00
privilegesLevel: model . privilegesLevel
2023-07-18 17:34:57 +00:00
ornamentColor: model . color
2024-05-08 11:24:27 +00:00
communityId: ""
2023-06-27 21:56:45 +00:00
onClicked: root . itemClicked ( model . contractUniqueKey ,
model . chainId , model . chainName ,
model . accountName , model . address )
2023-05-25 14:45:46 +00:00
}
}
2023-06-27 21:56:45 +00:00
// Empty placeholder when no collectibles; dashed rounded rectangle
ShapeRectangle {
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: parent . width - 4 // The rectangular path is rendered outside
Layout.preferredHeight: 44
visible: collectiblesGrid . count === 0
text: qsTr ( "You currently have no minted collectibles" )
}
2023-08-01 10:31:50 +00:00
// Retry button, only in case of Owner or TMaster tokens failure
StatusButton {
Layout.preferredWidth: 336
Layout.preferredHeight: 44
Layout.alignment: Qt . AlignLeft
Layout.leftMargin: 24
visible: root . anyPrivilegedTokenFailed
text: qsTr ( "Retry mint" )
onClicked: {
// Get owner token item:
const index = StatusQUtils . ModelUtils . indexOf ( root . model , "name" , PermissionsHelpers . ownerTokenNameTag + root . communityName )
if ( index === - 1 )
return console . warn ( "Trying to get Owner Token item but it's not part of the provided model." )
const token = StatusQUtils . ModelUtils . get ( root . model , index )
root . retryOwnerTokenClicked ( token . contractUniqueKey , token . chainId , token . accountName , token . accountAddress )
}
}
2023-05-25 14:45:46 +00:00
}
2023-03-10 15:55:50 +00:00
}
}