2020-08-03 05:36:54 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-08-03 05:36:54 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
property var assets
|
2020-08-04 11:10:09 +00:00
|
|
|
property var selectedAsset
|
2020-08-03 05:36:54 +00:00
|
|
|
width: 86
|
|
|
|
height: 24
|
|
|
|
|
2020-08-20 04:45:29 +00:00
|
|
|
function resetInternal() {
|
|
|
|
assets = undefined
|
|
|
|
selectedAsset = undefined
|
|
|
|
}
|
|
|
|
|
2020-08-12 09:05:12 +00:00
|
|
|
onSelectedAssetChanged: {
|
|
|
|
if (selectedAsset && selectedAsset.symbol) {
|
2021-09-28 15:04:06 +00:00
|
|
|
iconImg.source = Style.png("tokens/" + selectedAsset.symbol.toUpperCase())
|
2020-08-12 09:05:12 +00:00
|
|
|
selectedTextField.text = selectedAsset.symbol.toUpperCase()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-20 04:45:29 +00:00
|
|
|
onAssetsChanged: {
|
|
|
|
if (!assets) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
selectedAsset = {
|
|
|
|
name: assets.rowData(0, "name"),
|
|
|
|
symbol: assets.rowData(0, "symbol"),
|
|
|
|
value: assets.rowData(0, "value"),
|
|
|
|
fiatBalanceDisplay: assets.rowData(0, "fiatBalanceDisplay"),
|
|
|
|
address: assets.rowData(0, "address"),
|
|
|
|
fiatBalance: assets.rowData(0, "fiatBalance")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-03 05:36:54 +00:00
|
|
|
Select {
|
|
|
|
id: select
|
|
|
|
width: parent.width
|
|
|
|
bgColor: Style.current.transparent
|
|
|
|
bgColorHover: Style.current.secondaryHover
|
2020-08-20 04:45:29 +00:00
|
|
|
model: root.assets
|
2020-08-03 05:36:54 +00:00
|
|
|
caretRightMargin: 7
|
|
|
|
select.radius: 6
|
|
|
|
select.height: root.height
|
|
|
|
menu.width: 343
|
|
|
|
selectedItemView: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
SVGImage {
|
|
|
|
id: iconImg
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
sourceSize.height: 24
|
|
|
|
sourceSize.width: 24
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: selectedTextField
|
|
|
|
anchors.left: iconImg.right
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
font.pixelSize: 15
|
|
|
|
height: 22
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.delegate: menuItem
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: menuItem
|
|
|
|
MenuItem {
|
|
|
|
id: itemContainer
|
|
|
|
property bool isFirstItem: index === 0
|
|
|
|
property bool isLastItem: index === assets.rowCount() - 1
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: 72
|
|
|
|
SVGImage {
|
|
|
|
id: iconImg
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
sourceSize.height: height
|
|
|
|
sourceSize.width: width
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.png("tokens/" + symbol.toUpperCase())
|
2020-08-03 05:36:54 +00:00
|
|
|
}
|
|
|
|
Column {
|
|
|
|
anchors.left: iconImg.right
|
|
|
|
anchors.leftMargin: 12
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
text: symbol.toUpperCase()
|
|
|
|
font.pixelSize: 15
|
|
|
|
height: 22
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
text: name
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 15
|
|
|
|
height: 22
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Column {
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
StyledText {
|
|
|
|
font.pixelSize: 15
|
|
|
|
height: 22
|
|
|
|
text: parseFloat(value).toFixed(4) + " " + symbol
|
|
|
|
}
|
|
|
|
StyledText {
|
|
|
|
font.pixelSize: 15
|
|
|
|
anchors.right: parent.right
|
|
|
|
height: 22
|
2020-08-05 12:53:25 +00:00
|
|
|
text: fiatBalanceDisplay.toUpperCase()
|
2020-08-03 05:36:54 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
background: Rectangle {
|
|
|
|
color: itemContainer.highlighted ? Style.current.backgroundHover : Style.current.background
|
|
|
|
radius: Style.current.radius
|
|
|
|
|
|
|
|
// cover bottom left/right corners with square corners
|
|
|
|
Rectangle {
|
|
|
|
visible: !isLastItem
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
height: parent.radius
|
|
|
|
color: parent.color
|
|
|
|
}
|
|
|
|
|
|
|
|
// cover top left/right corners with square corners
|
|
|
|
Rectangle {
|
|
|
|
visible: !isFirstItem
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: parent.radius
|
|
|
|
color: parent.color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: itemContainer
|
|
|
|
onClicked: {
|
2020-08-04 11:10:09 +00:00
|
|
|
root.selectedAsset = { address, name, value, symbol, fiatBalance, fiatBalanceDisplay }
|
2020-08-03 05:36:54 +00:00
|
|
|
select.menu.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|