From 3adb5deeb03323a3f931bc76b04aace20c954719 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 27 May 2020 19:06:41 -0400 Subject: [PATCH] extract ChatInput into its own file --- ui/app/AppLayouts/Chat/ChatColumn.qml | 74 +---------------- .../AppLayouts/Chat/ChatColumn/ChatInput.qml | 81 +++++++++++++++++++ ui/app/AppLayouts/Chat/ChatColumn/qmldir | 3 +- 3 files changed, 84 insertions(+), 74 deletions(-) create mode 100644 ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index ae21b7a267..20de136921 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -43,79 +43,7 @@ StackLayout { Layout.alignment: Qt.AlignLeft | Qt.AlignBottom transformOrigin: Item.Bottom - Rectangle { - id: element2 - width: 200 - height: 70 - Layout.fillWidth: true - color: "white" - border.width: 0 - - Rectangle { - id: rectangle - color: "#00000000" - border.color: Theme.grey - anchors.fill: parent - - Button { - id: chatSendBtn - x: 100 - width: 30 - height: 30 - text: "\u2191" - font.bold: true - font.pointSize: 12 - anchors.top: parent.top - anchors.topMargin: 20 - anchors.right: parent.right - anchors.rightMargin: 16 - onClicked: { - chatsModel.onSend(txtData.text) - txtData.text = "" - } - enabled: txtData.text !== "" - background: Rectangle { - color: parent.enabled ? Theme.blue : Theme.grey - radius: 50 - } - } - - TextField { - id: txtData - text: "" - leftPadding: 0 - padding: 0 - font.pixelSize: 14 - placeholderText: qsTr("Type a message...") - anchors.right: chatSendBtn.left - anchors.rightMargin: 16 - anchors.top: parent.top - anchors.topMargin: 24 - anchors.left: parent.left - anchors.leftMargin: 24 - Keys.onEnterPressed: { - chatsModel.onSend(txtData.text) - txtData.text = "" - } - Keys.onReturnPressed: { - chatsModel.onSend(txtData.text) - txtData.text = "" - } - background: Rectangle { - color: "#00000000" - } - } - - MouseArea { - id: mouseArea1 - anchors.rightMargin: 50 - anchors.fill: parent - onClicked: { - txtData.forceActiveFocus(Qt.MouseFocusReason) - } - } - } - } + ChatInput {} } } diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml new file mode 100644 index 0000000000..97a67d2a6f --- /dev/null +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatInput.qml @@ -0,0 +1,81 @@ +import QtQuick 2.3 +import QtQuick.Controls 2.3 +import QtQuick.Controls 2.12 as QQC2 +import QtQuick.Layouts 1.3 +import Qt.labs.platform 1.1 +import "../../../../shared" +import "../../../../imports" + +Rectangle { + id: element2 + width: 200 + height: 70 + Layout.fillWidth: true + color: "white" + border.width: 0 + + Rectangle { + id: rectangle + color: "#00000000" + border.color: Theme.grey + anchors.fill: parent + + Button { + id: chatSendBtn + x: 100 + width: 30 + height: 30 + text: "\u2191" + font.bold: true + font.pointSize: 12 + anchors.top: parent.top + anchors.topMargin: 20 + anchors.right: parent.right + anchors.rightMargin: 16 + onClicked: { + chatsModel.onSend(txtData.text) + txtData.text = "" + } + enabled: txtData.text !== "" + background: Rectangle { + color: parent.enabled ? Theme.blue : Theme.grey + radius: 50 + } + } + + TextField { + id: txtData + text: "" + leftPadding: 0 + padding: 0 + font.pixelSize: 14 + placeholderText: qsTr("Type a message...") + anchors.right: chatSendBtn.left + anchors.rightMargin: 16 + anchors.top: parent.top + anchors.topMargin: 24 + anchors.left: parent.left + anchors.leftMargin: 24 + Keys.onEnterPressed: { + chatsModel.onSend(txtData.text) + txtData.text = "" + } + Keys.onReturnPressed: { + chatsModel.onSend(txtData.text) + txtData.text = "" + } + background: Rectangle { + color: "#00000000" + } + } + + MouseArea { + id: mouseArea1 + anchors.rightMargin: 50 + anchors.fill: parent + onClicked: { + txtData.forceActiveFocus(Qt.MouseFocusReason) + } + } + } +} \ No newline at end of file diff --git a/ui/app/AppLayouts/Chat/ChatColumn/qmldir b/ui/app/AppLayouts/Chat/ChatColumn/qmldir index b27fe3b32b..998dab5789 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/qmldir +++ b/ui/app/AppLayouts/Chat/ChatColumn/qmldir @@ -1,2 +1,3 @@ TopBar 1.0 TopBar.qml -ChatMessages 1.0 ChatMessages.qml \ No newline at end of file +ChatMessages 1.0 ChatMessages.qml +ChatInput 1.0 ChatInput.qml \ No newline at end of file