2020-08-04 22:22:51 +00:00
|
|
|
|
import QtQuick 2.14
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQuick.Controls 2.14
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
|
import StatusQ.Controls 0.1
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
|
|
|
|
import "../popups"
|
2021-10-27 21:27:49 +00:00
|
|
|
|
import shared 1.0
|
|
|
|
|
import shared.panels 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
import shared.panels.chat 1.0
|
|
|
|
|
import shared.controls.chat 1.0
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
2021-10-06 09:16:39 +00:00
|
|
|
|
id: root
|
2020-08-07 16:27:41 +00:00
|
|
|
|
signal addBtnClicked()
|
|
|
|
|
signal selectEns(string username)
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
property var store
|
2021-12-09 13:28:02 +00:00
|
|
|
|
property int profileContentWidth
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|
2020-08-05 19:50:55 +00:00
|
|
|
|
// Defaults to show message
|
|
|
|
|
property bool isMessage: true
|
|
|
|
|
property bool isEmoji: false
|
|
|
|
|
property bool isCurrentUser: false
|
|
|
|
|
property int contentType: 1
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Hey"
|
|
|
|
|
property string message: qsTrId("ens-test-message")
|
2020-08-05 19:50:55 +00:00
|
|
|
|
property string authorCurrentMsg: "0"
|
|
|
|
|
property string authorPrevMsg: "1"
|
2021-07-26 19:08:27 +00:00
|
|
|
|
property bool isText: true
|
2020-08-05 19:50:55 +00:00
|
|
|
|
property var clickMessage: function(){}
|
2021-10-06 09:16:39 +00:00
|
|
|
|
property string identicon: store.identicon
|
2021-12-01 12:46:21 +00:00
|
|
|
|
//property string identicon: userProfile.icon
|
2020-08-05 19:50:55 +00:00
|
|
|
|
property int timestamp: 1577872140
|
2021-10-01 15:58:36 +00:00
|
|
|
|
property var messageStore
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2020-09-11 17:23:57 +00:00
|
|
|
|
function shouldDisplayExampleMessage(){
|
2021-10-06 09:16:39 +00:00
|
|
|
|
return store.ens.rowCount() > 0 && store.ensPendingLen() !== store.ens.rowCount() && store.preferredUsername !== ""
|
2020-09-11 17:23:57 +00:00
|
|
|
|
}
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.fill: parent
|
2020-09-11 17:23:57 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
anchors.top: parent.top
|
2021-12-09 13:28:02 +00:00
|
|
|
|
width: profileContentWidth
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: statusENS
|
|
|
|
|
Item {
|
|
|
|
|
Text {
|
|
|
|
|
id: usernameTxt
|
|
|
|
|
//% "(pending)"
|
|
|
|
|
text: username.substr(0, username.indexOf(".")) + " " + (isPending ? qsTrId("-pending-") : "")
|
|
|
|
|
color: Style.current.textColor
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Text {
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: usernameTxt.bottom
|
|
|
|
|
anchors.topMargin: 2
|
|
|
|
|
text: username.substr(username.indexOf("."))
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.baseColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: normalENS
|
|
|
|
|
Item {
|
|
|
|
|
Text {
|
|
|
|
|
id: usernameTxt
|
|
|
|
|
//% "(pending)"
|
|
|
|
|
text: username + " " + (isPending ? qsTrId("-pending-") : "")
|
|
|
|
|
font.pixelSize: 16
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 5
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: ensDelegate
|
|
|
|
|
Item {
|
|
|
|
|
height: 45
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2020-08-06 19:45:57 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: selectEns(model.username)
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
id: circle
|
|
|
|
|
width: 35
|
|
|
|
|
height: 35
|
|
|
|
|
radius: 35
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.primaryColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
text: "@"
|
|
|
|
|
opacity: 0.7
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 16
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.indirectColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Loader {
|
|
|
|
|
sourceComponent: model.username.endsWith(".stateofus.eth") ? statusENS : normalENS
|
|
|
|
|
property string username: model.username
|
|
|
|
|
property bool isPending: model.isPending
|
|
|
|
|
active: true
|
|
|
|
|
anchors.left: circle.right
|
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
ENSPopup {
|
|
|
|
|
id: ensPopup
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: sectionTitle
|
|
|
|
|
//% "ENS usernames"
|
|
|
|
|
text: qsTrId("ens-usernames")
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: 24
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 20
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: addUsername
|
|
|
|
|
anchors.top: sectionTitle.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
width: addButton.width + usernameText.width + Style.current.padding
|
|
|
|
|
height: addButton.height
|
|
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
|
id: addButton
|
2021-10-25 19:37:44 +00:00
|
|
|
|
width: 40
|
|
|
|
|
height: 40
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-10-25 19:37:44 +00:00
|
|
|
|
icon.name: "add"
|
|
|
|
|
type: StatusRoundButton.Type.Secondary
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernameText
|
|
|
|
|
//% "Add username"
|
|
|
|
|
text: qsTrId("ens-add-username")
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.primaryColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: addButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: addButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
MouseArea {
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.fill: parent
|
2021-04-08 15:44:58 +00:00
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: addBtnClicked()
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernamesLabel
|
|
|
|
|
//% "Your usernames"
|
|
|
|
|
text: qsTrId("ens-your-usernames")
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: addUsername.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.pixelSize: 16
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-06 18:19:26 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
anchors.top: usernamesLabel.bottom
|
|
|
|
|
anchors.topMargin: 10
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
height: 200
|
|
|
|
|
id: ensList
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
ScrollView {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
ScrollBar.vertical.policy: lvEns.contentHeight > lvEns.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
id: lvEns
|
|
|
|
|
anchors.fill: parent
|
2021-10-06 09:16:39 +00:00
|
|
|
|
model: root.store.ens
|
2021-04-08 15:44:58 +00:00
|
|
|
|
spacing: 10
|
|
|
|
|
clip: true
|
|
|
|
|
delegate: ensDelegate
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Separator {
|
|
|
|
|
id: separator
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.top: ensList.bottom
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: chatSettingsLabel
|
2021-10-06 09:16:39 +00:00
|
|
|
|
visible: root.store.ens.rowCount() > 0 && root.store.ensPendingLen() != root.store.ens.rowCount()
|
2021-04-08 15:44:58 +00:00
|
|
|
|
//% "Chat settings"
|
|
|
|
|
text: qsTrId("chat-settings")
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: ensList.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.pixelSize: 16
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2020-08-06 18:19:26 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
width: childrenRect.width
|
|
|
|
|
height: childrenRect.height
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: preferredUsername
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.left: parent.left
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: chatSettingsLabel.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernameLabel
|
|
|
|
|
visible: chatSettingsLabel.visible
|
|
|
|
|
//% "Primary Username"
|
|
|
|
|
text: qsTrId("primary-username")
|
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
font.weight: Font.Bold
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: usernameLabel2
|
|
|
|
|
visible: chatSettingsLabel.visible
|
|
|
|
|
//% "None selected"
|
2021-10-06 09:16:39 +00:00
|
|
|
|
text: root.store.preferredUsername || qsTrId("none-selected")
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.left: usernameLabel.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
font.pixelSize: 14
|
2021-11-01 09:42:00 +00:00
|
|
|
|
color: Theme.palette.directColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: ensPopup.open()
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Item {
|
|
|
|
|
id: messagesShownAs
|
|
|
|
|
visible: shouldDisplayExampleMessage()
|
|
|
|
|
anchors.top: !visible ? separator.bottom : preferredUsername.bottom
|
|
|
|
|
anchors.topMargin: Style.current.padding * 2
|
|
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
|
id: chatImage
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.left: parent.left
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 20
|
2021-10-01 15:58:36 +00:00
|
|
|
|
// isCurrentUser: root.isCurrentUser
|
|
|
|
|
// profileImage: root.messageStore.profileImageSource
|
|
|
|
|
// isMessage: root.messageStore.isMessage
|
|
|
|
|
// identiconImageSource: root.messageStore.identicon
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
root.parent.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, isReply);
|
|
|
|
|
}
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
UsernameLabel {
|
|
|
|
|
id: chatName
|
2021-10-06 09:16:39 +00:00
|
|
|
|
label.text: "@" + (root.store.preferredUsername.replace(".stateofus.eth", ""))
|
2021-04-08 15:44:58 +00:00
|
|
|
|
label.color: Style.current.blue
|
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 0
|
|
|
|
|
anchors.left: chatImage.right
|
2021-10-01 15:58:36 +00:00
|
|
|
|
// isCurrentUser: root.messageStore.isCurrentUser
|
|
|
|
|
// userName: root.messageStore.userName
|
|
|
|
|
// localName: root.messageStore.localName
|
|
|
|
|
// displayUserName: root.messageStore.displayUserName
|
|
|
|
|
onClickMessage: {
|
|
|
|
|
root.parent.clickMessage(true, false, false, null, false, false, false);
|
|
|
|
|
}
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
property int chatVerticalPadding: 7
|
|
|
|
|
property int chatHorizontalPadding: 12
|
|
|
|
|
id: chatBox
|
|
|
|
|
color: Style.current.secondaryBackground
|
|
|
|
|
height: 35
|
|
|
|
|
width: 80
|
|
|
|
|
radius: 16
|
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
|
anchors.leftMargin: 8
|
|
|
|
|
anchors.top: chatImage.top
|
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
|
ChatTextView {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: chatText
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: chatBox.chatVerticalPadding
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: chatBox.chatHorizontalPadding
|
|
|
|
|
width: parent.width
|
|
|
|
|
anchors.right: parent.right
|
2021-10-21 22:39:53 +00:00
|
|
|
|
store: root.store
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
|
2021-04-08 15:44:58 +00:00
|
|
|
|
RectangleCorner {}
|
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
|
2021-10-21 22:39:53 +00:00
|
|
|
|
ChatTimePanel {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
id: chatTime
|
|
|
|
|
anchors.top: chatBox.bottom
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
|
anchors.right: chatBox.right
|
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2021-10-21 00:41:54 +00:00
|
|
|
|
//timestamp: root.timestamp
|
2021-10-21 22:39:53 +00:00
|
|
|
|
visible: root.messageStore.isMessage
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-06 09:16:39 +00:00
|
|
|
|
StatusBaseText {
|
2021-04-08 15:44:58 +00:00
|
|
|
|
anchors.top: chatTime.bottom
|
|
|
|
|
anchors.left: chatImage.left
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
//% "You’re displaying your ENS username in chats"
|
|
|
|
|
text: qsTrId("you-re-displaying-your-ens-username-in-chats")
|
|
|
|
|
font.pixelSize: 14
|
2021-10-06 09:16:39 +00:00
|
|
|
|
color: Theme.palette.baseColor1
|
2021-04-08 15:44:58 +00:00
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
}
|
2021-04-08 15:44:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Connections {
|
2021-10-06 09:16:39 +00:00
|
|
|
|
target: root.store.ens
|
2021-04-08 15:44:58 +00:00
|
|
|
|
onPreferredUsernameChanged: {
|
|
|
|
|
messagesShownAs.visible = shouldDisplayExampleMessage()
|
|
|
|
|
}
|
|
|
|
|
onUsernameConfirmed: {
|
|
|
|
|
messagesShownAs.visible = shouldDisplayExampleMessage()
|
|
|
|
|
chatSettingsLabel.visible = true
|
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-14 12:12:47 +00:00
|
|
|
|
}
|
2021-10-06 09:16:39 +00:00
|
|
|
|
|