status-desktop/ui/app/AppLayouts/Chat/components/ProfilePopup.qml

292 lines
9.0 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../../../../imports"
import "../../../../shared"
import "./"
ModalPopup {
id: popup
2020-06-17 21:43:26 +00:00
property var identicon: ""
property var userName: ""
property var fromAuthor: ""
2020-06-23 17:17:58 +00:00
property bool showQR: false
property bool isEnsVerified: false
2020-06-17 21:43:26 +00:00
function openPopup(userNameParam, fromAuthorParam, identiconParam) {
2020-06-23 17:17:58 +00:00
this.showQR = false
2020-06-17 21:43:26 +00:00
this.userName = userNameParam
this.fromAuthor = fromAuthorParam
this.identicon = identiconParam
this.isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor)
2020-06-17 21:43:26 +00:00
popup.open()
}
header: Item {
2020-06-23 19:04:08 +00:00
height: children[0].height
width: parent.width
Rectangle {
id: profilePic
width: 40
height: 40
radius: 30
border.color: "#10000000"
border.width: 1
color: Style.current.transparent
2020-06-23 19:04:08 +00:00
anchors.top: parent.top
anchors.topMargin: Style.current.padding
SVGImage {
2020-06-23 19:04:08 +00:00
width: parent.width
height: parent.height
fillMode: Image.PreserveAspectFit
source: identicon
}
}
StyledTextEdit {
id: profileName
text: userName
anchors.top: parent.top
anchors.topMargin: 18
anchors.left: profilePic.right
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
font.bold: true
font.pixelSize: 14
readOnly: true
wrapMode: Text.WordWrap
}
2020-06-23 19:04:08 +00:00
StyledText {
text: fromAuthor
width: 160
elide: Text.ElideMiddle
anchors.left: profilePic.right
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
anchors.top: profileName.bottom
anchors.topMargin: 2
font.pixelSize: 14
color: Style.current.darkGrey
2020-06-23 19:04:08 +00:00
}
2020-06-23 19:04:08 +00:00
Rectangle {
id: qrCodeButton
height: 32
width: 32
anchors.top: parent.top
anchors.topMargin: Style.current.padding
2020-06-23 19:04:08 +00:00
anchors.right: parent.right
anchors.rightMargin: 32 + Style.current.smallPadding
2020-06-23 19:04:08 +00:00
radius: 8
2020-06-23 17:17:58 +00:00
SVGImage {
2020-06-23 19:04:08 +00:00
source: "../../../img/qr-code-icon.svg"
width: 25
height: 25
2020-06-23 19:04:08 +00:00
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
2020-06-23 17:17:58 +00:00
2020-06-23 19:04:08 +00:00
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onExited: {
qrCodeButton.color = Style.current.white
2020-06-23 19:04:08 +00:00
}
onEntered: {
qrCodeButton.color = Style.current.grey
2020-06-23 19:04:08 +00:00
}
onClicked: {
showQR = true
}
}
}
}
2020-06-23 17:17:58 +00:00
Item {
2020-06-23 19:04:08 +00:00
anchors.fill: parent
visible: showQR
Image {
asynchronous: true
fillMode: Image.PreserveAspectFit
2020-06-23 19:04:08 +00:00
source: profileModel.qrCode(fromAuthor)
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
height: 212
width: 212
mipmap: true
smooth: false
}
}
2020-06-23 17:17:58 +00:00
Item {
2020-06-23 19:04:08 +00:00
anchors.fill: parent
visible: !showQR
2020-06-23 19:04:08 +00:00
StyledText {
id: labelEnsUsername
height: isEnsVerified ? 20 : 0
visible: isEnsVerified
2020-06-23 19:04:08 +00:00
text: qsTr("ENS username")
font.pixelSize: 13
font.weight: Font.Medium
color: Style.current.darkGrey
2020-06-23 19:04:08 +00:00
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
anchors.top: parent.top
anchors.topMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
}
2020-06-23 19:04:08 +00:00
StyledText {
id: valueEnsName
visible: isEnsVerified
height: isEnsVerified ? 20 : 0
text: userName
2020-06-23 19:04:08 +00:00
font.pixelSize: 14
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
anchors.top: labelEnsUsername.bottom
anchors.topMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
}
CopyToClipBoardIcon {
visible: isEnsVerified
height: isEnsVerified ? 20 : 0
anchors.top: labelEnsUsername.bottom
anchors.left: valueEnsName.right
anchors.leftMargin: Style.current.smallPadding
onClick: function (){
chatsModel.copyToClipboard(valueEnsName.text)
}
}
2020-06-23 19:04:08 +00:00
StyledText {
id: labelChatKey
text: qsTr("Chat key")
font.pixelSize: 13
font.weight: Font.Medium
color: Style.current.darkGrey
2020-06-23 19:04:08 +00:00
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.top: isEnsVerified ? valueEnsName.bottom : parent.top
anchors.topMargin: Style.current.padding
2020-06-23 19:04:08 +00:00
}
2020-06-23 19:04:08 +00:00
StyledText {
id: valueChatKey
text: fromAuthor
width: 160
elide: Text.ElideMiddle
font.pixelSize: 14
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
anchors.top: labelChatKey.bottom
anchors.topMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
}
2020-06-23 17:17:58 +00:00
CopyToClipBoardIcon {
anchors.top: labelChatKey.bottom
anchors.left: valueChatKey.right
anchors.leftMargin: Style.current.smallPadding
onClick: function (){
chatsModel.copyToClipboard(valueChatKey.text)
}
}
2020-06-23 19:04:08 +00:00
Separator {
id: separator
anchors.top: valueChatKey.bottom
anchors.topMargin: Style.current.padding
2020-06-23 19:04:08 +00:00
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
2020-06-23 19:04:08 +00:00
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
2020-06-23 19:04:08 +00:00
}
2020-06-23 19:04:08 +00:00
StyledText {
id: labelShareURL
text: qsTr("Share Profile URL")
font.pixelSize: 13
font.weight: Font.Medium
color: Style.current.darkGrey
2020-06-23 19:04:08 +00:00
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
anchors.top: separator.bottom
anchors.topMargin: Style.current.padding
2020-06-23 19:04:08 +00:00
}
2020-06-23 17:17:58 +00:00
2020-06-23 19:04:08 +00:00
StyledText {
id: valueShareURL
text: "https://join.status.im/u/" + fromAuthor.substr(
0, 4) + "..." + fromAuthor.substr(fromAuthor.length - 5)
font.pixelSize: 14
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
anchors.top: labelShareURL.bottom
anchors.topMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
}
CopyToClipBoardIcon {
anchors.top: labelShareURL.bottom
anchors.left: valueShareURL.right
anchors.leftMargin: Style.current.smallPadding
onClick: function (){
chatsModel.copyToClipboard("https://join.status.im/u/" + fromAuthor)
}
}
}
footer: Item {
width: parent.width
height: children[0].height
StyledButton {
2020-06-23 19:04:08 +00:00
anchors.left: parent.left
anchors.leftMargin: 20
label: qsTr("Send Message")
anchors.bottom: parent.bottom
onClicked: {
profilePopup.close()
if (tabBar.currentIndex !== 0)
tabBar.currentIndex = 0
chatsModel.joinChat(fromAuthor, Constants.chatTypeOneToOne)
}
}
StyledButton {
2020-06-23 19:04:08 +00:00
anchors.right: parent.right
anchors.rightMargin: addToContactsButton.width + 32
btnColor: "white"
btnBorderWidth: 1
btnBorderColor: Style.current.grey
textColor: Style.current.red
2020-06-23 19:04:08 +00:00
label: qsTr("Block User")
anchors.bottom: parent.bottom
onClicked: {
chatsModel.blockContact(fromAuthor)
// TODO(pascal): Change block user button state based
// on :contact/blocked state
profilePopup.close()
}
}
StyledButton {
2020-06-23 19:04:08 +00:00
id: addToContactsButton
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
2020-06-23 19:04:08 +00:00
label: profileModel.isAdded(
fromAuthor) ? qsTr("Remove Contact") : qsTr(
"Add to contacts")
anchors.bottom: parent.bottom
onClicked: {
if (profileModel.isAdded(fromAuthor)) {
chatsModel.removeContact(fromAuthor)
} else {
chatsModel.addContact(fromAuthor)
}
profilePopup.close()
}
2020-06-23 19:04:08 +00:00
}
}
}