status-desktop/ui/app/AppLayouts/Profile/views/MyProfileView.qml

198 lines
5.9 KiB
QML
Raw Normal View History

import QtQuick 2.13
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13
import utils 1.0
import shared 1.0
import shared.panels 1.0
import shared.popups 1.0
import "../popups"
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
Item {
id: root
property var store
property string ensName: store.preferredUsername || store.firstEnsUsername || ""
property string username: store.username
property string pubkey: store.pubKey
clip: true
2021-04-07 16:28:49 +00:00
height: parent.height
Layout.fillWidth: true
2020-11-30 17:03:52 +00:00
Component {
id: changeProfileModalComponent
ChangeProfilePicModal {
largeImage: store.profileLargeImage
hasIdentityImage: store.profileHasIdentityImage
onCropFinished: {
uploadError = store.uploadImage(selectedImage, aX, aY, bX, bY)
}
onRemoveImageButtonClicked: {
uploadError = store.removeImage()
}
}
2020-11-30 17:03:52 +00:00
}
Item {
id: profileImgNameContainer
anchors.top: parent.top
anchors.topMargin: 64
width: profileContainer.profileContentWidth
anchors.horizontalCenter: parent.horizontalCenter
height: this.childrenRect.height
2020-11-30 17:03:52 +00:00
Item {
id: profileImgContainer
width: profileImg.width
height: profileImg.height
2020-11-30 17:03:52 +00:00
RoundedImage {
id: profileImg
width: 64
height: 64
border.width: 1
border.color: Style.current.border
source: root.store.profileThumbnailImage
smooth: false
antialiasing: true
}
2020-11-30 17:03:52 +00:00
RoundedIcon {
source: Style.svg("pencil")
2020-11-30 17:03:52 +00:00
anchors.bottom: parent.bottom
anchors.bottomMargin: -3
anchors.right: parent.right
anchors.rightMargin: -3
width: 24
height: 24
border.width: 1
border.color: Style.current.background
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
const popup = changeProfileModalComponent.createObject(root);
2020-11-30 17:03:52 +00:00
popup.open()
}
}
}
StatusBaseText {
id: profileName
text: root.ensName !== "" ? root.ensName : root.username
2020-11-30 17:03:52 +00:00
anchors.left: profileImgContainer.right
2020-12-29 18:18:50 +00:00
anchors.leftMargin: Style.current.halfPadding
2020-11-30 17:03:52 +00:00
anchors.top: profileImgContainer.top
2020-12-29 18:18:50 +00:00
anchors.topMargin: 4
font.weight: Font.Bold
font.pixelSize: 20
color: Theme.palette.directColor1
}
Address {
id: pubkeyText
text: root.ensName !== "" ? root.username : root.pubkey
2020-11-30 17:03:52 +00:00
anchors.bottom: profileImgContainer.bottom
anchors.left: profileName.left
anchors.bottomMargin: 4
2020-08-06 18:19:26 +00:00
width: 200
font.pixelSize: 15
}
StatusFlatRoundButton {
id: qrCodeButton
width: 32
height: 32
anchors.right: parent.right
2020-12-29 18:18:50 +00:00
anchors.verticalCenter: profileImgContainer.verticalCenter
icon.name: "qr"
type: StatusFlatRoundButton.Type.Quaternary
onClicked: qrCodePopup.open()
}
Separator {
id: lineSeparator
2020-11-30 17:03:52 +00:00
anchors.top: profileImgContainer.bottom
anchors.topMargin: 36
}
}
ModalPopup {
id: qrCodePopup
width: 420
height: 420
2020-08-19 21:01:22 +00:00
Image {
asynchronous: true
fillMode: Image.PreserveAspectFit
source: root.store.getQrCodeSource(pubkey)
2020-12-29 18:18:50 +00:00
anchors.verticalCenterOffset: 20
2020-08-19 21:01:22 +00:00
anchors.horizontalCenter: parent.horizontalCenter
2020-12-29 18:18:50 +00:00
anchors.verticalCenter: parent.verticalCenter
height: 312
width: 312
2020-08-19 21:01:22 +00:00
mipmap: true
smooth: false
}
}
Column {
anchors.right: profileImgNameContainer.right
anchors.left: profileImgNameContainer.left
anchors.top: profileImgNameContainer.bottom
anchors.topMargin: 16
StatusDescriptionListItem {
title: qsTr("ENS username")
subTitle: root.ensName
tooltip.text: qsTr("Copy to clipboard")
icon.name: "copy"
visible: !!root.ensName
iconButton.onClicked: {
root.store.copyToClipboard(root.ensName)
tooltip.visible = !tooltip.visible
}
width: parent.width
}
StatusDescriptionListItem {
title: qsTr("Chat key")
subTitle: root.pubkey
subTitleComponent.elide: Text.ElideMiddle
subTitleComponent.width: 320
subTitleComponent.font.family: Theme.palette.monoFont.name
tooltip.text: qsTr("Copy to clipboard")
icon.name: "copy"
iconButton.onClicked: {
root.store.copyToClipboard(root.pubkey)
tooltip.visible = !tooltip.visible
}
width: parent.width
}
StatusDescriptionListItem {
title: qsTr("Share Profile URL")
subTitle: `${Constants.userLinkPrefix}${root.ensName !== "" ? root.ensName : (root.pubkey.substring(0, 5) + "..." + root.pubkey.substring(root.pubkey.length - 5))}`
tooltip.text: qsTr("Copy to clipboard")
icon.name: "copy"
iconButton.onClicked: {
root.store.copyToClipboard(Constants.userLinkPrefix + (root.ensName !== "" ? root.ensName : root.pubkey))
tooltip.visible = !tooltip.visible
}
width: parent.width
}
}
}