feat(@wallet): unknown token

This commit is contained in:
Anthony Laibe 2024-02-13 12:12:01 +01:00 committed by Anthony Laibe
parent 6cbdcfdcf2
commit 115610fcf6
11 changed files with 197 additions and 46 deletions

View File

@ -125,8 +125,9 @@ SplitView {
id: manageTokensCommunityTag
ManageTokensCommunityTag {
Layout.maximumWidth: delegate.width *.4
text: model ? model.tagText : ""
asset.name: model ? model.tagAsset : ""
communityName: model ? model.tagText : ""
communityId: ""
communityImage: model ? model.tagAsset : ""
loading: model ? model.tagLoading : false
}
}

View File

@ -139,7 +139,7 @@ Item {
verify(!!lvCommunity)
// verify we have 2 community collectible groups
tryCompare(lvCommunity, "count", 3)
tryCompare(lvCommunity, "count", 4)
tryCompare(notificationSpy, "count", 0)
triggerDelegateMenuAction(lvCommunity, 0, "miHideTokenGroup", true)
// verify the signal to show the notification toast got fired
@ -147,7 +147,7 @@ Item {
// verify we have one less group
waitForItemPolished(lvCommunity)
tryCompare(lvCommunity, "count", 2)
tryCompare(lvCommunity, "count", 3)
}
function test_dnd() {
@ -190,7 +190,7 @@ Item {
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
verify(!!lvCommunity)
waitForItemPolished(lvCommunity)
tryCompare(lvCommunity, "count", 3)
tryCompare(lvCommunity, "count", 4)
const group0 = findChild(lvCommunity, "manageTokensGroupDelegate-0")
const title0 = group0.title
@ -225,7 +225,7 @@ Item {
const lvCommunity = findChild(controlUnderTest, "communityTokensListView")
verify(!!lvCommunity)
waitForItemPolished(lvCommunity)
tryCompare(lvCommunity, "count", 3)
tryCompare(lvCommunity, "count", 4)
// get the "Bearz" group at index 1
var bearzGroupTokenDelegate = findChild(lvCommunity, "manageTokensGroupDelegate-1")

View File

@ -309,6 +309,26 @@ ListModel {
},
]
},
{
uid: "lb#777",
chainId: 420,
name: "Lonely Turtle #777",
collectionUid: "",
collectionName: "",
communityId: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240",
communityName: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240",
communityImage: "",
imageUrl: "",
isLoading: false,
backgroundColor: "pink",
ownership: [
{
accountAddress: "0x7F47C2e18a4BBf5487E6fb082eC2D9Ab0E6d7240",
balance: 1,
txTimestamp: 27
},
]
},
]
Component.onCompleted: {

View File

@ -54,7 +54,6 @@ StackView {
property var accounts // Expected roles: address, name, color, emoji, walletType
required property var referenceAssetsBySymbolModel
// Network related properties:
property var layer1Networks
property var layer2Networks
@ -166,7 +165,6 @@ StackView {
communityName: root.communityName
communityId: root.communityId
anyPrivilegedTokenFailed: root.anyPrivilegedTokenFailed
onItemClicked: root.push(tokenViewComponent, { tokenKey }, StackView.Immediate)
onMintOwnerTokenClicked: root.push(ownerTokenViewComponent, StackView.Immediate)
onRetryOwnerTokenClicked: d.retryPrivilegedToken(tokenKey, chainId, accountName, accountAddress)

View File

@ -255,7 +255,6 @@ StatusScrollView {
privilegesLevel: model.privilegesLevel
ornamentColor: model.color
communityId: root.communityId
onClicked: root.itemClicked(model.contractUniqueKey,
model.chainId, model.chainName,
model.accountName, model.address)

View File

@ -38,8 +38,9 @@ ProfileShowcasePanel {
Component {
id: communityTokenTagComponent
ManageTokensCommunityTag {
text: model && !!model.communityName ? model.communityName : ""
asset.name: model && !!model.communityImage ? model.communityImage : ""
communityName: model && !!model.communityName ? model.communityName : ""
communityId: model && !!model.communityId ? model.communityId : ""
communityImage: model && !!model.communityImage ? model.communityImage : ""
loading: model && !!model.communityImageLoading ? model.communityImageLoading : false
}
}

View File

@ -5,16 +5,21 @@ import QtQuick.Layouts 1.15
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
import shared.controls 1.0
import utils 1.0
Control {
id: root
property string text
property alias asset: identicon.asset
property alias name: identicon.name
property string communityName
property string communityId
property var communityImage
property bool loading
property bool useLongTextDescription: true
property Component customBackground: Component {
Rectangle {
@ -27,6 +32,7 @@ Control {
QtObject {
id: d
readonly property bool unknownCommunityName: !!root.communityName ? root.communityName.startsWith("0x") && root.communityName === root.communityId : false
property var loadingComponent: Component { LoadingComponent {} }
}
@ -47,16 +53,59 @@ Control {
Layout.preferredHeight: visible ? 16 : 0
asset.width: 16
asset.height: 16
asset.isImage: true
visible: !!asset.source
visible: root.useLongTextDescription && !!asset.source
asset.name: !!root.communityImage ? root.communityImage : "help"
asset.isImage: !!root.communityImage
}
StatusBaseText {
RowLayout {
spacing: 2
Layout.fillWidth: true
font.pixelSize: Style.current.tertiaryTextFontSize
font.weight: Font.Medium
text: root.text
elide: Text.ElideRight
color: enabled ? Theme.palette.directColor1 : Theme.palette.baseColor1
StatusBaseText {
font.pixelSize: Style.current.tertiaryTextFontSize
font.weight: Font.Medium
text: {
if (d.unknownCommunityName) {
if (communityNameToolTip.visible) {
if (!root.full) {
return StatusQUtils.Utils.elideAndFormatWalletAddress(root.communityName)
}
return qsTr("Community %1").arg(StatusQUtils.Utils.elideAndFormatWalletAddress(root.communityName))
}
if (!root.full) {
return qsTr("Unknown")
}
return qsTr("Unknown community")
}
return root.communityName
}
elide: Text.ElideRight
color: enabled ? Theme.palette.directColor1 : Theme.palette.baseColor1
}
CopyToClipBoardButton {
visible: d.unknownCommunityName && root.hovered
icon.height: Style.current.tertiaryTextFontSize
icon.width: Style.current.tertiaryTextFontSize
icon.color: Theme.palette.directColor1
Layout.preferredWidth: 16
Layout.preferredHeight: 16
color: Style.current.transparent
textToCopy: root.communityName
onCopyClicked: {
Utils.copyToClipboard(textToCopy)
}
}
}
}
StatusToolTip {
id: communityNameToolTip
text: qsTr("Community name could not be fetched")
visible: d.unknownCommunityName && root.hovered
orientation: StatusToolTip.Orientation.Top
}
}

View File

@ -91,8 +91,9 @@ DropArea {
ManageTokensCommunityTag {
Layout.maximumWidth: delegate.width *.4
visible: !!model.communityId
text: model.communityName
asset.name: model && !!model.communityImage ? model.communityImage : ""
communityImage: model.communityImage
communityName: model.communityName
communityId: model.communityId
},
ManageTokenMenuButton {
id: menuBtn

View File

@ -6,7 +6,9 @@ import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
import shared.controls 1.0
import utils 1.0
DropArea {
@ -27,6 +29,8 @@ DropArea {
readonly property int childCount: model.enabledNetworkBalance // NB using "balance" as "count" in the grouped model
readonly property alias title: groupedCommunityTokenDelegate.title
readonly property bool unknownCommunityName: model.communityName.startsWith("0x") && model.communityName == model.communityId
ListView.onRemove: SequentialAnimation {
PropertyAction { target: root; property: "ListView.delayRemove"; value: true }
NumberAnimation { target: root; property: "scale"; to: 0; easing.type: Easing.InOutQuad }
@ -53,7 +57,21 @@ DropArea {
draggable: true
spacing: 12
bgColor: Theme.palette.baseColor4
title: root.isCollection ? model.collectionName : model.communityName
title: {
if (root.isCollection) {
return model.collectionName
}
if (root.unknownCommunityName) {
if (communityNameArea.hovered) {
return qsTr("Community %1").arg(StatusQUtils.Utils.elideAndFormatWalletAddress(model.communityName))
}
return qsTr("Unknown community")
}
return model.communityName
}
visualIndex: index
dragParent: root.dragParent
@ -71,30 +89,92 @@ DropArea {
color: root.dragEnabled ? Theme.palette.baseColor1 : Theme.palette.baseColor2
}
StatusSmartIdenticon {
id: identicon
Layout.preferredWidth: visible ? 32 : 0
Layout.preferredHeight: visible ? 32 : 0
asset.width: 32
asset.height: 32
visible: root.unknownCommunityName
asset.name: "help"
asset.color: Theme.palette.baseColor1
asset.isImage: false
}
StatusRoundedImage {
visible: !root.unknownCommunityName
radius: root.isCollection ? Style.current.radius : height/2
Layout.preferredWidth: root.isCollectible ? 44 : 32
Layout.preferredHeight: root.isCollectible ? 44 : 32
image.source: root.isCollection ? model.imageUrl : model.communityImage // FIXME unify group image
Layout.preferredWidth: {
if (!visible){
return 0
}
return root.isCollectible ? 44 : 32
}
Layout.preferredHeight: {
if (!visible){
return 0
}
return root.isCollectible ? 44 : 32
}
image.source: {
if(root.isCollection) {
return model.imageUrl
}
return model.communityImage // FIXME unify group image
}
showLoadingIndicator: true
image.fillMode: Image.PreserveAspectCrop
}
StatusBaseText {
RowLayout {
id: communityNameRow
spacing: 2
Layout.fillWidth: true
text: groupedCommunityTokenDelegate.title
elide: Text.ElideRight
maximumLineCount: 1
font.weight: Font.Medium
StatusBaseText {
text: groupedCommunityTokenDelegate.title
elide: Text.ElideRight
maximumLineCount: 1
font.weight: Font.Medium
}
CopyToClipBoardButton {
visible: root.unknownCommunityName && communityNameArea.hovered
icon.height: Theme.primaryTextFontSize
icon.width: Theme.primaryTextFontSize
icon.color: Theme.palette.directColor1
Layout.preferredWidth: 16
Layout.preferredHeight: 16
color: Style.current.transparent
textToCopy: model.communityName
onCopyClicked: {
Utils.copyToClipboard(textToCopy)
}
}
StatusToolTip {
id: communityNameToolTip
text: qsTr("Community name could not be fetched")
visible: root.unknownCommunityName && communityNameArea.hovered
orientation: StatusToolTip.Orientation.Top
}
HoverHandler {
id: communityNameArea
}
}
Item { Layout.fillWidth: true }
ManageTokensCommunityTag {
text: root.childCount
communityName: root.childCount
communityId: ""
asset.name: root.isCollectible ? "image" : "token"
asset.isImage: false
asset.color: Theme.palette.baseColor1
loading: false
enabled: false
}

View File

@ -35,6 +35,11 @@ Control {
(privilegesLevel === Constants.TokenPrivilegesLevel.TMaster)
property color ornamentColor // Relevant color for these special tokens (community color)
readonly property var d: QtObject {
id: d
readonly property bool unknownCommunityName: root.communityName.startsWith("0x") && root.communityId === root.communityName
}
signal clicked
signal rightClicked
signal switchToCommunityRequested(string communityId)
@ -154,15 +159,15 @@ Control {
Layout.leftMargin: Style.current.halfPadding
Layout.rightMargin: Style.current.halfPadding
Layout.maximumWidth: parent.width - Layout.leftMargin - Layout.rightMargin
text: root.communityName
asset.name: root.communityImage
communityName: root.communityName
communityId: root.communityId
communityImage: root.communityImage
visible: root.isCommunityCollectible
enabled: !root.isLoading
StatusToolTip {
text: qsTr("This token was minted by the %1 community").arg(root.communityName)
visible: parent.hovered
}
useLongTextDescription: false
TapHandler {
enabled: !d.unknownCommunityName
acceptedButtons: Qt.LeftButton
onSingleTapped: root.switchToCommunityRequested(root.communityId)
}

View File

@ -129,15 +129,12 @@ StatusListItem {
}
ManageTokensCommunityTag {
anchors.right: parent.right
text: modelData && !!modelData.communityName ? modelData.communityName : ""
name: modelData && !!modelData.communityName ? modelData.communityName : ""
asset.name: modelData && !!modelData.communityImage ? modelData.communityImage : ""
communityImage: !!modelData ? modelData.communityImage : ""
communityName: !!modelData && !!modelData.communityName ? modelData.communityName: ""
communityId: !!modelData && !!modelData.communityId ? modelData.communityId : ""
asset.letterSize: 12
visible: root.isCommunityToken
StatusToolTip {
text: modelData ? qsTr("This token was minted by the %1 community").arg(modelData.communityName) : ""
visible: parent.hovered
}
TapHandler {
acceptedButtons: Qt.LeftButton
onSingleTapped: root.switchToCommunityRequested(modelData.communityId)