status-desktop/ui/imports/shared/controls/WalletAccountListItem.qml
Alex Jbanca 8b4cbc59a8 refactor: Refactoring of AccountSelector dropdown
The new account selector expects a generic account model. It will display all the account data if provided, including preferred chains, balance or asset balance. Otherwise it will display only the available data.
The account selector can receive an initial selection based on account address and will provide the current selected address and the current selected model item.

- Unify the account selector between communities and wallet
- Update the account selector to work with addresses instead of model indexes
- Adapt all components using the account selector or the account selection
- Move/reuse qml components involved in the account selector UI
- Remove nim logic used to handle index based account selection.
- Adding storybook page
2024-06-20 11:24:35 +03:00

105 lines
3.6 KiB
QML

import QtQuick 2.15
import StatusQ 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils
import AppLayouts.Wallet 1.0
import utils 1.0
StatusListItem {
id: root
property bool clearVisible: false
required property string name
required property string address
required property string chainShortNames
required property string emoji
required property string walletColor
required property var currencyBalance
required property string walletType
required property bool migratedToKeycard
/*
formattedBalance [string] - formatted balance e.g. "1234.56B"
balance [string] - balance e.g. "123456000000"
iconUrl [string] - icon url e.g. "network/Network=Hermez"
chainColor [string] - chain color e.g. "#FF0000"
*/
property var accountBalance: null
signal cleared()
objectName: root.name
height: visible ? 64 : 0
title: root.name
subTitle:{
if(!!root.address) {
let elidedAddress = StatusQUtils.Utils.elideText(root.address,6,4)
return sensor.containsMouse ? root.chainShortNames || Utils.richColorText(elidedAddress, Theme.palette.directColor1) : elidedAddress
}
return ""
}
statusListItemSubTitle.wrapMode: Text.NoWrap
asset.emoji: root.emoji
asset.color: root.walletColor
asset.name: root.emoji ? "filled-account": ""
asset.letterSize: 14
asset.isLetterIdenticon: !!root.emoji
asset.bgColor: Theme.palette.indirectColor1
asset.width: 40
asset.height: 40
radius: 0
color: sensor.containsMouse || highlighted ? Theme.palette.baseColor2 : "transparent"
components: [
Column {
anchors.verticalCenter: parent.verticalCenter
StatusTextWithLoadingState {
objectName: "walletAccountCurrencyBalance"
anchors.right: parent.right
font.pixelSize: 15
text: !!root.currencyBalance ? LocaleUtils.currencyAmountToLocaleString(root.currencyBalance) : ""
}
StatusIcon {
objectName: "walletAccountTypeIcon"
anchors.right: parent.right
width: !!icon ? 15: 0
height: !!icon ? 15 : 0
color: Theme.palette.directColor1
icon: root.walletType === Constants.watchWalletType ? "show" :
root.migratedToKeycard ? "keycard" : ""
}
},
StatusClearButton {
anchors.verticalCenter: parent.verticalCenter
visible: root.clearVisible
onClicked: root.cleared()
}
]
inlineTagModel: !!root.accountBalance && !!root.accountBalance.formattedBalance ? 1 : 0
inlineTagDelegate: StatusListItemTag {
objectName: "inlineTagDelegate_" + index
background: null
height: 16
asset.height: 16
asset.width: 16
title: root.accountBalance.formattedBalance
titleText.font.pixelSize: 12
titleText.color: root.accountBalance.balance === "0" ? Theme.palette.baseColor1 : Theme.palette.directColor1
asset.isImage: true
asset.name: Style.svg("tiny/%1".arg(root.accountBalance.iconUrl))
asset.color: root.accountBalance.chainColor
closeButtonVisible: false
hoverEnabled: true
tagClickable: true
onTagClicked: root.clicked(root.itemId, mouse)
onClicked: root.clicked(root.itemId, mouse)
}
}