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
|
|
|
|
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
|
|
|
|
2022-05-03 11:34:30 +00:00
|
|
|
Keys.onEscapePressed: {
|
2022-05-13 15:27:26 +00:00
|
|
|
Global.closeCreateChatView()
|
2022-06-12 16:17:18 +00:00
|
|
|
root.rootStore.openCreateChat = false;
|
2022-05-03 11:34:30 +00:00
|
|
|
}
|
|
|
|
|
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 {
|
2022-06-12 16:17:18 +00:00
|
|
|
property string pubKey: model.pubKey
|
|
|
|
property string displayName: model.displayName
|
2022-02-15 21:00:05 +00:00
|
|
|
property string icon: model.icon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-13 15:27:26 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
for (var i = 0; i < contactsModelListView.count; i ++) {
|
|
|
|
var entry = contactsModelListView.itemAtIndex(i);
|
|
|
|
contactsModel.insert(contactsModel.count,
|
|
|
|
{"pubKey": entry.pubKey, "displayName": entry.displayName,
|
|
|
|
"icon": entry.icon});
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
2022-05-13 15:27:26 +00:00
|
|
|
tagSelector.sortModel(root.contactsModel);
|
|
|
|
} else {
|
|
|
|
contactsModel.clear();
|
|
|
|
tagSelector.namesModel.clear();
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createChat() {
|
|
|
|
if (tagSelector.namesModel.count === 1) {
|
|
|
|
var ensName = tagSelector.namesModel.get(0).name.includes(".eth") ? tagSelector.namesModel.get(0).name : "";
|
2022-06-12 16:17:18 +00:00
|
|
|
root.rootStore.chatCommunitySectionModule.createOneToOneChat("", tagSelector.namesModel.get(0).pubKey, ensName);
|
2022-02-15 21:00:05 +00:00
|
|
|
} else {
|
|
|
|
var groupName = "";
|
2022-06-12 16:17:18 +00:00
|
|
|
var pubKeys = [];
|
2022-02-15 21:00:05 +00:00
|
|
|
for (var i = 0; i < tagSelector.namesModel.count; i++) {
|
|
|
|
groupName += (tagSelector.namesModel.get(i).name + (i === tagSelector.namesModel.count - 1 ? "" : "&"));
|
2022-06-12 16:17:18 +00:00
|
|
|
pubKeys.push(tagSelector.namesModel.get(i).pubKey);
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
2022-05-13 15:27:26 +00:00
|
|
|
root.rootStore.chatCommunitySectionModule.createGroupChat("", groupName, JSON.stringify(pubKeys));
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
2022-03-22 08:29:58 +00:00
|
|
|
|
|
|
|
chatInput.textInput.clear();
|
|
|
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
|
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
2022-05-13 15:27:26 +00:00
|
|
|
Global.changeAppSectionBySectionType(Constants.appSection.chat)
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-05-13 17:11:02 +00:00
|
|
|
// TODO: Could it be replaced to `GroupChatPanel`?
|
2022-02-15 21:00:05 +00:00
|
|
|
header: RowLayout {
|
|
|
|
id: headerRow
|
2022-07-12 13:16:33 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
2022-02-15 21:00:05 +00:00
|
|
|
height: tagSelector.height
|
2022-04-07 17:13:23 +00:00
|
|
|
clip: true
|
2022-07-15 14:53:29 +00:00
|
|
|
spacing: Style.current.padding
|
2022-02-15 21:00:05 +00:00
|
|
|
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
|
2022-05-06 14:06:27 +00:00
|
|
|
nameCountLimit: 20
|
2022-07-07 14:16:17 +00:00
|
|
|
listLabel: contactsModel.count ? qsTr("Contacts") : ""
|
|
|
|
textEdit.enabled: contactsModel.count
|
2022-02-15 21:00:05 +00:00
|
|
|
toLabelText: qsTr("To: ")
|
|
|
|
warningText: qsTr("USER LIMIT REACHED")
|
2022-05-16 15:40:14 +00:00
|
|
|
ringSpecModelGetter: function(pubKey) {
|
|
|
|
return Utils.getColorHashAsJson(pubKey);
|
|
|
|
}
|
|
|
|
compressedKeyGetter: function(pubKey) {
|
|
|
|
return Utils.getCompressedPk(pubKey);
|
|
|
|
}
|
2022-05-31 10:50:06 +00:00
|
|
|
colorIdForPubkeyGetter: function (pubKey) {
|
|
|
|
return Utils.colorIdForPubkey(pubKey);
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
onTextChanged: {
|
2022-03-23 21:31:30 +00:00
|
|
|
sortModel(root.contactsModel);
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: confirmButton
|
2022-07-15 14:53:29 +00:00
|
|
|
implicitWidth: 106
|
2022-02-15 21:00:05 +00:00
|
|
|
implicitHeight: 44
|
2022-03-23 21:31:30 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-07-07 14:16:17 +00:00
|
|
|
enabled: tagSelector.namesModel.count > 0
|
|
|
|
text: qsTr("Confirm")
|
2022-02-15 21:00:05 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2022-05-27 15:14:05 +00:00
|
|
|
|
|
|
|
Item {
|
2022-07-15 14:53:29 +00:00
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
2022-05-27 15:14:05 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
|
|
|
StatusActivityCenterButton {
|
|
|
|
id: notificationButton
|
2022-07-15 14:53:29 +00:00
|
|
|
anchors.right: parent.right
|
2022-05-27 15:14:05 +00:00
|
|
|
unreadNotificationsCount: activityCenter.unreadNotificationsCount
|
|
|
|
onClicked: activityCenter.open()
|
|
|
|
}
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
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
|
2022-04-01 09:52:44 +00:00
|
|
|
closeGifPopupAfterSelection: true
|
2022-03-22 08:29:58 +00:00
|
|
|
|
|
|
|
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 {
|
2022-07-15 14:53:29 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 252
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 252
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2022-07-12 14:48:07 +00:00
|
|
|
anchors.verticalCenterOffset: -(headerRow.height/2)
|
2022-02-15 21:00:05 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-07-07 14:16:17 +00:00
|
|
|
visible: contactsModel.count === 0
|
2022-02-15 21:00:05 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.baseColor1
|
2022-07-15 14:53:29 +00:00
|
|
|
text: qsTr("You can only send direct messages to your Contacts.\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.")
|
2022-02-15 21:00:05 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (visible) {
|
|
|
|
tagSelector.enabled = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|