fix chat section being squished

This commit is contained in:
Jonathan Rainville 2021-05-18 13:17:04 -04:00
parent 8340a28ad1
commit d827433ad4
2 changed files with 96 additions and 13 deletions

View File

@ -29,17 +29,16 @@ StackLayout {
property var doNotShowAddToContactBannerToThose: ([])
property var onActivated: function () {
inputArea.chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
}
property string activeChatId: chatsModel.activeChannel.id
property bool isBlocked: profileModel.contacts.isContactBlocked(activeChatId)
property bool isContact: profileModel.contacts.isAdded(activeChatId)
property alias input: inputArea.chatInput
property string currentNotificationChatId
property string currentNotificationCommunityId
property alias input: chatInput
property string hoveredMessage
property string activeMessage
@ -61,7 +60,7 @@ StackLayout {
}
Component.onCompleted: {
inputArea.chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
}
Layout.fillHeight: true
@ -99,12 +98,12 @@ StackLayout {
identicon: chatsModel.messageList.getMessageData(i, "identicon"),
localNickname: chatsModel.messageList.getMessageData(i, "localName")
})
inputArea.chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
idMap[contactAddr] = true;
}
function populateSuggestions() {
inputArea.chatInput.suggestionsList.clear()
chatInput.suggestionsList.clear()
const len = chatsModel.suggestionList.rowCount()
idMap = {}
@ -120,7 +119,7 @@ StackLayout {
localNickname: chatsModel.suggestionList.rowData(i, "localNickname")
})
inputArea.chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
idMap[contactAddr] = true;
}
const len2 = chatsModel.messageList.rowCount();
@ -139,7 +138,7 @@ StackLayout {
let message = chatsModel.messageList.getMessageData(replyMessageIndex, "message")
let identicon = chatsModel.messageList.getMessageData(replyMessageIndex, "identicon")
inputArea.chatInput.showReplyArea(userName, message, identicon)
chatInput.showReplyArea(userName, message, identicon)
}
function requestAddressForTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
@ -284,8 +283,8 @@ StackLayout {
Connections {
target: chatsModel
onActiveChannelChanged: {
inputArea.chatInput.suggestions.hide();
inputArea.chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
chatInput.suggestions.hide();
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
populateSuggestions();
}
onMessagePushed: {
@ -306,11 +305,96 @@ StackLayout {
Layout.bottomMargin: Style.current.bigPadding
}
InputArea {
Item {
id: inputArea
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.fillWidth: true
Layout.preferredWidth: parent.width
height: chatInput.height
Layout.preferredHeight: height
Connections {
target: chatsModel
onLoadingMessagesChanged:
if(value){
loadingMessagesIndicator.active = true
} else {
timer.setTimeout(function(){
loadingMessagesIndicator.active = false;
}, 5000);
}
}
Loader {
id: loadingMessagesIndicator
active: chatsModel.loadingMessages
sourceComponent: loadingIndicator
anchors.right: parent.right
anchors.bottom: chatInput.top
anchors.rightMargin: Style.current.padding
anchors.bottomMargin: Style.current.padding
}
Component {
id: loadingIndicator
LoadingAnimation {}
}
StatusChatInput {
id: chatInput
visible: {
const community = chatsModel.communities.activeCommunity
if (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
return chatsModel.activeChannel.isMember
}
return !community.active ||
community.access === Constants.communityChatPublicAccess ||
community.admin ||
chatsModel.activeChannel.canPost
}
enabled: !isBlocked
chatInputPlaceholder: isBlocked ?
//% "This user has been blocked."
qsTrId("this-user-has-been-blocked-") :
//% "Type a message."
qsTrId("type-a-message-")
anchors.bottom: parent.bottom
recentStickers: chatsModel.stickers.recent
stickerPackList: chatsModel.stickers.stickerPacks
chatType: chatsModel.activeChannel.chatType
onSendTransactionCommandButtonClicked: {
if (chatsModel.activeChannel.ensVerified) {
txModalLoader.sourceComponent = cmpSendTransactionWithEns
} else {
txModalLoader.sourceComponent = cmpSendTransactionNoEns
}
txModalLoader.item.open()
}
onReceiveTransactionCommandButtonClicked: {
txModalLoader.sourceComponent = cmpReceiveTransaction
txModalLoader.item.open()
}
onStickerSelected: {
chatsModel.stickers.send(hashId, packId)
}
onSendMessage: {
if (chatInput.fileUrls.length > 0){
chatsModel.sendImages(JSON.stringify(fileUrls));
}
let msg = chatsModel.plainText(Emoji.deparse(chatInput.textInput.text))
if (msg.length > 0){
msg = chatInput.interpretMessage(msg)
chatsModel.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false, JSON.stringify(suggestionsObj));
if(event) event.accepted = true
sendMessageSound.stop();
Qt.callLater(sendMessageSound.play);
chatInput.textInput.clear();
chatInput.textInput.textFormat = TextEdit.PlainText;
chatInput.textInput.textFormat = TextEdit.RichText;
}
}
}
}
}
@ -413,4 +497,4 @@ StackLayout {
Designer {
D{i:0;formeditorColor:"#ffffff";height:770;width:800}
}
##^##*/
##^##*/

View File

@ -76,7 +76,6 @@ ScrollView {
}
}
Timer {
id: timer
}