status-desktop/ui/shared/AddressSourceSelector.qml
emizzle e0e1487643 refactor: replace transaction modal reset functionality
The transaction component's `reset` functionality was meant ot reset a form when the modal was closed. It was difficult to manage and added extra overhead for each additional transaction modal created.

Instead of using reset functions, we can use Loaders to load and destroy the modal's as they are opened and closed. We do not need to keep them in memory and then also reset their functions. It creates a smaller memory footprint to destroy the object and reload on open.

feat: load gas prediction prices asynchronously
2020-11-26 11:17:24 -05:00

68 lines
2.1 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13
import "../imports"
Item {
id: root
property var sources: []
property var selectedSource: sources.length ? sources[0] : null
property int dropdownWidth: 220
height: select.height
Select {
id: select
anchors.left: parent.left
anchors.right: parent.right
model: root.sources
selectedItemView: Item {
anchors.fill: parent
StyledText {
id: selectedTextField
text: !!root.selectedSource ? root.selectedSource.text : qsTr("Invalid source")
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 15
verticalAlignment: Text.AlignVCenter
height: 24
}
}
menu.width: dropdownWidth
menu.topPadding: 8
menu.bottomPadding: 8
menu.delegate: Component {
MenuItem {
id: menuItem
height: 40
width: parent.width
onTriggered: function () {
root.selectedSource = root.sources[index]
}
StyledText {
id: itemText
text: root.sources[index].text
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 15
height: 22
color: menuItem.highlighted ? Style.current.primaryMenuItemTextHover : Style.current.textColor
}
background: Rectangle {
color: menuItem.highlighted ? Style.current.primaryMenuItemHover : Style.current.transparent
}
}
}
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/