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:
parent
359d0ab252
commit
3169fe636b
|
@ -248,18 +248,15 @@ StackLayout {
|
||||||
qsTr("Contact") :
|
qsTr("Contact") :
|
||||||
qsTr("Contact request pending") :
|
qsTr("Contact request pending") :
|
||||||
qsTr("Not a contact"))
|
qsTr("Not a contact"))
|
||||||
break;
|
|
||||||
case Constants.chatTypePublic:
|
case Constants.chatTypePublic:
|
||||||
return qsTr("Public chat")
|
return qsTr("Public chat")
|
||||||
case Constants.chatTypePrivateGroupChat:
|
case Constants.chatTypePrivateGroupChat:
|
||||||
let cnt = chatsModel.channelView.activeChannel.members.rowCount();
|
let cnt = chatsModel.channelView.activeChannel.members.rowCount();
|
||||||
if(cnt > 1) return qsTr("%1 members").arg(cnt);
|
if(cnt > 1) return qsTr("%1 members").arg(cnt);
|
||||||
return qsTr("1 member");
|
return qsTr("1 member");
|
||||||
break;
|
|
||||||
case Constants.chatTypeCommunity:
|
case Constants.chatTypeCommunity:
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chatInfoButton.image.source: profileImage || chatsModel.channelView.activeChannel.identicon
|
chatInfoButton.image.source: profileImage || chatsModel.channelView.activeChannel.identicon
|
||||||
|
@ -291,6 +288,11 @@ StackLayout {
|
||||||
notificationButton.visible: appSettings.isActivityCenterEnabled
|
notificationButton.visible: appSettings.isActivityCenterEnabled
|
||||||
notificationCount: chatsModel.activityNotificationList.unreadCount
|
notificationCount: chatsModel.activityNotificationList.unreadCount
|
||||||
|
|
||||||
|
onSearchButtonClicked: searchPopup.open()
|
||||||
|
SearchPopup {
|
||||||
|
id: searchPopup
|
||||||
|
}
|
||||||
|
|
||||||
onMembersButtonClicked: showUsers = !showUsers
|
onMembersButtonClicked: showUsers = !showUsers
|
||||||
onNotificationButtonClicked: activityCenter.open()
|
onNotificationButtonClicked: activityCenter.open()
|
||||||
|
|
||||||
|
|
|
@ -21,23 +21,23 @@ Popup {
|
||||||
y: Math.round(((parent ? parent.height : 0) - height) / 2)
|
y: Math.round(((parent ? parent.height : 0) - height) / 2)
|
||||||
width: 690
|
width: 690
|
||||||
height: {
|
height: {
|
||||||
if (!searchResults || !searchResults.length) {
|
const noResultHeight = 122
|
||||||
return 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
|
if (minHeight > maxHeight) {
|
||||||
const childrenHeight = searchHeader.height + channelBadge.height + channelBadge.anchors.topMargin +
|
return maxHeight
|
||||||
searchResultContent.height + searchResultContent.anchors.topMargin
|
}
|
||||||
|
|
||||||
// min height
|
if (messageColumn.height < minHeight - noResultHeight) {
|
||||||
if (childrenHeight < 560) {
|
return minHeight
|
||||||
return 560
|
|
||||||
}
|
}
|
||||||
// max height
|
if (messageColumn.height > maxHeight - noResultHeight) {
|
||||||
if (childrenHeight > 970) {
|
return maxHeight
|
||||||
return 970
|
|
||||||
}
|
}
|
||||||
return childrenHeight
|
|
||||||
}
|
}
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: Style.current.background
|
color: Style.current.background
|
||||||
|
@ -49,7 +49,6 @@ Popup {
|
||||||
}
|
}
|
||||||
onClosed: {
|
onClosed: {
|
||||||
popupOpened = false
|
popupOpened = false
|
||||||
destroy()
|
|
||||||
}
|
}
|
||||||
padding: 0
|
padding: 0
|
||||||
|
|
||||||
|
@ -70,13 +69,14 @@ Popup {
|
||||||
|
|
||||||
property var searchMessages: Backpressure.debounce(searchInput, 400, function (value) {
|
property var searchMessages: Backpressure.debounce(searchInput, 400, function (value) {
|
||||||
if (value === "") {
|
if (value === "") {
|
||||||
searchResults = []
|
searchResultContent.visible = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add loading?
|
// TODO add loading?
|
||||||
const messageIdsStr = chatsModel.messageView.messageList.messageSearch(value)
|
const messageIdsStr = chatsModel.messageView.messageList.messageSearch(value)
|
||||||
try {
|
try {
|
||||||
|
searchResultContent.visible = true
|
||||||
searchResults = JSON.parse(messageIdsStr)
|
searchResults = JSON.parse(messageIdsStr)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error ("Error parsing search result", e)
|
console.error ("Error parsing search result", e)
|
||||||
|
@ -142,8 +142,7 @@ Popup {
|
||||||
id: searchResultContent
|
id: searchResultContent
|
||||||
visible: !!popup.searchResults && popup.searchResults.length > 0
|
visible: !!popup.searchResults && popup.searchResults.length > 0
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: visible ? implicitHeight + anchors.topMargin : 0
|
anchors.bottom: parent.bottom
|
||||||
implicitHeight: childrenRect.height
|
|
||||||
anchors.top: channelBadge.bottom
|
anchors.top: channelBadge.bottom
|
||||||
anchors.topMargin: visible ? 13 : 0
|
anchors.topMargin: visible ? 13 : 0
|
||||||
|
|
||||||
|
@ -164,11 +163,18 @@ Popup {
|
||||||
anchors.leftMargin: Style.current.bigPadding
|
anchors.leftMargin: Style.current.bigPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
ScrollView {
|
||||||
|
id: scrollView
|
||||||
anchors.top: sectionTitle.bottom
|
anchors.top: sectionTitle.bottom
|
||||||
anchors.topMargin: 4
|
anchors.topMargin: 4
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.bottomMargin: Style.current.smallPadding
|
||||||
|
width: parent.width
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: messageColumn
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: searchResultContent.visible ? childrenRect.height : 0
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
@ -228,4 +234,5 @@ Popup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue