fix(search): fix missing scroll and wrong heights

Also fixes a bug where if the search was cleared, messages would after that appear all on top of each other. 
Also leaves the popup live after closing so the search can be gone back to
This commit is contained in:
Jonathan Rainville 2021-07-12 13:42:40 -04:00 committed by Iuri Matias
parent 359d0ab252
commit 3169fe636b
2 changed files with 77 additions and 68 deletions

View File

@ -248,18 +248,15 @@ StackLayout {
qsTr("Contact") :
qsTr("Contact request pending") :
qsTr("Not a contact"))
break;
case Constants.chatTypePublic:
return qsTr("Public chat")
case Constants.chatTypePrivateGroupChat:
let cnt = chatsModel.channelView.activeChannel.members.rowCount();
if(cnt > 1) return qsTr("%1 members").arg(cnt);
return qsTr("1 member");
break;
case Constants.chatTypeCommunity:
default:
return ""
break;
}
}
chatInfoButton.image.source: profileImage || chatsModel.channelView.activeChannel.identicon
@ -291,6 +288,11 @@ StackLayout {
notificationButton.visible: appSettings.isActivityCenterEnabled
notificationCount: chatsModel.activityNotificationList.unreadCount
onSearchButtonClicked: searchPopup.open()
SearchPopup {
id: searchPopup
}
onMembersButtonClicked: showUsers = !showUsers
onNotificationButtonClicked: activityCenter.open()

View File

@ -21,23 +21,23 @@ Popup {
y: Math.round(((parent ? parent.height : 0) - height) / 2)
width: 690
height: {
if (!searchResults || !searchResults.length) {
return 122
const noResultHeight = 122
let minHeight = 560
const maxHeight = parent.height - 200
if (!searchResults || !searchResults.length || !searchResultContent.visible) {
return noResultHeight
}
// FIXME childrenRect has a binding loop for some reason
const childrenHeight = searchHeader.height + channelBadge.height + channelBadge.anchors.topMargin +
searchResultContent.height + searchResultContent.anchors.topMargin
if (minHeight > maxHeight) {
return maxHeight
}
// min height
if (childrenHeight < 560) {
return 560
if (messageColumn.height < minHeight - noResultHeight) {
return minHeight
}
// max height
if (childrenHeight > 970) {
return 970
if (messageColumn.height > maxHeight - noResultHeight) {
return maxHeight
}
return childrenHeight
}
background: Rectangle {
color: Style.current.background
@ -49,7 +49,6 @@ Popup {
}
onClosed: {
popupOpened = false
destroy()
}
padding: 0
@ -70,13 +69,14 @@ Popup {
property var searchMessages: Backpressure.debounce(searchInput, 400, function (value) {
if (value === "") {
searchResults = []
searchResultContent.visible = false
return
}
// TODO add loading?
const messageIdsStr = chatsModel.messageView.messageList.messageSearch(value)
try {
searchResultContent.visible = true
searchResults = JSON.parse(messageIdsStr)
} catch (e) {
console.error ("Error parsing search result", e)
@ -142,8 +142,7 @@ Popup {
id: searchResultContent
visible: !!popup.searchResults && popup.searchResults.length > 0
width: parent.width
height: visible ? implicitHeight + anchors.topMargin : 0
implicitHeight: childrenRect.height
anchors.bottom: parent.bottom
anchors.top: channelBadge.bottom
anchors.topMargin: visible ? 13 : 0
@ -164,11 +163,18 @@ Popup {
anchors.leftMargin: Style.current.bigPadding
}
Column {
ScrollView {
id: scrollView
anchors.top: sectionTitle.bottom
anchors.topMargin: 4
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.smallPadding
width: parent.width
clip: true
Column {
id: messageColumn
width: parent.width
height: searchResultContent.visible ? childrenRect.height : 0
spacing: 0
Repeater {
@ -228,4 +234,5 @@ Popup {
}
}
}
}
}