Skip to content

Commit

Permalink
qml: Introduce LabeledTextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny9 committed Nov 13, 2024
1 parent 07f9100 commit 5bf9b87
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/qml/controls/LabeledTextInput.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2024 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

Item {
property alias labelText: label.text
property alias text: input.text
property alias placeholderText: input.placeholderText
property alias iconSource: icon.source
property alias customIcon: iconContainer.data

signal iconClicked
signal textEdited

id: root
implicitHeight: label.height + input.height

CoreText {
id: label
anchors.left: parent.left
anchors.top: parent.top
color: Theme.color.neutral7
font.pixelSize: 15
}

TextField {
id: input
anchors.left: parent.left
anchors.right: iconContainer.left
anchors.bottom: parent.bottom
leftPadding: 0
font.family: "Inter"
font.styleName: "Regular"
font.pixelSize: 18
color: Theme.color.neutral9
placeholderTextColor: Theme.color.neutral7
background: Item {}
onTextEdited: textEdited()
}

Item {
id: iconContainer
anchors.right: parent.right
anchors.verticalCenter: input.verticalCenter

Icon {
id: icon
source: ""
color: Theme.color.neutral8
size: 30
enabled: source != ""
onClicked: iconClicked()
}
}
}

0 comments on commit 5bf9b87

Please sign in to comment.