2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-05-28 12:56:43 +00:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
2020-06-16 18:04:56 +00:00
|
|
|
import "../../Profile/Sections/Contacts/"
|
2020-05-28 12:56:43 +00:00
|
|
|
import "./"
|
|
|
|
|
2020-05-29 16:27:50 +00:00
|
|
|
ModalPopup {
|
2020-06-22 15:51:15 +00:00
|
|
|
property string validationError: ""
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
// TODO change this when we support ENS names
|
|
|
|
if (!Utils.isChatKey(chatKey.text)) {
|
|
|
|
validationError = "This needs to be a valid chat key"
|
|
|
|
} else {
|
|
|
|
validationError = ""
|
|
|
|
}
|
|
|
|
return validationError === ""
|
|
|
|
}
|
|
|
|
|
|
|
|
function doJoin() {
|
2020-06-16 18:04:56 +00:00
|
|
|
if (chatKey.text !== "") {
|
2020-06-22 15:51:15 +00:00
|
|
|
if (!validate()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-06-16 18:04:56 +00:00
|
|
|
chatsModel.joinChat(chatKey.text, Constants.chatTypeOneToOne);
|
|
|
|
} else if (contactListView.selectedContact.checked) {
|
|
|
|
chatsModel.joinChat(contactListView.selectedContact.parent.address, Constants.chatTypeOneToOne);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-15 16:24:21 +00:00
|
|
|
popup.close();
|
|
|
|
}
|
|
|
|
|
2020-05-28 12:56:43 +00:00
|
|
|
id: popup
|
2020-05-29 16:27:50 +00:00
|
|
|
title: qsTr("New chat")
|
|
|
|
|
2020-05-29 18:38:11 +00:00
|
|
|
onOpened: {
|
|
|
|
chatKey.text = "";
|
|
|
|
chatKey.forceActiveFocus(Qt.MouseFocusReason)
|
2020-06-22 15:51:15 +00:00
|
|
|
if (contactListView.selectedContact) {
|
|
|
|
contactListView.selectedContact.checked = false
|
|
|
|
}
|
2020-05-29 18:38:11 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 16:24:21 +00:00
|
|
|
Input {
|
|
|
|
id: chatKey
|
|
|
|
placeholderText: qsTr("Enter ENS username or chat key")
|
|
|
|
Keys.onEnterPressed: doJoin()
|
|
|
|
Keys.onReturnPressed: doJoin()
|
2020-06-22 15:51:15 +00:00
|
|
|
validationError: popup.validationError
|
|
|
|
textField.onEditingFinished: {
|
|
|
|
validate()
|
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
}
|
2020-05-28 12:56:43 +00:00
|
|
|
|
2020-06-16 18:04:56 +00:00
|
|
|
ContactList {
|
|
|
|
id: contactListView
|
|
|
|
contacts: profileModel.contactList
|
|
|
|
selectable: true
|
|
|
|
}
|
|
|
|
|
2020-05-29 16:27:50 +00:00
|
|
|
footer: Button {
|
|
|
|
width: 44
|
|
|
|
height: 44
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
Image {
|
|
|
|
source: chatKey.text == "" ? "../../../img/arrow-button-inactive.svg" : "../../../img/arrow-btn-active.svg"
|
2020-05-28 12:56:43 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
background: Rectangle {
|
|
|
|
color: "transparent"
|
2020-05-28 12:56:43 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
MouseArea {
|
|
|
|
id: btnMAnewChat
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
2020-06-15 16:24:21 +00:00
|
|
|
onClicked : doJoin()
|
2020-05-28 12:56:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-16 18:04:56 +00:00
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;height:300;width:300}
|
|
|
|
}
|
|
|
|
##^##*/
|