2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml.Models 2.15
|
2022-02-15 21:00:05 +00:00
|
|
|
|
|
|
|
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 {
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.halfPadding
|
|
|
|
Layout.rightMargin: Theme.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 {
|
2024-10-22 14:14:43 +00:00
|
|
|
var groupName = []
|
|
|
|
var pubKeys = []
|
2022-09-06 13:19:50 +00:00
|
|
|
for (var i = 0; i < model.count; i++) {
|
|
|
|
const member = model.get(i)
|
2024-10-22 14:14:43 +00:00
|
|
|
groupName.push(member.displayName)
|
2022-09-06 13:19:50 +00:00
|
|
|
pubKeys.push(member.pubKey)
|
|
|
|
}
|
2024-10-22 14:14:43 +00:00
|
|
|
root.rootStore.chatCommunitySectionModule.createGroupChat("", groupName.join("&"), JSON.stringify(pubKeys))
|
2022-09-06 13:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
topMargin: Theme.bigPadding
|
|
|
|
bottomMargin: Theme.padding
|
|
|
|
leftMargin: Theme.halfPadding
|
2022-03-22 08:29:58 +00:00
|
|
|
}
|
|
|
|
|
2022-09-06 13:19:50 +00:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.halfPadding
|
2022-09-06 13:19:50 +00:00
|
|
|
visible: contactsList.visible
|
|
|
|
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
|
2024-10-15 19:26:12 +00:00
|
|
|
width: Math.min(553, parent.width - 2 * Theme.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
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|