2023-03-10 15:55:50 +00:00
import QtQuick 2.0
import QtQuick . Layouts 1.14
import StatusQ . Core 0.1
import StatusQ . Components 0.1
import StatusQ . Core . Theme 0.1
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-03-10 15:55:50 +00:00
StatusScrollView {
id: root
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-03-10 15:55:50 +00:00
property int viewWidth: 560 // by design
property var model
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-07-06 12:33:27 +00:00
signal mintOwnerTokenClicked
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-06-27 19:36:31 +00:00
function getSubtitle ( deployState , remainingSupply , supply ,
isCollectible , isInfiniteSupply ) {
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-06-27 19:36:31 +00:00
if ( isInfiniteSupply )
2023-06-22 05:27:18 +00:00
return isCollectible ? qsTr ( "∞ remaining" ) : ""
2023-06-27 19:36:31 +00:00
return isCollectible
? qsTr ( "%1 / %2 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
Layout.preferredHeight: childrenRect . height
visible: count > 0
model: assetsModel
delegate: StatusListItem {
height: 64
width: mainLayout . width
title: model . name
subTitle: model . symbol
asset.name: model . image ? model.image : ""
asset.isImage: true
components: [
StatusBaseText {
anchors.verticalCenter: parent . verticalCenter
text: d . getSubtitle ( model . deployState ,
model . remainingSupply ,
model . supply , false ,
model . infiniteSupply )
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
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 : "..."
subTitle: d . getSubtitle ( model . deployState ,
model . remainingSupply ,
model . supply , true ,
model . infiniteSupply )
subTitleColor: model . deployState === Constants . ContractTransactionStatus . Failed
? Theme.palette.dangerColor1 : Theme . palette . baseColor1
fallbackImageUrl: model . image ? model.image : ""
backgroundColor: "transparent"
isLoading: false
navigationIconVisible: true
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-05-25 14:45:46 +00:00
}
2023-03-10 15:55:50 +00:00
}
}