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

View File

@ -8,6 +8,7 @@ Item {
property alias textField: inputValue property alias textField: inputValue
property string placeholderText: "My placeholder" property string placeholderText: "My placeholder"
property alias text: inputValue.text property alias text: inputValue.text
property alias textAreaText: textArea.text
property string label: "" property string label: ""
property color bgColor: Theme.grey property color bgColor: Theme.grey
@ -22,6 +23,8 @@ Item {
readonly property int labelMargin: 7 readonly property int labelMargin: 7
property var selectOptions property var selectOptions
property bool isSelect: !!selectOptions && selectOptions.length > 0 property bool isSelect: !!selectOptions && selectOptions.length > 0
property int customHeight: 44
property bool isTextArea: false
id: inputBox id: inputBox
height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0) height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)
@ -42,7 +45,7 @@ Item {
Rectangle { Rectangle {
id: inputRectangle id: inputRectangle
height: 44 height: customHeight
color: bgColor color: bgColor
radius: 8 radius: 8
anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top anchors.top: inputBox.hasLabel ? inputLabel.bottom : parent.top
@ -52,7 +55,7 @@ Item {
TextField { TextField {
id: inputValue id: inputValue
visible: !isSelect visible: !inputBox.isTextArea && !inputBox.isSelect
placeholderText: inputBox.placeholderText placeholderText: inputBox.placeholderText
text: inputBox.text text: inputBox.text
anchors.left: parent.left 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 { Menu {
id: selectMenu id: selectMenu
width: parent.width width: parent.width
@ -118,7 +136,13 @@ Item {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
onClicked: { 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) x: Math.round((parent.width - width) / 2)
y: Math.round((parent.height - height) / 2) y: Math.round((parent.height - height) / 2)
width: 480 width: 480
height: 509 height: 510 // TODO find a way to make this dynamic
background: Rectangle { background: Rectangle {
color: Theme.white color: Theme.white
radius: 8 radius: 8