feat: add TextArea to Input and set correct Modal height

This commit is contained in:
Jonathan Rainville 2020-06-08 15:30:22 -04:00 committed by Iuri Matias
parent 50c10d38dd
commit 43df7d2f77
3 changed files with 31 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import "../../../../shared"
ModalPopup {
id: popup
title: qsTr("Add account with a seed phrase")
height: 600
property int marginBetweenInputs: 38
property string selectedColor: Constants.accountColors[0]
@ -25,12 +26,13 @@ ModalPopup {
Input {
// TODO use a Textarea
id: accountSeedInput
anchors.top: passwordInput.bottom
anchors.topMargin: marginBetweenInputs
placeholderText: qsTr("Enter your seed phrase, separate words with commas or spaces...")
label: qsTr("Seed phrase")
isTextArea: true
customHeight: 88
}
Input {

View File

@ -8,6 +8,7 @@ Item {
property alias textField: inputValue
property string placeholderText: "My placeholder"
property alias text: inputValue.text
property alias textAreaText: textArea.text
property string label: ""
property color bgColor: Theme.grey
@ -22,6 +23,8 @@ Item {
readonly property int labelMargin: 7
property var selectOptions
property bool isSelect: !!selectOptions && selectOptions.length > 0
property int customHeight: 44
property bool isTextArea: false
id: inputBox
height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)
@ -42,7 +45,7 @@ Item {
Rectangle {
id: inputRectangle
height: 44
height: customHeight
color: bgColor
radius: 8
anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top
@ -52,7 +55,7 @@ Item {
TextField {
id: inputValue
visible: !isSelect
visible: !inputBox.isTextArea && !inputBox.isSelect
placeholderText: inputBox.placeholderText
text: inputBox.text
anchors.left: parent.left
@ -64,6 +67,21 @@ Item {
}
}
TextArea {
id: textArea
text: ""
font.pixelSize: 15
wrapMode: Text.WordWrap
visible: inputBox.isTextArea
placeholderText: inputBox.placeholderText
anchors.rightMargin: Theme.padding
anchors.leftMargin: inputBox.hasIcon ? 36 : Theme.padding
anchors.bottomMargin: Theme.smallPadding
anchors.topMargin: Theme.smallPadding
anchors.fill: parent
}
Menu {
id: selectMenu
width: parent.width
@ -118,7 +136,13 @@ Item {
id: mouseArea
anchors.fill: parent
onClicked: {
isSelect ? selectMenu.open() : inputValue.forceActiveFocus(Qt.MouseFocusReason)
if (inputBox.isSelect) {
selectMenu.open()
} else if (inputBox.isTextArea) {
textArea.forceActiveFocus(Qt.MouseFocusReason)
} else {
inputValue.forceActiveFocus(Qt.MouseFocusReason)
}
}
}
}

View File

@ -20,7 +20,7 @@ Popup {
x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height - height) / 2)
width: 480
height: 509
height: 510 // TODO find a way to make this dynamic
background: Rectangle {
color: Theme.white
radius: 8