2023-11-29 15:48:33 +00:00
import QtQuick 2.15
import QtQuick . Layouts 1.15
import QtQuick . Controls 2.15
2024-01-24 12:36:23 +00:00
import QtQml 2.15
2021-09-28 15:04:06 +00:00
2023-11-29 15:48:33 +00:00
import StatusQ 0.1
2022-07-13 12:29:38 +00:00
import StatusQ . Components 0.1
2023-03-06 16:46:32 +00:00
import StatusQ . Controls 0.1
2024-01-24 12:36:23 +00:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import StatusQ . Core . Utils 0.1
import StatusQ . Models 0.1
2023-11-29 15:48:33 +00:00
import StatusQ . Popups 0.1
import StatusQ . Popups . Dialog 0.1
2023-01-31 10:49:07 +00:00
2023-11-29 15:48:33 +00:00
import shared . controls 1.0
2021-10-27 21:27:49 +00:00
import shared . panels 1.0
2023-11-29 15:48:33 +00:00
import shared . popups 1.0
2023-01-31 10:49:07 +00:00
import utils 1.0
2021-10-21 08:22:05 +00:00
2023-11-29 15:48:33 +00:00
import AppLayouts . Wallet . views . collectibles 1.0
2023-12-06 10:54:36 +00:00
import AppLayouts . Wallet . controls 1.0
2023-11-29 15:48:33 +00:00
import SortFilterProxyModel 0.2
2021-10-21 08:22:05 +00:00
2023-12-06 10:54:36 +00:00
ColumnLayout {
2020-08-18 18:46:11 +00:00
id: root
2023-11-29 15:48:33 +00:00
2024-07-17 14:55:52 +00:00
required property var ownedAccountsModel
2024-01-31 18:09:44 +00:00
required property var controller
2024-01-17 20:19:58 +00:00
required property string addressFilters
required property string networkFilters
2023-11-29 15:48:33 +00:00
property bool sendEnabled: true
2023-12-06 10:54:36 +00:00
property bool filterVisible
2024-02-07 22:58:56 +00:00
property bool isFetching: false // Indicates if a collectibles page is being loaded from the backend
property bool isUpdating: false // Indicates if the collectibles list is being updated
property bool isError: false // Indicates an error occurred while updating/fetching the collectibles list
2024-11-22 15:57:21 +00:00
property alias bannerComponent: banner . sourceComponent
2023-01-20 00:44:35 +00:00
2024-09-11 12:00:25 +00:00
// allows/disables choosing custom sort order from a sorter
property bool customOrderAvailable
property alias selectedFilterGroupIds: cmbFilter . selectedFilterGroupIds
2024-08-02 09:24:40 +00:00
signal collectibleClicked ( int chainId , string contractAddress , string tokenId , string uid , int tokenType , string communityId )
2024-07-19 11:20:26 +00:00
signal sendRequested ( string symbol , int tokenType , string fromAddress )
2023-11-29 15:48:33 +00:00
signal receiveRequested ( string symbol )
signal switchToCommunityRequested ( string communityId )
signal manageTokensRequested ( )
2023-12-06 10:54:36 +00:00
spacing: 0
2024-09-11 12:00:25 +00:00
function setSortOrder ( order ) {
d . sortOrder = order
}
function getSortOrder ( ) {
return d . sortOrder
}
function getSortValue ( ) {
return d . sortValue
}
function sortByValue ( value ) {
d . sortValue = value
}
2023-11-29 15:48:33 +00:00
QtObject {
id: d
2024-09-11 12:00:25 +00:00
property int sortValue: SortOrderComboBox . TokenOrderAlpha
property int sortOrder: Qt . DescendingOrder
2023-11-29 15:48:33 +00:00
readonly property int cellHeight: 225
readonly property int communityCellHeight: 242
readonly property int cellWidth: 176
2024-01-24 12:36:23 +00:00
readonly property int headerHeight: 56
2023-01-20 00:44:35 +00:00
2023-12-06 10:54:36 +00:00
readonly property bool isCustomView: cmbTokenOrder . currentValue === SortOrderComboBox . TokenOrderCustom
2023-11-29 15:48:33 +00:00
2024-02-07 22:58:56 +00:00
readonly property var sourceModel: root . controller . sourceModel
readonly property bool isLoading: root . isUpdating || root . isFetching
2024-06-13 23:20:18 +00:00
function setSortByDateIsDisabled ( value ) {
const orderByDateIndex = cmbTokenOrder . indexOfValue ( SortOrderComboBox . TokenOrderDateAdded )
cmbTokenOrder . model [ orderByDateIndex ] . isDisabled = value
cmbTokenOrder . modelChanged ( )
if ( ! value && cmbTokenOrder . currentIndex === orderByDateIndex ) {
cmbTokenOrder . indexOfValue ( SortOrderComboBox . TokenOrderAlpha )
}
}
2024-02-07 22:58:56 +00:00
onIsLoadingChanged: {
d . loadingItemsModel . refresh ( )
}
readonly property var loadingItemsModel: ListModel {
Component.onCompleted: {
refresh ( )
}
function refresh ( ) {
clear ( )
if ( d . isLoading ) {
for ( let i = 0 ; i < 10 ; i ++ ) {
2024-08-28 13:58:33 +00:00
append ( { isLoading: true , name: qsTr ( "Loading collectible..." ) } )
2024-02-07 22:58:56 +00:00
}
}
}
}
readonly property var communityModel: CustomSFPM {
isCommunity: true
}
readonly property var communityModelWithLoadingItems: ConcatModel {
sources: [
SourceModel {
model: d . communityModel
markerRoleValue: "communityModel"
} ,
SourceModel {
model: d . loadingItemsModel
markerRoleValue: "loadingItemsModel"
}
]
markerRoleName: "sourceGroup"
}
readonly property var nonCommunityModel: CustomSFPM {
isCommunity: false
}
readonly property var nonCommunityModelWithLoadingItems: ConcatModel {
sources: [
SourceModel {
model: d . nonCommunityModel
markerRoleValue: "nonCommunityModel"
} ,
SourceModel {
model: d . loadingItemsModel
markerRoleValue: "loadingItemsModel"
}
]
markerRoleName: "sourceGroup"
}
2024-06-13 23:20:18 +00:00
readonly property var allCollectiblesModel: ConcatModel {
sources: [
SourceModel {
model: d . communityModel
markerRoleValue: "loadingItemsModel"
} ,
SourceModel {
model: d . nonCommunityModel
markerRoleValue: "nonCommunityModel"
}
]
markerRoleName: "sourceGroup"
}
2024-03-12 15:48:59 +00:00
readonly property bool hasRegularCollectibles: d . nonCommunityModel . count || d . loadingItemsModel . count
2024-02-07 22:58:56 +00:00
readonly property bool hasCommunityCollectibles: d . communityModel . count || d . loadingItemsModel . count
2024-03-12 15:48:59 +00:00
readonly property bool onlyRegularCollectiblesType: hasRegularCollectibles && ! hasCommunityCollectibles
2023-11-29 15:48:33 +00:00
2024-01-17 20:19:58 +00:00
readonly property var nwFilters: root . networkFilters . split ( ":" )
readonly property var addrFilters: root . addressFilters . split ( ":" ) . map ( ( addr ) = > addr . toLowerCase ( ) )
2024-04-09 13:07:43 +00:00
function getLatestTimestamp ( ownership , filterList ) {
2024-03-05 20:16:37 +00:00
let latest = 0
if ( ! ! ownership ) {
for ( let i = 0 ; i < ownership . count ; i ++ ) {
let accountAddress = ModelUtils . get ( ownership , i , "accountAddress" ) . toLowerCase ( )
if ( filterList . includes ( accountAddress ) ) {
let txTimestamp = ModelUtils . get ( ownership , i , "txTimestamp" )
latest = Math . max ( latest , txTimestamp )
}
2024-01-17 20:19:58 +00:00
}
}
2024-03-05 20:16:37 +00:00
return latest
2024-01-17 20:19:58 +00:00
}
2024-02-15 12:59:34 +00:00
2024-03-05 20:16:37 +00:00
function getBalance ( ownership , filterList ) {
// Balance is a Uint256, so we need to use AmountsArithmetic to handle it
let balance = AmountsArithmetic . fromNumber ( 0 )
if ( ! ! ownership ) {
for ( let i = 0 ; i < ownership . count ; i ++ ) {
let accountAddress = ModelUtils . get ( ownership , i , "accountAddress" ) . toLowerCase ( )
if ( filterList . includes ( accountAddress ) ) {
let tokenBalanceStr = ModelUtils . get ( ownership , i , "balance" ) + ""
if ( tokenBalanceStr !== "" ) {
let tokenBalance = AmountsArithmetic . fromString ( tokenBalanceStr )
balance = AmountsArithmetic . sum ( balance , tokenBalance )
}
}
}
// For simplicity, we limit the result to the maximum int manageable by QML
const maxInt = 2147483647
if ( AmountsArithmetic . cmp ( balance , AmountsArithmetic . fromNumber ( maxInt ) ) === 1 ) {
return maxInt
2024-02-15 12:59:34 +00:00
}
}
2024-03-05 20:16:37 +00:00
return AmountsArithmetic . toNumber ( balance )
2024-02-15 12:59:34 +00:00
}
2024-06-13 23:20:18 +00:00
2024-07-19 11:20:26 +00:00
function getFirstUserOwnedAddress ( ownershipModel ) {
if ( ! ownershipModel ) return ""
for ( let i = 0 ; i < ownershipModel . rowCount ( ) ; i ++ ) {
const accountAddress = ModelUtils . get ( ownershipModel , i , "accountAddress" )
if ( ModelUtils . contains ( root . ownedAccountsModel , "address" , accountAddress , Qt . CaseInsensitive ) )
return accountAddress
}
return ""
}
2024-06-13 23:20:18 +00:00
property FunctionAggregator hasAllTimestampsAggregator: FunctionAggregator {
model: d . allCollectiblesModel
initialValue: true
roleName: "lastTxTimestamp"
2024-08-07 08:55:54 +00:00
aggregateFunction: ( aggr , value ) = > aggr && value > 0
2024-06-13 23:20:18 +00:00
onValueChanged: {
2024-08-07 08:55:54 +00:00
Qt . callLater ( ( ) = > {
d . hasAllTimestamps = value
d . setSortByDateIsDisabled ( value )
} )
2024-06-13 23:20:18 +00:00
}
2024-08-07 08:55:54 +00:00
Component.onCompleted: d . hasAllTimestamps = value
2024-06-13 23:20:18 +00:00
}
2024-08-07 08:55:54 +00:00
property bool hasAllTimestamps
2020-08-19 15:58:25 +00:00
}
2023-12-06 10:54:36 +00:00
component CustomSFPM: SortFilterProxyModel {
id: customFilter
property bool isCommunity
2023-11-29 15:48:33 +00:00
2024-02-07 22:58:56 +00:00
sourceModel: d . sourceModel
2024-02-15 12:59:34 +00:00
proxyRoles: [
2024-08-20 04:02:14 +00:00
FastExpressionRole {
2024-02-15 12:59:34 +00:00
name: "groupName"
2024-08-20 04:02:14 +00:00
expression: ! ! model . communityId ? model.communityName : model . collectionName
expectedRoles: [ "communityId" , "collectionName" , "communityName" ]
2024-02-15 12:59:34 +00:00
} ,
2024-03-05 20:16:37 +00:00
FastExpressionRole {
name: "balance"
2024-04-09 13:07:43 +00:00
expression: {
d . addrFilters
return d . getBalance ( model . ownership , d . addrFilters )
}
2024-03-05 20:16:37 +00:00
expectedRoles: [ "ownership" ]
} ,
2024-02-15 12:59:34 +00:00
FastExpressionRole {
name: "lastTxTimestamp"
2024-04-09 13:07:43 +00:00
expression: {
d . addrFilters
return d . getLatestTimestamp ( model . ownership , d . addrFilters )
}
2024-02-15 12:59:34 +00:00
expectedRoles: [ "ownership" ]
}
]
2023-12-06 10:54:36 +00:00
filters: [
2024-01-17 20:19:58 +00:00
FastExpressionFilter {
expression: {
2024-03-05 20:16:37 +00:00
return d . nwFilters . includes ( model . chainId + "" )
2024-01-17 20:19:58 +00:00
}
2024-03-05 20:16:37 +00:00
expectedRoles: [ "chainId" ]
} ,
ValueFilter {
roleName: "balance"
value: 0
inverted: true
2024-01-17 20:19:58 +00:00
} ,
2024-01-04 12:05:54 +00:00
FastExpressionFilter {
2023-12-06 10:54:36 +00:00
expression: {
2024-01-31 18:09:44 +00:00
root . controller . revision
return root . controller . filterAcceptsSymbol ( model . symbol ) && ( customFilter . isCommunity ? ! ! model.communityId : ! model . communityId )
2023-12-06 10:54:36 +00:00
}
2024-01-04 12:05:54 +00:00
expectedRoles: [ "symbol" , "communityId" ]
2023-12-18 10:12:57 +00:00
} ,
2024-01-04 12:05:54 +00:00
FastExpressionFilter {
2023-12-18 10:12:57 +00:00
enabled: customFilter . isCommunity && cmbFilter . hasEnabledFilters
expression: cmbFilter . selectedFilterGroupIds . includes ( model . communityId ) ||
( ! model . communityId && cmbFilter . selectedFilterGroupIds . includes ( "" ) )
2024-01-04 12:05:54 +00:00
expectedRoles: [ "communityId" ]
2023-12-18 10:12:57 +00:00
} ,
2024-01-04 12:05:54 +00:00
FastExpressionFilter {
2023-12-18 10:12:57 +00:00
enabled: ! customFilter . isCommunity && cmbFilter . hasEnabledFilters
expression: cmbFilter . selectedFilterGroupIds . includes ( model . collectionUid ) ||
( ! model . collectionUid && cmbFilter . selectedFilterGroupIds . includes ( "" ) )
2024-01-04 12:05:54 +00:00
expectedRoles: [ "collectionUid" ]
2023-12-06 10:54:36 +00:00
}
]
sorters: [
2024-01-04 12:05:54 +00:00
FastExpressionSorter {
2023-12-06 10:54:36 +00:00
expression: {
2024-01-31 18:09:44 +00:00
root . controller . revision
return root . controller . compareTokens ( modelLeft . symbol , modelRight . symbol )
2023-12-06 10:54:36 +00:00
}
enabled: d . isCustomView
2024-01-04 12:05:54 +00:00
expectedRoles: [ "symbol" ]
2023-12-06 10:54:36 +00:00
} ,
RoleSorter {
roleName: cmbTokenOrder . currentSortRoleName
sortOrder: cmbTokenOrder . currentSortOrder
enabled: ! d . isCustomView
}
]
}
2023-11-29 15:48:33 +00:00
2023-12-06 10:54:36 +00:00
ColumnLayout {
Layout.fillWidth: true
2024-01-24 12:36:23 +00:00
Layout.fillHeight: false
2023-12-18 10:12:57 +00:00
Layout.preferredHeight: root . filterVisible ? implicitHeight : 0
2023-12-06 10:54:36 +00:00
spacing: 20
2023-12-18 10:12:57 +00:00
opacity: root . filterVisible ? 1 : 0
2023-12-06 10:54:36 +00:00
Behavior on Layout . preferredHeight { NumberAnimation { duration: 200 ; easing.type: Easing . InOutQuad } }
Behavior on opacity { NumberAnimation { duration: 200 ; easing.type: Easing . InOutQuad } }
2023-11-29 15:48:33 +00:00
StatusDialogDivider {
Layout.fillWidth: true
}
RowLayout {
Layout.fillWidth: true
2024-10-15 19:26:12 +00:00
spacing: Theme . halfPadding
2023-12-06 10:54:36 +00:00
2023-12-18 10:12:57 +00:00
FilterComboBox {
id: cmbFilter
2024-08-20 04:02:14 +00:00
sourceModel: SortFilterProxyModel {
sourceModel: d . sourceModel
proxyRoles: [
FastExpressionRole {
name: "balance"
expression: {
d . addrFilters
return d . getBalance ( model . ownership , d . addrFilters )
}
expectedRoles: [ "ownership" ]
}
]
filters: [
FastExpressionFilter {
expression: {
return d . nwFilters . includes ( model . chainId + "" )
}
expectedRoles: [ "chainId" ]
} ,
ValueFilter {
roleName: "balance"
value: 0
inverted: true
}
]
}
2024-01-31 18:09:44 +00:00
regularTokensModel: root . controller . regularTokensModel
collectionGroupsModel: root . controller . collectionGroupsModel
communityTokenGroupsModel: root . controller . communityTokenGroupsModel
2023-12-18 10:12:57 +00:00
hasCommunityGroups: d . hasCommunityCollectibles
}
Rectangle {
Layout.preferredHeight: 34
Layout.preferredWidth: 1
Layout.leftMargin: 12
Layout.rightMargin: 12
color: Theme . palette . baseColor2
}
2023-11-29 15:48:33 +00:00
StatusBaseText {
color: Theme . palette . baseColor1
2024-10-15 19:26:12 +00:00
font.pixelSize: Theme . additionalTextSize
2023-12-06 10:54:36 +00:00
text: qsTr ( "Sort by:" )
2023-11-29 15:48:33 +00:00
}
2023-12-06 10:54:36 +00:00
SortOrderComboBox {
id: cmbTokenOrder
2024-09-11 12:00:25 +00:00
hasCustomOrderDefined: root . customOrderAvailable
Binding on currentIndex {
value: {
cmbTokenOrder . count
let sortValue = d . sortValue
if ( root . sortValue === SortOrderComboBox . TokenOrderDateAdded && ! d . hasAllTimestamps )
sortValue = SortOrderComboBox . TokenOrderAlpha
let id = cmbTokenOrder . indexOfValue ( sortValue )
if ( id === - 1 )
id = cmbTokenOrder . indexOfValue ( SortOrderComboBox . TokenOrderAlpha )
return id
}
when: cmbTokenOrder . count > 0
}
onCurrentValueChanged: d . sortValue = cmbTokenOrder . currentValue
Binding on currentSortOrder {
value: d . sortOrder
}
onCurrentSortOrderChanged: d . sortOrder = cmbTokenOrder . currentSortOrder
2023-12-06 10:54:36 +00:00
model: [
2024-08-07 08:55:54 +00:00
{ value: SortOrderComboBox . TokenOrderDateAdded , text: qsTr ( "Date added" ) , icon: "" , sortRoleName: "lastTxTimestamp" , isDisabled: ! d . hasAllTimestamps } , // Custom SFPM role
2024-04-09 13:07:43 +00:00
{ value: SortOrderComboBox . TokenOrderAlpha , text: qsTr ( "Collectible name" ) , icon: "" , sortRoleName: "name" } ,
{ value: SortOrderComboBox . TokenOrderGroupName , text: qsTr ( "Collection/community name" ) , icon: "" , sortRoleName: "groupName" } , // Custom SFPM role communityName || collectionName
{ value: SortOrderComboBox . TokenOrderCustom , text: qsTr ( "Custom order" ) , icon: "" , sortRoleName: "" } ,
2023-12-06 10:54:36 +00:00
{ value: SortOrderComboBox . TokenOrderNone , text: "---" , icon: "" , sortRoleName: "" } , // separator
{ value: SortOrderComboBox . TokenOrderCreateCustom , text: hasCustomOrderDefined ? qsTr ( "Edit custom order →" ) : qsTr ( "Create custom order →" ) ,
icon: "" , sortRoleName: "" }
]
onCreateOrEditRequested: {
root . manageTokensRequested ( )
}
2020-08-20 21:59:07 +00:00
}
2023-12-18 10:12:57 +00:00
Item { Layout.fillWidth: true }
StatusLinkText {
visible: cmbFilter . hasEnabledFilters
normalColor: Theme . palette . primaryColor1
text: qsTr ( "Clear filter" )
onClicked: cmbFilter . clearFilter ( )
}
2020-08-20 21:59:07 +00:00
}
2023-11-29 15:48:33 +00:00
2023-12-06 10:54:36 +00:00
StatusDialogDivider {
Layout.fillWidth: true
}
}
2024-11-22 15:57:21 +00:00
Loader {
id: banner
Layout.fillWidth: true
}
2023-12-06 10:54:36 +00:00
ShapeRectangle {
Layout.fillWidth: true
2024-10-15 19:26:12 +00:00
Layout.topMargin: Theme . padding
2024-03-12 15:48:59 +00:00
visible: ! d . hasRegularCollectibles && ! d . hasCommunityCollectibles
2023-12-06 10:54:36 +00:00
text: qsTr ( "Collectibles will appear here" )
}
2024-01-24 12:36:23 +00:00
DoubleFlickableWithFolding {
id: doubleFlickable
2023-12-06 10:54:36 +00:00
Layout.fillWidth: true
Layout.fillHeight: true
2024-01-24 12:36:23 +00:00
clip: true
flickable1: CustomGridView {
id: communityCollectiblesView
2024-03-12 15:48:59 +00:00
header: d . hasCommunityCollectibles ? communityHeaderComponent : null
2024-01-24 12:36:23 +00:00
width: doubleFlickable . width
cellHeight: d . communityCellHeight
2024-02-07 22:58:56 +00:00
model: d . communityModelWithLoadingItems
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
Component {
id: communityHeaderComponent
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
FoldableHeader {
height: d . headerHeight
width: doubleFlickable . width
title: qsTr ( "Community minted" )
titleColor: Theme . palette . baseColor1
folded: doubleFlickable . flickable1Folded
rightAdditionalComponent: StatusFlatButton {
icon.name: "info"
textColor: Theme . palette . baseColor1
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
onClicked: Global . openPopup ( communityInfoPopupCmp )
}
onToggleFolding: doubleFlickable . flip1Folding ( )
}
2023-12-06 10:54:36 +00:00
}
2024-03-12 15:48:59 +00:00
}
2023-12-06 10:54:36 +00:00
2024-03-12 15:48:59 +00:00
flickable2: CustomGridView {
id: regularCollectiblesView
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
header: ! d . hasRegularCollectibles || d . onlyRegularCollectiblesType ? null : regularHeaderComponent
2024-01-24 12:36:23 +00:00
width: doubleFlickable . width
cellHeight: d . cellHeight
2024-02-07 22:58:56 +00:00
model: d . nonCommunityModelWithLoadingItems
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
Component {
id: regularHeaderComponent
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
FoldableHeader {
height: d . headerHeight
width: doubleFlickable . width
title: qsTr ( "Others" )
titleColor: Theme . palette . baseColor1
folded: doubleFlickable . flickable2Folded
2024-01-24 12:36:23 +00:00
2024-03-12 15:48:59 +00:00
onToggleFolding: doubleFlickable . flip2Folding ( )
}
2024-01-24 12:36:23 +00:00
}
}
2023-11-29 15:48:33 +00:00
}
component CustomGridView: StatusGridView {
id: gridView
interactive: false
cellWidth: d . cellWidth
delegate: collectibleDelegate
2020-08-20 21:59:07 +00:00
}
2020-08-18 18:46:11 +00:00
2021-10-21 08:22:05 +00:00
Component {
2023-11-29 15:48:33 +00:00
id: collectibleDelegate
CollectibleView {
width: d . cellWidth
height: isCommunityCollectible ? d.communityCellHeight : d . cellHeight
2024-08-28 13:58:33 +00:00
title: model . name ? ? ""
2023-12-06 10:54:36 +00:00
subTitle: model . collectionName ? model.collectionName : model . collectionUid ? model.collectionUid : ""
2023-11-29 15:48:33 +00:00
mediaUrl: model . mediaUrl ? ? ""
2024-04-09 13:07:43 +00:00
mediaType: model . mediaType ? ? ""
fallbackImageUrl: model . imageUrl ? ? ""
backgroundColor: model . backgroundColor ? model.backgroundColor : "transparent"
2023-11-29 15:48:33 +00:00
isLoading: ! ! model . isLoading
2024-08-28 13:58:33 +00:00
isMetadataValid: ! ! model . isMetadataValid
2023-11-29 15:48:33 +00:00
privilegesLevel: model . communityPrivilegesLevel ? ? Constants . TokenPrivilegesLevel . Community
2024-04-09 13:07:43 +00:00
ornamentColor: model . communityColor ? ? "transparent"
communityId: model . communityId ? ? ""
communityName: model . communityName ? ? ""
communityImage: model . communityImage ? ? ""
balance: model . balance ? ? 1
2023-11-29 15:48:33 +00:00
2024-08-02 09:24:40 +00:00
onClicked: root . collectibleClicked ( model . chainId , model . contractAddress , model . tokenId , model . symbol , model . tokenType , model . communityId ? ? "" )
2023-11-29 15:48:33 +00:00
onRightClicked: {
2024-07-19 11:20:26 +00:00
const userOwnedAddress = d . getFirstUserOwnedAddress ( model . ownership )
2023-11-29 15:48:33 +00:00
Global . openMenu ( tokenContextMenu , this ,
{ symbol: model . symbol , tokenName: model . name , tokenImage: model . imageUrl ,
2024-03-05 09:27:40 +00:00
communityId: model . communityId , communityName: model . communityName ,
2024-07-17 14:55:52 +00:00
communityImage: model . communityImage , tokenType: model . tokenType ,
2024-07-19 11:20:26 +00:00
soulbound: model . soulbound , userOwnedAddress: userOwnedAddress } )
2020-08-19 15:58:25 +00:00
}
2023-11-29 15:48:33 +00:00
onSwitchToCommunityRequested: ( communityId ) = > root . switchToCommunityRequested ( communityId )
}
}
2023-03-06 16:46:32 +00:00
2023-11-29 15:48:33 +00:00
Component {
id: tokenContextMenu
StatusMenu {
2024-07-17 14:55:52 +00:00
id: tokenMenu
2023-11-29 15:48:33 +00:00
onClosed: destroy ( )
2023-08-03 16:05:04 +00:00
2023-11-29 15:48:33 +00:00
property string symbol
property string tokenName
property string tokenImage
property string communityId
property string communityName
property string communityImage
2024-07-19 11:20:26 +00:00
property string userOwnedAddress
2024-03-05 09:27:40 +00:00
property int tokenType
2024-07-19 11:20:26 +00:00
property bool ownedByUser: ! ! userOwnedAddress
2024-07-17 14:55:52 +00:00
property bool soulbound
// Show send button for owned collectibles
// Disable send button for owned soulbound collectibles
Instantiator {
model: tokenMenu . ownedByUser ? 1 : 0
delegate: StatusAction {
enabled: root . sendEnabled && ! tokenMenu . soulbound
visibleOnDisabled: true
icon.name: "send"
text: qsTr ( "Send" )
2024-07-19 11:20:26 +00:00
onTriggered: root . sendRequested ( tokenMenu . symbol , tokenMenu . tokenType , tokenMenu . userOwnedAddress )
2024-07-17 14:55:52 +00:00
}
onObjectAdded: tokenMenu . insertAction ( 0 , object )
onObjectRemoved: tokenMenu . removeAction ( 0 )
2023-11-29 15:48:33 +00:00
}
2024-07-17 14:55:52 +00:00
2023-11-29 15:48:33 +00:00
StatusAction {
icon.name: "receive"
text: qsTr ( "Receive" )
onTriggered: root . receiveRequested ( symbol )
}
StatusMenuSeparator { }
StatusAction {
icon.name: "settings"
text: qsTr ( "Manage tokens" )
onTriggered: root . manageTokensRequested ( )
2023-08-03 16:05:04 +00:00
}
2023-11-29 15:48:33 +00:00
StatusAction {
2024-03-05 17:15:08 +00:00
enabled: symbol !== Constants . ethToken
2023-11-29 15:48:33 +00:00
type: StatusAction . Type . Danger
icon.name: "hide"
text: qsTr ( "Hide collectible" )
2024-01-31 18:09:44 +00:00
onTriggered: Global . openConfirmHideCollectiblePopup ( symbol , tokenName , tokenImage , ! ! communityId )
2023-11-29 15:48:33 +00:00
}
StatusAction {
enabled: ! ! communityId
type: StatusAction . Type . Danger
icon.name: "hide"
text: qsTr ( "Hide all collectibles from this community" )
onTriggered: Global . openPopup ( confirmHideCommunityCollectiblesPopup , { communityId , communityName , communityImage } )
}
}
}
2023-08-03 16:05:04 +00:00
2023-11-29 15:48:33 +00:00
Component {
id: communityInfoPopupCmp
StatusDialog {
destroyOnClose: true
title: qsTr ( "What are community collectibles?" )
standardButtons: Dialog . Ok
width: 520
contentItem: StatusBaseText {
wrapMode: Text . Wrap
text: qsTr ( "Community collectibles are collectibles that have been minted by a community. As these collectibles cannot be verified, always double check their origin and validity before interacting with them. If in doubt, ask a trusted member or admin of the relevant community." )
}
}
}
Component {
id: confirmHideCommunityCollectiblesPopup
ConfirmationDialog {
property string communityId
property string communityName
property string communityImage
2023-08-03 16:05:04 +00:00
2023-11-29 15:48:33 +00:00
width: 520
destroyOnClose: true
2024-01-29 15:37:17 +00:00
confirmButtonLabel: qsTr ( "Hide '%1' collectibles" ) . arg ( communityName )
2023-11-29 15:48:33 +00:00
cancelBtnType: ""
showCancelButton: true
headerSettings.title: qsTr ( "Hide %1 community collectibles" ) . arg ( communityName )
headerSettings.asset.name: communityImage
confirmationText: qsTr ( "Are you sure you want to hide all community collectibles minted by %1? You will no longer see or be able to interact with these collectibles anywhere inside Status." ) . arg ( communityName )
onCancelButtonClicked: close ( )
onConfirmButtonClicked: {
2024-01-31 18:09:44 +00:00
root . controller . showHideGroup ( communityId , false )
2023-11-29 15:48:33 +00:00
close ( )
Global . displayToastMessage (
2024-03-12 15:48:59 +00:00
qsTr ( "%1 community collectibles were successfully hidden. You can toggle collectible visibility via %2." ) . arg ( communityName )
2023-12-06 10:54:36 +00:00
. arg ( ` < a style = "text-decoration:none" href = "#${Constants.appSection.profile}/${Constants.settingsSubsection.wallet}/${Constants.walletSettingsSubsection.manageCollectibles}" > ` + qsTr ( "Settings" , "Go to Settings" ) + "</a>" ) ,
2024-03-12 15:48:59 +00:00
"" ,
"checkmark-circle" ,
false ,
Constants . ephemeralNotificationType . success ,
""
)
2023-08-03 16:05:04 +00:00
}
2020-08-18 18:46:11 +00:00
}
2020-07-28 18:19:46 +00:00
}
2020-05-28 14:54:42 +00:00
}