2022-06-20 11:54:17 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import utils 1.0
|
2022-06-22 12:16:21 +00:00
|
|
|
import shared.controls.chat 1.0
|
2022-06-20 11:54:17 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
StatusModal {
|
|
|
|
id: root
|
|
|
|
|
2023-04-06 07:56:50 +00:00
|
|
|
property var rootStore
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
property string userPublicKey: ""
|
|
|
|
property string userDisplayName: ""
|
|
|
|
property string userIcon: ""
|
2022-09-22 22:18:15 +00:00
|
|
|
property bool userIsEnsVerified
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-09-27 21:26:26 +00:00
|
|
|
property string challengeText: qsTr("Say who you are / why you want to become a contact...")
|
|
|
|
property string buttonText: qsTr("Send Contact Request")
|
|
|
|
|
2022-06-20 11:54:17 +00:00
|
|
|
signal accepted(string message)
|
|
|
|
|
2022-09-28 14:24:12 +00:00
|
|
|
width: 480
|
|
|
|
height: 548
|
|
|
|
|
2023-05-23 12:46:16 +00:00
|
|
|
headerSettings.title: d.loadingContactDetails ? qsTr("Send Contact Request")
|
2023-04-06 07:56:50 +00:00
|
|
|
: qsTr("Send Contact Request to %1").arg(d.userDisplayName)
|
|
|
|
|
|
|
|
onAboutToShow: {
|
|
|
|
messageInput.input.edit.forceActiveFocus()
|
|
|
|
|
|
|
|
const contactDetails = Utils.getContactDetailsAsJson(userPublicKey, false)
|
|
|
|
|
|
|
|
if (contactDetails.displayName !== "") {
|
|
|
|
d.updateContactDetails(contactDetails)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
root.rootStore.contactStore.requestContactInfo(root.userPublicKey)
|
|
|
|
d.loadingContactDetails = true
|
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int maxMsgLength: 280
|
|
|
|
readonly property int minMsgLength: 1
|
|
|
|
readonly property int msgHeight: 152
|
2022-09-28 14:24:12 +00:00
|
|
|
readonly property int contentSpacing: Style.current.halfPadding
|
2023-04-06 07:56:50 +00:00
|
|
|
|
|
|
|
property bool loadingContactDetails: false
|
|
|
|
|
|
|
|
property string userDisplayName: ""
|
|
|
|
property string userIcon: ""
|
|
|
|
property bool userIsEnsVerified
|
|
|
|
|
|
|
|
function updateContactDetails(contactDetails) {
|
|
|
|
d.userDisplayName = contactDetails.displayName
|
|
|
|
d.userIcon = contactDetails.largeImage
|
|
|
|
d.userIsEnsVerified = contactDetails.ensVerified
|
|
|
|
}
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
|
|
|
|
2023-04-06 07:56:50 +00:00
|
|
|
Connections {
|
|
|
|
target: root.rootStore.contactStore.contactsModule
|
|
|
|
|
|
|
|
function onContactInfoRequestFinished(publicKey, ok) {
|
|
|
|
if (ok) {
|
|
|
|
const details = Utils.getContactDetailsAsJson(userPublicKey, false)
|
|
|
|
d.updateContactDetails(details)
|
|
|
|
}
|
|
|
|
d.loadingContactDetails = false
|
|
|
|
}
|
2022-09-27 21:26:26 +00:00
|
|
|
}
|
|
|
|
|
2022-06-20 14:48:38 +00:00
|
|
|
ColumnLayout {
|
2022-06-20 11:54:17 +00:00
|
|
|
id: content
|
2022-06-22 12:16:21 +00:00
|
|
|
anchors.fill: parent
|
2022-09-28 14:24:12 +00:00
|
|
|
anchors.topMargin: Style.current.bigPadding
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.rightMargin: Style.current.padding
|
2022-06-20 11:54:17 +00:00
|
|
|
spacing: d.contentSpacing
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
ProfileHeader {
|
2022-06-20 11:54:17 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2023-04-06 07:56:50 +00:00
|
|
|
displayName: d.userDisplayName
|
2022-06-22 12:16:21 +00:00
|
|
|
pubkey: root.userPublicKey
|
2023-04-06 07:56:50 +00:00
|
|
|
icon: d.userIcon
|
|
|
|
userIsEnsVerified: d.userIsEnsVerified
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-09-18 13:01:13 +00:00
|
|
|
displayNameVisible: true
|
|
|
|
pubkeyVisible: true
|
2022-06-22 12:16:21 +00:00
|
|
|
imageSize: ProfileHeader.ImageSize.Middle
|
2023-04-06 07:56:50 +00:00
|
|
|
loading: d.loadingContactDetails
|
2022-06-20 11:54:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusInput {
|
|
|
|
id: messageInput
|
2022-12-26 21:53:47 +00:00
|
|
|
input.edit.objectName: "ProfileSendContactRequestModal_sayWhoYouAreInput"
|
2022-09-28 14:24:12 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-20 11:54:17 +00:00
|
|
|
charLimit: d.maxMsgLength
|
2022-09-27 21:26:26 +00:00
|
|
|
placeholderText: root.challengeText
|
2022-06-20 11:54:17 +00:00
|
|
|
input.multiline: true
|
2022-07-26 09:49:28 +00:00
|
|
|
minimumHeight: d.msgHeight
|
|
|
|
maximumHeight: d.msgHeight
|
2022-06-20 11:54:17 +00:00
|
|
|
input.verticalAlignment: TextEdit.AlignTop
|
|
|
|
validators: StatusMinLengthValidator {
|
|
|
|
minLength: d.minMsgLength
|
|
|
|
errorMessage: Utils.getErrorMessage(messageInput.errors, qsTr("who are you"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rightButtons: StatusButton {
|
2022-12-26 21:53:47 +00:00
|
|
|
objectName: "ProfileSendContactRequestModal_sendContactRequestButton"
|
2022-06-20 11:54:17 +00:00
|
|
|
enabled: messageInput.valid
|
2022-09-27 21:26:26 +00:00
|
|
|
text: root.buttonText
|
2022-06-20 11:54:17 +00:00
|
|
|
onClicked: {
|
2022-12-27 10:16:16 +00:00
|
|
|
root.accepted(messageInput.text);
|
2022-06-20 11:54:17 +00:00
|
|
|
root.close();
|
|
|
|
}
|
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|