From 1a829828c8e873819505cf96b96a6485018f659f Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 28 May 2020 08:56:43 -0400 Subject: [PATCH] feat: private chat popup --- ui/app/AppLayouts/Chat/ChatColumn.qml | 1 + ui/app/AppLayouts/Chat/ContactsColumn.qml | 4 + .../Chat/ContactsColumn/AddChat.qml | 4 +- .../Chat/ContactsColumn/SearchBox.qml | 2 +- .../Chat/components/PrivateChatPopup.qml | 138 ++++++++++++++++++ .../Chat/components/PublicChatPopup.qml | 2 +- ui/app/AppLayouts/Chat/components/qmldir | 3 +- ui/nim-status-client.pro | 1 + 8 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index a9478ed490..133259235a 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -11,6 +11,7 @@ StackLayout { property int chatGroupsListViewCount: 0 Layout.fillHeight: true Layout.fillWidth: true + Layout.minimumWidth: 300 currentIndex: chatGroupsListViewCount > 0 ? 0 : 1 diff --git a/ui/app/AppLayouts/Chat/ContactsColumn.qml b/ui/app/AppLayouts/Chat/ContactsColumn.qml index f3749c26f3..01a5985bca 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn.qml @@ -32,6 +32,10 @@ Item { id: publicChatPopup } + PrivateChatPopup { + id: privateChatPopup + } + SearchBox { id: searchBox } diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/AddChat.qml b/ui/app/AppLayouts/Chat/ContactsColumn/AddChat.qml index 88d6a37e41..060836ef09 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/AddChat.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/AddChat.qml @@ -87,9 +87,7 @@ Rectangle { QQC2.Action { text: qsTr("Start new chat") icon.source: "../../../img/new_chat.svg" - onTriggered: { - console.log("TODO: Start new chat") - } + onTriggered: privateChatPopup.open() } QQC2.Action { text: qsTr("Start group chat") diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/SearchBox.qml b/ui/app/AppLayouts/Chat/ContactsColumn/SearchBox.qml index f09922d9e1..4ac8855398 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/SearchBox.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/SearchBox.qml @@ -36,7 +36,7 @@ Rectangle { anchors.leftMargin: 10 anchors.verticalCenter: parent.verticalCenter fillMode: Image.PreserveAspectFit - source: "../../img/search.svg" + source: "../../../img/search.svg" } MouseArea { diff --git a/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml new file mode 100644 index 0000000000..cdf2c8b0d2 --- /dev/null +++ b/ui/app/AppLayouts/Chat/components/PrivateChatPopup.qml @@ -0,0 +1,138 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 +import "../../../../imports" +import "../../../../shared" +import "./" + +Item { + function open(){ + popup.open() + chatKey.text = ""; + chatKey.forceActiveFocus(Qt.MouseFocusReason) + } + + function close(){ + popup.close() + } + + Popup { + id: popup + modal: true + closePolicy: Popup.NoAutoClose + Overlay.modal: Rectangle { + color: "#60000000" + } + parent: Overlay.overlay + x: Math.round((parent.width - width) / 2) + y: Math.round((parent.height - height) / 2) + width: 480 + height: 509 + background: Rectangle { + color: Theme.white + radius: 8 + } + padding: 0 + contentItem: Item { + Text { + id: modalDialogTitle + text: qsTr("New chat") + anchors.top: parent.top + anchors.left: parent.left + font.bold: true + font.pixelSize: 17 + anchors.leftMargin: 16 + anchors.topMargin: 16 + } + + Image { + id: closeModalImg + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: 16 + anchors.topMargin: 16 + source: "../../../img/close.svg" + MouseArea { + id: closeModalMouseArea + cursorShape: Qt.PointingHandCursor + anchors.fill: parent + onClicked : { + popup.close() + } + } + } + + Separator { + id: separator + anchors.top: modalDialogTitle.bottom + } + + Rectangle { + id: chatKeyBox + height: 44 + color: Theme.grey + anchors.top: separator.bottom + anchors.topMargin: 16 + radius: 8 + anchors.right: parent.right + anchors.rightMargin: 16 + anchors.left: parent.left + anchors.leftMargin: 16 + + TextField { + id: chatKey + placeholderText: qsTr("Enter ENS username or chat key") + anchors.left: parent.left + anchors.leftMargin: 16 + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 15 + background: Rectangle { + color: "#00000000" + } + width: popup.width - 65 + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked : { + chatKey.forceActiveFocus(Qt.MouseFocusReason) + } + } + } + + Separator { + id: separator2 + anchors.bottom: parent.bottom + anchors.bottomMargin: 75 + } + + Button { + id: btnNewChat + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.bottomMargin: 16 + anchors.rightMargin: 16 + width: 44 + height: 44 + Image { + source: chatKey.text == "" ? "../../../img/arrow-button-inactive.svg" : "../../../img/arrow-btn-active.svg" + } + background: Rectangle { + color: "transparent" + } + MouseArea { + id: btnMAnewChat + cursorShape: Qt.PointingHandCursor + anchors.fill: parent + onClicked : { + if(chatKey.text === "") return; + // chatsModel.joinChat(chatKey.text); + console.log("TODO: join private chat"); + popup.close(); + } + } + } + } + } +} diff --git a/ui/app/AppLayouts/Chat/components/PublicChatPopup.qml b/ui/app/AppLayouts/Chat/components/PublicChatPopup.qml index b71e7830e6..3b93c34be8 100644 --- a/ui/app/AppLayouts/Chat/components/PublicChatPopup.qml +++ b/ui/app/AppLayouts/Chat/components/PublicChatPopup.qml @@ -8,6 +8,7 @@ import "./" Item { function open(){ popup.open() + channelName.text = ""; channelName.forceActiveFocus(Qt.MouseFocusReason) } @@ -189,7 +190,6 @@ Item { onClicked : { if(channelName.text === "") return; chatsModel.joinChat(channelName.text); - channelName.text = ""; popup.close(); } } diff --git a/ui/app/AppLayouts/Chat/components/qmldir b/ui/app/AppLayouts/Chat/components/qmldir index 358b86ac2e..f3ca6cbdc5 100644 --- a/ui/app/AppLayouts/Chat/components/qmldir +++ b/ui/app/AppLayouts/Chat/components/qmldir @@ -1,2 +1,3 @@ SuggestedChannel 1.0 SuggestedChannel.qml -PublicChatPopup 1.0 PublicChatPopup.qml \ No newline at end of file +PublicChatPopup 1.0 PublicChatPopup.qml +PrivateChatPopup 1.0 PrivateChatPopup.qml \ No newline at end of file diff --git a/ui/nim-status-client.pro b/ui/nim-status-client.pro index 25945726e9..6bf8e68943 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -54,6 +54,7 @@ DISTFILES += \ app/AppLayouts/Chat/ChatLayout.qml \ app/AppLayouts/Chat/ContactsColumn.qml \ app/AppLayouts/Chat/components/PublicChatPopup.qml \ + app/AppLayouts/Chat/components/PrivateChatPopup.qml \ app/AppLayouts/Chat/components/SuggestedChannel.qml \ app/AppLayouts/Chat/components/qmldir \ app/AppLayouts/Chat/qmldir \