2022-02-15 21:00:05 +00:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import QtQml.Models 2.2
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
2022-03-22 08:29:58 +00:00
|
|
|
import shared.status 1.0
|
2022-02-15 21:00:05 +00:00
|
|
|
|
|
|
|
Page {
|
|
|
|
id: root
|
|
|
|
anchors.fill: parent
|
|
|
|
Behavior on anchors.bottomMargin { NumberAnimation { duration: 30 }}
|
2022-03-22 08:29:58 +00:00
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
property ListModel contactsModel: ListModel { }
|
|
|
|
property var rootStore
|
2022-03-22 08:29:58 +00:00
|
|
|
property var emojiPopup: null
|
2022-02-15 21:00:05 +00:00
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: contactsModelListView
|
2022-03-22 08:29:58 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2022-02-15 21:00:05 +00:00
|
|
|
model: root.rootStore.contactsModel
|
|
|
|
delegate: Item {
|
|
|
|
property string publicId: model.pubKey
|
|
|
|
property string name: model.name
|
|
|
|
property string icon: model.icon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: rootStore
|
|
|
|
onOpenCreateChatChanged: {
|
|
|
|
if (root.rootStore.openCreateChat) {
|
|
|
|
for (var i = 0; i < contactsModelListView.count; i ++) {
|
|
|
|
var entry = contactsModelListView.itemAtIndex(i);
|
|
|
|
contactsModel.insert(contactsModel.count,
|
|
|
|
{"publicId": entry.publicId, "name": entry.name,
|
2022-03-30 15:30:28 +00:00
|
|
|
"icon": entry.icon});
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
2022-03-28 19:33:38 +00:00
|
|
|
tagSelector.sortModel(root.contactsModel);
|
2022-02-15 21:00:05 +00:00
|
|
|
} else {
|
|
|
|
tagSelector.namesModel.clear();
|
|
|
|
contactsModel.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createChat() {
|
|
|
|
if (tagSelector.namesModel.count === 1) {
|
|
|
|
var ensName = tagSelector.namesModel.get(0).name.includes(".eth") ? tagSelector.namesModel.get(0).name : "";
|
|
|
|
root.rootStore.chatCommunitySectionModule.createOneToOneChat("", tagSelector.namesModel.get(0).publicId, ensName);
|
|
|
|
} else {
|
|
|
|
var groupName = "";
|
|
|
|
var publicIds = [];
|
|
|
|
for (var i = 0; i < tagSelector.namesModel.count; i++) {
|
|
|
|
groupName += (tagSelector.namesModel.get(i).name + (i === tagSelector.namesModel.count - 1 ? "" : "&"));
|
|
|
|
publicIds.push(tagSelector.namesModel.get(i).publicId);
|
|
|
|
}
|
|
|
|
root.rootStore.chatCommunitySectionModule.createGroupChat("",groupName, JSON.stringify(publicIds));
|
|
|
|
}
|
2022-03-22 08:29:58 +00:00
|
|
|
|
|
|
|
chatInput.textInput.clear();
|
|
|
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
|
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
visible: (opacity > 0.01)
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (!visible) {
|
|
|
|
tagSelector.namesModel.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
opacity: (root.rootStore.openCreateChat) ? 1.0 : 0.0
|
|
|
|
Behavior on opacity { NumberAnimation {}}
|
|
|
|
background: Rectangle {
|
|
|
|
anchors.fill: parent
|
2022-03-22 08:29:58 +00:00
|
|
|
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
header: RowLayout {
|
|
|
|
id: headerRow
|
|
|
|
width: parent.width
|
|
|
|
height: tagSelector.height
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 8
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 8
|
|
|
|
|
|
|
|
StatusTagSelector {
|
|
|
|
id: tagSelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
|
|
|
Layout.leftMargin: 17
|
2022-03-23 21:31:30 +00:00
|
|
|
maxHeight: root.height
|
|
|
|
listLabel: qsTr("Contacts")
|
2022-02-15 21:00:05 +00:00
|
|
|
toLabelText: qsTr("To: ")
|
|
|
|
warningText: qsTr("USER LIMIT REACHED")
|
|
|
|
onTextChanged: {
|
2022-03-23 21:31:30 +00:00
|
|
|
sortModel(root.contactsModel);
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: confirmButton
|
|
|
|
implicitHeight: 44
|
2022-03-23 21:31:30 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-02-15 21:00:05 +00:00
|
|
|
enabled: (tagSelector.namesModel.count > 0)
|
|
|
|
text: "Confirm"
|
|
|
|
onClicked: {
|
2022-03-22 08:29:58 +00:00
|
|
|
root.rootStore.createChatInitMessage = chatInput.textInput.text;
|
|
|
|
root.rootStore.createChatFileUrls = chatInput.fileUrls;
|
2022-02-15 21:00:05 +00:00
|
|
|
root.createChat();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: headerRow.height + 32
|
|
|
|
|
2022-03-22 08:29:58 +00:00
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
visible: tagSelector.namesModel.count > 0
|
|
|
|
chatType: tagSelector.namesModel.count == 1? Constants.chatType.oneToOne : Constants.chatType.privateGroupChat
|
|
|
|
|
|
|
|
emojiPopup: root.emojiPopup
|
|
|
|
recentStickers: root.rootStore.stickersModuleInst.recent
|
|
|
|
stickerPackList: root.rootStore.stickersModuleInst.stickerPacks
|
|
|
|
|
|
|
|
onSendTransactionCommandButtonClicked: {
|
|
|
|
root.rootStore.createChatStartSendTransactionProcess = true;
|
|
|
|
root.createChat();
|
|
|
|
}
|
|
|
|
|
|
|
|
onReceiveTransactionCommandButtonClicked: {
|
|
|
|
root.rootStore.createChatStartReceiveTransactionProcess = true;
|
|
|
|
root.createChat();
|
|
|
|
}
|
|
|
|
|
|
|
|
onStickerSelected: {
|
|
|
|
root.rootStore.createChatStickerHashId = hashId;
|
|
|
|
root.rootStore.createChatStickerPackId = packId;
|
|
|
|
root.createChat();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSendMessage: {
|
|
|
|
root.rootStore.createChatFileUrls = chatInput.fileUrls;
|
|
|
|
root.rootStore.createChatInitMessage = chatInput.textInput.text;
|
|
|
|
root.createChat();
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
width: parent.width
|
|
|
|
height: contentHeight
|
|
|
|
anchors.centerIn: parent
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
visible: (contactsModel.count === 0)
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: qsTr("You can only send direct messages to your Contacts.\n\n
|
|
|
|
Send a contact request to the person you would like to chat with, you will be able to
|
|
|
|
chat with them once they have accepted your contact request.")
|
|
|
|
Component.onCompleted: {
|
|
|
|
if (visible) {
|
|
|
|
tagSelector.enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|