From d827433ad47d8667e8dd99920ee5ff4706cc77de Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 18 May 2021 13:17:04 -0400 Subject: [PATCH] fix chat section being squished --- ui/app/AppLayouts/Chat/ChatColumn.qml | 108 ++++++++++++++++-- .../Chat/ChatColumn/ChatMessages.qml | 1 - 2 files changed, 96 insertions(+), 13 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index 24d1175f31..e291bb7fd2 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -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} } -##^##*/ +##^##*/ \ No newline at end of file diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml index 768b98360e..5bf09eb6d9 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml @@ -76,7 +76,6 @@ ScrollView { } } - Timer { id: timer }