2020-08-04 22:22:51 +00:00
|
|
|
|
import QtQuick 2.14
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
import "../../../../../imports"
|
|
|
|
|
import "../../../../../shared"
|
2020-11-16 13:15:39 +00:00
|
|
|
|
import "../../../../../shared/status"
|
2020-08-05 19:50:55 +00:00
|
|
|
|
import "../../../Chat/ChatColumn/MessageComponents"
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
2020-08-07 16:27:41 +00:00
|
|
|
|
signal addBtnClicked()
|
|
|
|
|
signal selectEns(string username)
|
2020-08-04 22:22:51 +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"
|
|
|
|
|
property var clickMessage: function(){}
|
|
|
|
|
property string identicon: profileModel.profile.identicon
|
|
|
|
|
property int timestamp: 1577872140
|
|
|
|
|
|
2020-09-11 17:23:57 +00:00
|
|
|
|
function shouldDisplayExampleMessage(){
|
|
|
|
|
return profileModel.ens.rowCount() > 0 && profileModel.ens.pendingLen() != profileModel.ens.rowCount() && profileModel.ens.preferredUsername !== ""
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 19:50:55 +00:00
|
|
|
|
Component {
|
|
|
|
|
id: statusENS
|
|
|
|
|
Item {
|
|
|
|
|
Text {
|
|
|
|
|
id: usernameTxt
|
2020-09-14 12:12:47 +00:00
|
|
|
|
//% "(pending)"
|
|
|
|
|
text: username.substr(0, username.indexOf(".")) + " " + (isPending ? qsTrId("-pending-") : "")
|
2020-08-05 19:50:55 +00:00
|
|
|
|
color: Style.current.textColor
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
|
|
|
|
|
anchors.top: usernameTxt.bottom
|
|
|
|
|
anchors.topMargin: 2
|
|
|
|
|
text: username.substr(username.indexOf("."))
|
|
|
|
|
color: Style.current.darkGrey
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: normalENS
|
|
|
|
|
Item {
|
|
|
|
|
Text {
|
|
|
|
|
id: usernameTxt
|
2020-09-14 12:12:47 +00:00
|
|
|
|
//% "(pending)"
|
|
|
|
|
text: username + " " + (isPending ? qsTrId("-pending-") : "")
|
2020-08-05 19:50:55 +00:00
|
|
|
|
font.pixelSize: 16
|
|
|
|
|
color: Style.current.textColor
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 5
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: ensDelegate
|
|
|
|
|
Item {
|
|
|
|
|
height: 45
|
2020-08-06 19:45:57 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2020-08-07 16:27:41 +00:00
|
|
|
|
onClicked: selectEns(model.username)
|
2020-08-06 19:45:57 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: circle
|
|
|
|
|
width: 35
|
|
|
|
|
height: 35
|
|
|
|
|
radius: 35
|
|
|
|
|
color: Style.current.blue
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
text: "@"
|
|
|
|
|
opacity: 0.7
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 16
|
|
|
|
|
color: Style.current.white
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-06 19:45:57 +00:00
|
|
|
|
Loader {
|
|
|
|
|
sourceComponent: model.username.endsWith(".stateofus.eth") ? statusENS : normalENS
|
|
|
|
|
property string username: model.username
|
2020-09-11 17:23:57 +00:00
|
|
|
|
property bool isPending: model.isPending
|
2020-08-06 19:45:57 +00:00
|
|
|
|
active: true
|
|
|
|
|
anchors.left: circle.right
|
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-06 18:19:26 +00:00
|
|
|
|
ENSPopup {
|
|
|
|
|
id: ensPopup
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-04 22:22:51 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: addUsername
|
|
|
|
|
anchors.top: sectionTitle.bottom
|
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
|
width: addButton.width + usernameText.width + Style.current.padding
|
|
|
|
|
height: addButton.height
|
|
|
|
|
|
2020-11-16 13:15:39 +00:00
|
|
|
|
StatusRoundButton {
|
2020-08-04 22:22:51 +00:00
|
|
|
|
id: addButton
|
2020-11-16 13:15:39 +00:00
|
|
|
|
icon.name: "plusSign"
|
|
|
|
|
size: "medium"
|
2021-03-16 19:19:48 +00:00
|
|
|
|
type: "secondary"
|
2020-08-04 22:22:51 +00:00
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: usernameText
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Add username"
|
|
|
|
|
text: qsTrId("ens-add-username")
|
2020-08-04 22:22:51 +00:00
|
|
|
|
color: Style.current.blue
|
|
|
|
|
anchors.left: addButton.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.verticalCenter: addButton.verticalCenter
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2020-08-07 16:27:41 +00:00
|
|
|
|
onClicked: addBtnClicked()
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: usernamesLabel
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Your usernames"
|
|
|
|
|
text: qsTrId("ens-your-usernames")
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.left: parent.left
|
2020-08-04 22:22:51 +00:00
|
|
|
|
anchors.top: addUsername.bottom
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.pixelSize: 16
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
anchors.top: usernamesLabel.bottom
|
|
|
|
|
anchors.topMargin: 10
|
2020-08-04 22:22:51 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2020-08-05 19:50:55 +00:00
|
|
|
|
height: 200
|
|
|
|
|
id: ensList
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
2020-08-05 19:50:55 +00:00
|
|
|
|
ScrollView {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
2020-08-04 22:22:51 +00:00
|
|
|
|
|
2020-08-05 19:50:55 +00:00
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
ScrollBar.vertical.policy: lvEns.contentHeight > lvEns.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
id: lvEns
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
model: profileModel.ens
|
|
|
|
|
spacing: 10
|
|
|
|
|
clip: true
|
|
|
|
|
delegate: ensDelegate
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
|
id: separator
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
|
anchors.top: ensList.bottom
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: chatSettingsLabel
|
2020-09-11 17:23:57 +00:00
|
|
|
|
visible: profileModel.ens.rowCount() > 0 && profileModel.ens.pendingLen() != profileModel.ens.rowCount()
|
2021-02-18 16:36:05 +00:00
|
|
|
|
//% "Chat settings"
|
2020-08-26 15:52:26 +00:00
|
|
|
|
text: qsTrId("chat-settings")
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: ensList.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
font.pixelSize: 16
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-06 18:19:26 +00:00
|
|
|
|
Item {
|
|
|
|
|
width: childrenRect.width
|
|
|
|
|
height: childrenRect.height
|
|
|
|
|
|
|
|
|
|
id: preferredUsername
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.top: chatSettingsLabel.bottom
|
|
|
|
|
anchors.topMargin: 24
|
|
|
|
|
|
2020-08-06 18:19:26 +00:00
|
|
|
|
StyledText {
|
|
|
|
|
id: usernameLabel
|
|
|
|
|
visible: chatSettingsLabel.visible
|
2020-08-26 15:52:26 +00:00
|
|
|
|
//% "Primary Username"
|
|
|
|
|
text: qsTrId("primary-username")
|
2020-08-06 18:19:26 +00:00
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
id: usernameLabel2
|
|
|
|
|
visible: chatSettingsLabel.visible
|
2020-09-14 12:12:47 +00:00
|
|
|
|
//% "None selected"
|
|
|
|
|
text: profileModel.ens.preferredUsername || qsTrId("none-selected")
|
2020-08-06 18:19:26 +00:00
|
|
|
|
anchors.left: usernameLabel.right
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: ensPopup.open()
|
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
2020-09-11 17:23:57 +00:00
|
|
|
|
id: messagesShownAs
|
|
|
|
|
visible: shouldDisplayExampleMessage()
|
|
|
|
|
anchors.top: !visible ? separator.bottom : preferredUsername.bottom
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.topMargin: Style.current.padding * 2
|
|
|
|
|
|
|
|
|
|
UserImage {
|
|
|
|
|
id: chatImage
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 20
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UsernameLabel {
|
|
|
|
|
id: chatName
|
2020-12-08 15:45:43 +00:00
|
|
|
|
label.text: "@" + (profileModel.ens.preferredUsername.replace(".stateofus.eth", ""))
|
|
|
|
|
label.color: Style.current.blue
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.leftMargin: 20
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 0
|
|
|
|
|
anchors.left: chatImage.right
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
ChatText {
|
|
|
|
|
id: chatText
|
2020-08-04 22:22:51 +00:00
|
|
|
|
anchors.top: parent.top
|
2020-08-05 19:50:55 +00:00
|
|
|
|
anchors.topMargin: chatBox.chatVerticalPadding
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: chatBox.chatHorizontalPadding
|
2020-11-19 19:44:24 +00:00
|
|
|
|
width: parent.width
|
2020-11-20 01:15:36 +00:00
|
|
|
|
anchors.right: parent.right
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
|
|
|
|
RectangleCorner {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChatTime {
|
|
|
|
|
id: chatTime
|
|
|
|
|
anchors.top: chatBox.bottom
|
|
|
|
|
anchors.topMargin: 4
|
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
|
anchors.right: chatBox.right
|
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
2020-09-11 17:23:57 +00:00
|
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
|
anchors.top: chatTime.bottom
|
|
|
|
|
anchors.left: chatImage.left
|
|
|
|
|
anchors.topMargin: Style.current.padding
|
2020-09-14 12:12:47 +00:00
|
|
|
|
//% "You’re displaying your ENS username in chats"
|
|
|
|
|
text: qsTrId("you-re-displaying-your-ens-username-in-chats")
|
2020-09-11 17:23:57 +00:00
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-08-04 22:22:51 +00:00
|
|
|
|
}
|
2020-08-05 19:50:55 +00:00
|
|
|
|
|
|
|
|
|
|
2020-09-11 17:23:57 +00:00
|
|
|
|
Connections {
|
|
|
|
|
target: profileModel.ens
|
|
|
|
|
onPreferredUsernameChanged: {
|
|
|
|
|
messagesShownAs.visible = shouldDisplayExampleMessage()
|
|
|
|
|
}
|
|
|
|
|
onUsernameConfirmed: {
|
|
|
|
|
messagesShownAs.visible = shouldDisplayExampleMessage()
|
|
|
|
|
chatSettingsLabel.visible = true
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-14 12:12:47 +00:00
|
|
|
|
}
|