fix: fix QML warnings and errors

This commit is contained in:
Jonathan Rainville 2020-07-20 11:38:24 -04:00 committed by Iuri Matias
parent 9612f890b4
commit f51399ff1f
3 changed files with 38 additions and 32 deletions

View File

@ -128,36 +128,6 @@ StackLayout {
}
}
SuggestionBox {
id: suggestionsBox
model: suggestions
width: chatContainer.width
anchors.bottom: inputArea.top
anchors.left: inputArea.left
filter: chatInput.textInput.text
property: "ensName, alias"
onItemSelected: function (item) {
let currentText = chatInput.textInput.text
let lastAt = currentText.lastIndexOf("@")
let aliasName = item[suggestionsBox.property.split(",").map(p => p.trim()).find(p => !!item[p])]
let nameLen = aliasName.length + 2 // We're doing a +2 here because of the `@` and the trailing whitespace
let position = 0;
let text = ""
if (currentText.length == 1) {
position = nameLen
text = "@" + aliasName + " "
} else {
let left = currentText.slice(0, lastAt)
position = left.length + nameLen
text = left + "@" + aliasName + " "
}
chatInput.textInput.text = text
chatInput.textInput.cursorPosition = position
suggestionsBox.suggestionsModel.clear()
}
}
Rectangle {
id: inputArea
@ -170,6 +140,36 @@ StackLayout {
height: !isReply ? 70 : 140
Layout.preferredHeight: height
SuggestionBox {
id: suggestionsBox
model: suggestions
width: chatContainer.width
anchors.bottom: inputArea.top
anchors.left: inputArea.left
filter: chatInput.textInput.text
property: "ensName, alias"
onItemSelected: function (item) {
let currentText = chatInput.textInput.text
let lastAt = currentText.lastIndexOf("@")
let aliasName = item[suggestionsBox.property.split(",").map(p => p.trim()).find(p => !!item[p])]
let nameLen = aliasName.length + 2 // We're doing a +2 here because of the `@` and the trailing whitespace
let position = 0;
let text = ""
if (currentText.length === 1) {
position = nameLen
text = "@" + aliasName + " "
} else {
let left = currentText.slice(0, lastAt)
position = left.length + nameLen
text = left + "@" + aliasName + " "
}
chatInput.textInput.text = text
chatInput.textInput.cursorPosition = position
suggestionsBox.suggestionsModel.clear()
}
}
ReplyArea {
id: replyAreaContainer

View File

@ -22,7 +22,13 @@ Rectangle {
Repeater {
id: imageRepeater
model: imageUrls.split(" ")
model: {
if (!imageUrls) {
return []
}
return imageUrls.split(" ")
}
Image {
id: imageMessage

View File

@ -36,7 +36,7 @@ Rectangle {
z: parent.z + 100
visible: filter.length > 0 && suggestionsModel.count > 0
height: visible ? childrenRect.height + (Style.current.padding * 2) : 0
height: visible ? popup.height + (Style.current.padding * 2) : 0
opacity: visible ? 1.0 : 0
Behavior on opacity {
NumberAnimation { }