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
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
import shared.controls.delegates 1.0
|
2024-09-04 14:27:24 +00:00
|
|
|
import shared.status 1.0
|
|
|
|
import shared.stores 1.0 as SharedStores
|
|
|
|
import utils 1.0
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0 as ChatStores
|
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
Page {
|
|
|
|
id: root
|
2022-03-22 08:29:58 +00:00
|
|
|
|
2024-10-02 20:47:14 +00:00
|
|
|
property SharedStores.RootStore sharedRootStore
|
2024-05-22 08:13:39 +00:00
|
|
|
property ChatStores.RootStore rootStore
|
|
|
|
property ChatStores.CreateChatPropertiesStore createChatPropertiesStore
|
2022-03-22 08:29:58 +00:00
|
|
|
property var emojiPopup: null
|
2023-01-08 20:59:05 +00:00
|
|
|
property var stickersPopup: null
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2022-11-15 14:17:58 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
function createChat() {
|
2023-05-04 18:36:35 +00:00
|
|
|
root.createChatPropertiesStore.createChatInitMessage = chatInput.textInput.text
|
|
|
|
root.createChatPropertiesStore.createChatFileUrls = chatInput.fileUrlsAndSources
|
2022-11-15 14:17:58 +00:00
|
|
|
membersSelector.createChat()
|
|
|
|
|
|
|
|
membersSelector.cleanup()
|
|
|
|
chatInput.textInput.clear()
|
|
|
|
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
padding: 0
|
2022-02-15 21:00:05 +00:00
|
|
|
|
|
|
|
Behavior on opacity { NumberAnimation {}}
|
2022-09-06 13:19:50 +00:00
|
|
|
Behavior on anchors.bottomMargin { NumberAnimation { duration: 30 }}
|
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
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-09-06 13:19:50 +00:00
|
|
|
header: Item {
|
|
|
|
implicitHeight: headerLayout.implicitHeight + headerLayout.anchors.topMargin + headerLayout.anchors.bottomMargin
|
|
|
|
RowLayout {
|
|
|
|
id: headerLayout
|
2022-09-20 10:54:28 +00:00
|
|
|
anchors.fill: parent
|
2022-09-06 13:19:50 +00:00
|
|
|
MembersSelectorView {
|
|
|
|
id: membersSelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-09-20 10:54:28 +00:00
|
|
|
Layout.leftMargin: Style.current.halfPadding
|
|
|
|
Layout.rightMargin: Style.current.halfPadding
|
2022-09-06 13:19:50 +00:00
|
|
|
rootStore: root.rootStore
|
|
|
|
|
|
|
|
function createChat() {
|
|
|
|
if (model.count === 0) {
|
|
|
|
console.warn("Can't create chat with no members")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (model.count === 1) {
|
|
|
|
const member = model.get(0)
|
|
|
|
const ensName = member.displayName.includes(".eth") ? member.displayName : ""
|
|
|
|
root.rootStore.chatCommunitySectionModule.createOneToOneChat("", member.pubKey, ensName)
|
|
|
|
} else {
|
|
|
|
var groupName = "";
|
|
|
|
var pubKeys = [];
|
|
|
|
for (var i = 0; i < model.count; i++) {
|
|
|
|
const member = model.get(i)
|
|
|
|
groupName += (member.displayName + (i === model.count - 1 ? "" : "&"))
|
|
|
|
pubKeys.push(member.pubKey)
|
|
|
|
}
|
|
|
|
root.rootStore.chatCommunitySectionModule.createGroupChat("", groupName, JSON.stringify(pubKeys))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-15 14:17:58 +00:00
|
|
|
onConfirmed: { d.createChat() }
|
2022-09-06 13:19:50 +00:00
|
|
|
|
|
|
|
onRejected: {
|
|
|
|
cleanup()
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
}
|
|
|
|
|
2022-09-16 19:25:10 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible)
|
|
|
|
edit.forceActiveFocus()
|
|
|
|
}
|
2022-09-29 15:18:29 +00:00
|
|
|
|
|
|
|
onEnterKeyPressed: {
|
|
|
|
entryAccepted(contactsList.itemAtIndex(contactsList.currentIndex));
|
|
|
|
}
|
|
|
|
|
|
|
|
onUpKeyPressed: {
|
|
|
|
contactsList.decrementCurrentIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
onDownKeyPressed: {
|
|
|
|
contactsList.incrementCurrentIndex();
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
2022-05-27 15:14:05 +00:00
|
|
|
|
|
|
|
StatusActivityCenterButton {
|
2022-09-20 10:54:28 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-10-26 16:00:20 +00:00
|
|
|
unreadNotificationsCount: activityCenterStore.unreadNotificationsCount
|
2023-02-07 15:53:56 +00:00
|
|
|
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
|
2022-07-26 14:23:45 +00:00
|
|
|
onClicked: Global.openActivityCenterPopup()
|
2022-05-27 15:14:05 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
2022-09-06 13:19:50 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors {
|
|
|
|
fill: parent
|
2022-09-20 10:54:28 +00:00
|
|
|
topMargin: Style.current.bigPadding
|
|
|
|
bottomMargin: Style.current.padding
|
|
|
|
leftMargin: Style.current.halfPadding
|
2022-03-22 08:29:58 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-09-20 10:54:28 +00:00
|
|
|
Layout.leftMargin: Style.current.halfPadding
|
2022-09-06 13:19:50 +00:00
|
|
|
visible: contactsList.visible
|
|
|
|
font.pixelSize: 15
|
|
|
|
text: qsTr("Contacts")
|
|
|
|
color: Theme.palette.baseColor1
|
2022-03-22 08:29:58 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
StatusListView {
|
|
|
|
id: contactsList
|
2022-09-29 14:33:47 +00:00
|
|
|
objectName: "createChatContactsList"
|
2022-09-06 13:19:50 +00:00
|
|
|
|
2022-09-16 19:25:10 +00:00
|
|
|
Layout.fillWidth: true
|
2022-09-06 13:19:50 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
visible: membersSelector.suggestionsModel.count &&
|
|
|
|
!(membersSelector.edit.text !== "")
|
|
|
|
implicitWidth: contentItem.childrenRect.width
|
|
|
|
model: membersSelector.suggestionsModel
|
|
|
|
delegate: ContactListItemDelegate {
|
2022-09-16 19:25:10 +00:00
|
|
|
width: ListView.view.width
|
2022-09-29 15:18:29 +00:00
|
|
|
highlighted: ListView.isCurrentItem
|
2022-09-06 13:19:50 +00:00
|
|
|
onClicked: membersSelector.entryAccepted(this)
|
|
|
|
}
|
2022-03-22 08:29:58 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: membersSelector.model.count > 0
|
|
|
|
chatType: membersSelector.model.count === 1? Constants.chatType.oneToOne : Constants.chatType.privateGroupChat
|
|
|
|
emojiPopup: root.emojiPopup
|
2023-01-08 20:59:05 +00:00
|
|
|
stickersPopup: root.stickersPopup
|
2022-09-06 13:19:50 +00:00
|
|
|
closeGifPopupAfterSelection: true
|
2024-09-06 13:11:47 +00:00
|
|
|
usersModel: membersSelector.model
|
2024-10-02 20:47:14 +00:00
|
|
|
sharedStore: root.sharedRootStore
|
2022-09-06 13:19:50 +00:00
|
|
|
onStickerSelected: {
|
2023-05-04 18:36:35 +00:00
|
|
|
root.createChatPropertiesStore.createChatStickerHashId = hashId;
|
|
|
|
root.createChatPropertiesStore.createChatStickerPackId = packId;
|
|
|
|
root.createChatPropertiesStore.createChatStickerUrl = url;
|
2022-09-29 15:18:29 +00:00
|
|
|
membersSelector.createChat();
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
2022-11-15 14:17:58 +00:00
|
|
|
|
|
|
|
onSendMessage: { d.createChat() }
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2022-09-06 13:19:50 +00:00
|
|
|
anchors.centerIn: parent
|
2022-08-18 11:16:55 +00:00
|
|
|
width: Math.min(553, parent.width - 2 * Style.current.padding)
|
2022-09-06 13:19:50 +00:00
|
|
|
visible: root.rootStore.contactsModel.count === 0
|
2022-02-15 21:00:05 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|