Skip to content

Commit

Permalink
gallery: implemented auto-resize for TextAreas
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubos committed Aug 14, 2023
1 parent e90a40c commit 1c3fa90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 7 additions & 1 deletion app/qmlV2/component/MMTextArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ import "../Style.js" as Style
Item {
id: control

property alias areaHeight: textArea.height
property int areaHeight
property alias text: textArea.text
property alias placeholderText: textArea.placeholderText
property string warningMsg
property string errorMsg

// auto resize
property int minHeight: 50
property int maxHeight: 150
property bool autoHeight: false

width: 280 * __dp
height: textArea.height + messageItem.height

Expand All @@ -30,6 +35,7 @@ Item {
property string warningMsg
property string errorMsg

height: control.autoHeight ? ( contentHeight+10 > control.minHeight ? contentHeight+10 > control.maxHeight ? control.maxHeight : contentHeight+10 : control.minHeight ) : control.areaHeight
width: parent.width
hoverEnabled: true
placeholderTextColor: Style.night_6
Expand Down
13 changes: 10 additions & 3 deletions gallery/qml/pages/TextAreaPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ Column {
spacing: 20
anchors.fill: parent
MMTextArea {
areaHeight: 100
areaHeight: 50
placeholderText: "Place holder"
}
MMTextArea {
areaHeight: 100
areaHeight: 50
text: "Disabled"
enabled: false
}
MMTextArea {
areaHeight: 100
areaHeight: 50
text: "Something important"
warningMsg: "Be careful"
}
Expand All @@ -51,6 +51,13 @@ Column {
text: "Something wrong"
errorMsg: "Error message"
}
MMTextArea {
areaHeight: 50
text: "autoHeight: true\nminHeight: 50\nmaxHeight: 150"
minHeight: 50
maxHeight: 150
autoHeight: true
}
}
}
}

0 comments on commit 1c3fa90

Please sign in to comment.