From 545bb751c1979c92003e9bacde3563078908e4bd Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 29 May 2020 15:54:06 -0400 Subject: [PATCH] feat: add Input to Login screen and enable otherProps for the Input --- ui/onboarding/Login.qml | 32 +++++++++++++++----------------- ui/shared/Input.qml | 3 ++- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ui/onboarding/Login.qml b/ui/onboarding/Login.qml index 60e449aaab..b9baf10438 100644 --- a/ui/onboarding/Login.qml +++ b/ui/onboarding/Login.qml @@ -128,22 +128,20 @@ SwipeView { anchors.horizontalCenter: parent.horizontalCenter } - Rectangle { - color: "#EEEEEE" + Input { + id: txtPassword + anchors.verticalCenter: parent.verticalCenter + anchors.rightMargin: Theme.padding + anchors.leftMargin: Theme.padding anchors.left: parent.left anchors.right: parent.right - anchors.centerIn: parent - height: 32 - width: parent.width - 40 - TextInput { - id: txtPassword - anchors.fill: parent - focus: true - echoMode: TextInput.Password - selectByMouse: true - Keys.onReturnPressed: { - submitBtn.clicked() - } + otherProps: { + this.textField.focus = true + this.textField.focus + this.textField.echoMode = TextInput.Password + } + Keys.onReturnPressed: { + submitBtn.clicked() } } @@ -154,8 +152,8 @@ SwipeView { icon: StandardIcon.Critical standardButtons: StandardButton.Ok onAccepted: { - txtPassword.clear() - txtPassword.focus = true + txtPassword.textField.clear() + txtPassword.textField.focus = true } } @@ -177,7 +175,7 @@ SwipeView { anchors.bottomMargin: 20 onClicked: { const selectedAccountIndex = wizardStep1.selectedIndex - const response = loginModel.login(selectedAccountIndex, txtPassword.text) + const response = loginModel.login(selectedAccountIndex, txtPassword.textField.text) // TODO: replace me with something graphical (ie spinner) console.log("Logging in...") } diff --git a/ui/shared/Input.qml b/ui/shared/Input.qml index ce4edb24cf..d0404d50aa 100644 --- a/ui/shared/Input.qml +++ b/ui/shared/Input.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts 1.3 import "../imports" Item { + property alias textField: inputValue property string placeholderText: "My placeholder" property string text: "" property string label: "" @@ -11,12 +12,12 @@ Item { // property url icon: "../app/img/hash.svg" property url icon: "" readonly property bool hasIcon: icon.toString() !== "" - readonly property bool hasLabel: label !== "" readonly property var forceActiveFocus: function () { inputValue.forceActiveFocus(Qt.MouseFocusReason) } readonly property int labelMargin: 7 + property var otherProps // Only used to assign stuff to textField id: inputBox height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)