fix: make profile popup look like the design

This commit is contained in:
Jonathan Rainville 2021-01-12 15:51:00 -05:00
parent 56f9b79834
commit 3f63ded1b2
6 changed files with 127 additions and 145 deletions

View File

@ -102,7 +102,7 @@ SplitView {
property Component profilePopupComponent: ProfilePopup { property Component profilePopupComponent: ProfilePopup {
id: profilePopup id: profilePopup
height: 450 height: 504
onClosed: { onClosed: {
if(profilePopup.parentPopup){ if(profilePopup.parentPopup){
profilePopup.parentPopup.close(); profilePopup.parentPopup.close();

View File

@ -17,12 +17,14 @@ ModalPopup {
width: 400 width: 400
height: 390 height: 390
noTopMargin: true
onOpened: { onOpened: {
nicknameInput.forceActiveFocus(Qt.MouseFocusReason) nicknameInput.forceActiveFocus(Qt.MouseFocusReason)
} }
header: Item { header: Item {
height: childrenRect.height height: 78
width: parent.width width: parent.width
StyledText { StyledText {
@ -30,11 +32,11 @@ ModalPopup {
//% "Nickname" //% "Nickname"
text: qsTrId("nickname") text: qsTrId("nickname")
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 18 anchors.topMargin: Style.current.padding
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding anchors.leftMargin: Style.current.padding
font.bold: true font.bold: true
font.pixelSize: 14 font.pixelSize: 17
} }
StyledText { StyledText {
@ -42,11 +44,19 @@ ModalPopup {
width: 160 width: 160
elide: !isEnsVerified ? Text.ElideMiddle : Text.ElideNone elide: !isEnsVerified ? Text.ElideMiddle : Text.ElideNone
anchors.left: nicknameTitle.left anchors.left: nicknameTitle.left
anchors.top: nicknameTitle.bottom anchors.bottom: parent.bottom
anchors.topMargin: 2 anchors.bottomMargin: Style.current.padding
font.pixelSize: 14 font.pixelSize: 15
color: Style.current.secondaryText color: Style.current.secondaryText
} }
Separator {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
}
} }
StyledText { StyledText {

View File

@ -19,6 +19,8 @@ ModalPopup {
property var text: "" property var text: ""
property var alias: "" property var alias: ""
readonly property int innerMargin: 20
property bool isEnsVerified: false property bool isEnsVerified: false
property bool noFooter: false property bool noFooter: false
property bool isBlocked: false property bool isBlocked: false
@ -32,6 +34,9 @@ ModalPopup {
signal contactAdded(publicKey: string) signal contactAdded(publicKey: string)
signal contactRemoved(publicKey: string) signal contactRemoved(publicKey: string)
clip: true
noTopMargin: true
function openPopup(showFooter, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) { function openPopup(showFooter, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
userName = userNameParam || "" userName = userNameParam || ""
nickname = nicknameParam || "" nickname = nicknameParam || ""
@ -47,15 +52,16 @@ ModalPopup {
} }
header: Item { header: Item {
height: children[0].height height: 78
width: parent.width width: parent.width
RoundedImage { RoundedImage {
id: profilePic id: profilePic
width: 40 width: 40
height: 40 height: 40
border.color: Style.current.border border.color: Style.current.border
border.width: 1 border.width: 1
anchors.top: parent.top anchors.verticalCenter: parent.verticalCenter
source: identicon source: identicon
} }
@ -63,40 +69,49 @@ ModalPopup {
id: profileName id: profileName
text: Utils.removeStatusEns(userName) text: Utils.removeStatusEns(userName)
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 2 anchors.topMargin: Style.current.padding
anchors.left: profilePic.right anchors.left: profilePic.right
anchors.leftMargin: Style.current.smallPadding anchors.leftMargin: Style.current.halfPadding
font.bold: true font.bold: true
font.pixelSize: 14 font.pixelSize: 17
readOnly: true readOnly: true
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
StyledText { StyledText {
text: isEnsVerified ? alias : fromAuthor text: isEnsVerified ? alias : fromAuthor
width: 160
elide: !isEnsVerified ? Text.ElideMiddle : Text.ElideNone elide: !isEnsVerified ? Text.ElideMiddle : Text.ElideNone
anchors.left: profilePic.right anchors.left: profilePic.right
anchors.leftMargin: Style.current.smallPadding anchors.leftMargin: Style.current.smallPadding
anchors.top: profileName.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.padding
anchors.right: qrCodeButton.left
anchors.rightMargin: Style.current.padding
anchors.topMargin: 2 anchors.topMargin: 2
font.pixelSize: 14 font.pixelSize: 14
color: Style.current.secondaryText color: Style.current.secondaryText
} }
StatusIconButton { StatusIconButton {
id: reloadBtn id: qrCodeButton
icon.name: "qr-code-icon" icon.name: "qr-code-icon"
anchors.top: parent.top anchors.verticalCenter: profileName.verticalCenter
anchors.topMargin: -4
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 32 + Style.current.smallPadding anchors.rightMargin: 52
iconColor: Style.current.textColor iconColor: Style.current.textColor
onClicked: qrCodePopup.open() onClicked: qrCodePopup.open()
width: 32 width: 32
height: 32 height: 32
} }
Separator {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
}
ModalPopup { ModalPopup {
id: qrCodePopup id: qrCodePopup
width: 320 width: 320
@ -114,80 +129,18 @@ ModalPopup {
} }
} }
Item {
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
profileModel.contacts.blockContact(fromAuthor)
blockContactConfirmationDialog.close();
popup.close()
contactBlocked(fromAuthor)
}
}
UnblockContactConfirmationDialog {
id: unblockContactConfirmationDialog
onUnblockButtonClicked: {
profileModel.unblockContact(fromAuthor)
unblockContactConfirmationDialog.close();
popup.close()
contactUnblocked(fromAuthor)
}
}
ConfirmationDialog {
id: removeContactConfirmationDialog
// % "Remove contact"
title: qsTrId("remove-contact")
//% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: {
if (profileModel.contacts.isAdded(fromAuthor)) {
profileModel.contacts.removeContact(fromAuthor);
}
removeContactConfirmationDialog.close();
popup.close();
contactRemoved(fromAuthor);
}
}
}
Item { Item {
anchors.fill: parent anchors.fill: parent
anchors.leftMargin: Style.current.smallPadding
StyledText { TextWithLabel {
id: labelEnsUsername id: ensText
height: isEnsVerified ? 20 : 0
visible: isEnsVerified
//% "ENS username" //% "ENS username"
text: qsTrId("ens-username") label: qsTrId("ens-username")
font.pixelSize: 13 text: userName
font.weight: Font.Medium
color: Style.current.secondaryText
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: Style.current.smallPadding
}
StyledText {
id: valueEnsName
visible: isEnsVerified visible: isEnsVerified
height: isEnsVerified ? 20 : 0 height: visible ? implicitHeight : 0
text: userName.substr(1) textToCopy: userName
font.pixelSize: 14
anchors.top: labelEnsUsername.bottom
anchors.topMargin: Style.current.smallPadding
}
CopyToClipBoardButton {
visible: isEnsVerified
height: isEnsVerified ? 20 : 0
anchors.top: labelEnsUsername.bottom
anchors.left: valueEnsName.right
textToCopy: valueEnsName.text
} }
StyledText { StyledText {
@ -197,8 +150,8 @@ ModalPopup {
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Medium font.weight: Font.Medium
color: Style.current.secondaryText color: Style.current.secondaryText
anchors.top: isEnsVerified ? valueEnsName.bottom : parent.top anchors.top: ensText.bottom
anchors.topMargin: Style.current.padding anchors.topMargin: ensText.visible ? popup.innerMargin : 0
} }
Address { Address {
@ -207,9 +160,9 @@ ModalPopup {
width: 160 width: 160
maxWidth: parent.width - (3 * Style.current.smallPadding) - copyBtn.width maxWidth: parent.width - (3 * Style.current.smallPadding) - copyBtn.width
color: Style.current.textColor color: Style.current.textColor
font.pixelSize: 14 font.pixelSize: 15
anchors.top: labelChatKey.bottom anchors.top: labelChatKey.bottom
anchors.topMargin: Style.current.smallPadding anchors.topMargin: 4
} }
CopyToClipBoardButton { CopyToClipBoardButton {
@ -222,67 +175,41 @@ ModalPopup {
Separator { Separator {
id: separator id: separator
anchors.top: valueChatKey.bottom anchors.top: valueChatKey.bottom
anchors.topMargin: Style.current.padding anchors.topMargin: popup.innerMargin
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: -Style.current.padding anchors.leftMargin: -Style.current.padding
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: -Style.current.padding anchors.rightMargin: -Style.current.padding
} }
StyledText { TextWithLabel {
id: labelShareURL
//% "Share Profile URL"
text: qsTrId("share-profile-url")
font.pixelSize: 13
font.weight: Font.Medium
color: Style.current.secondaryText
anchors.top: separator.bottom
anchors.topMargin: Style.current.padding
}
StyledText {
id: valueShareURL id: valueShareURL
label: qsTr("Share Profile URL")
text: "https://join.status.im/u/" + fromAuthor.substr( text: "https://join.status.im/u/" + fromAuthor.substr(
0, 4) + "..." + fromAuthor.substr(fromAuthor.length - 5) 0, 4) + "..." + fromAuthor.substr(fromAuthor.length - 5)
font.pixelSize: 14 anchors.top: separator.top
anchors.top: labelShareURL.bottom anchors.topMargin: popup.innerMargin
anchors.topMargin: Style.current.smallPadding
}
CopyToClipBoardButton {
anchors.top: labelShareURL.bottom
anchors.left: valueShareURL.right
textToCopy: "https://join.status.im/u/" + fromAuthor textToCopy: "https://join.status.im/u/" + fromAuthor
} }
Separator { Separator {
id: separator2 id: separator2
anchors.top: valueShareURL.bottom anchors.top: valueShareURL.bottom
anchors.topMargin: Style.current.padding anchors.topMargin: popup.innerMargin
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: -Style.current.padding anchors.leftMargin: -Style.current.padding
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: -Style.current.padding anchors.rightMargin: -Style.current.padding
} }
StyledText { TextWithLabel {
id: chatSettings id: chatSettings
//% "Chat settings" //% "Chat settings"
text: qsTrId("chat-settings") label: qsTrId("chat-settings")
font.pixelSize: 13
font.weight: Font.Medium
color: Style.current.secondaryText
anchors.top: separator2.bottom
anchors.topMargin: Style.current.padding
}
StyledText {
id: nicknameTitle
//% "Nickname" //% "Nickname"
text: qsTrId("nickname") text: qsTrId("nickname")
font.pixelSize: 14 anchors.top: separator2.top
anchors.top: chatSettings.bottom anchors.topMargin: popup.innerMargin
anchors.topMargin: Style.current.smallPadding
} }
SVGImage { SVGImage {
@ -291,7 +218,8 @@ ModalPopup {
rotation: -90 rotation: -90
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
anchors.verticalCenter: nicknameTitle.verticalCenter anchors.bottom: chatSettings.bottom
anchors.bottomMargin: 5
width: 13 width: 13
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
ColorOverlay { ColorOverlay {
@ -307,16 +235,16 @@ ModalPopup {
text: nickname ? nickname : qsTrId("none") text: nickname ? nickname : qsTrId("none")
anchors.right: nicknameCaret.left anchors.right: nicknameCaret.left
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
anchors.verticalCenter: nicknameTitle.verticalCenter anchors.verticalCenter: nicknameCaret.verticalCenter
color: Style.current.secondaryText color: Style.current.secondaryText
} }
MouseArea { MouseArea {
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.left: nicknameTitle.left anchors.left: chatSettings.left
anchors.right: nicknameCaret.right anchors.right: nicknameCaret.right
anchors.top: nicknameTitle.top anchors.top: chatSettings.top
anchors.bottom: nicknameTitle.bottom anchors.bottom: chatSettings.bottom
onClicked: { onClicked: {
nicknamePopup.open() nicknamePopup.open()
} }
@ -409,5 +337,43 @@ ModalPopup {
popup.close() popup.close()
} }
} }
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
profileModel.contacts.blockContact(fromAuthor)
blockContactConfirmationDialog.close();
popup.close()
contactBlocked(fromAuthor)
}
}
UnblockContactConfirmationDialog {
id: unblockContactConfirmationDialog
onUnblockButtonClicked: {
profileModel.unblockContact(fromAuthor)
unblockContactConfirmationDialog.close();
popup.close()
contactUnblocked(fromAuthor)
}
}
ConfirmationDialog {
id: removeContactConfirmationDialog
// % "Remove contact"
title: qsTrId("remove-contact")
//% "Are you sure you want to remove this contact?"
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
onConfirmButtonClicked: {
if (profileModel.contacts.isAdded(fromAuthor)) {
profileModel.contacts.removeContact(fromAuthor);
}
removeContactConfirmationDialog.close();
popup.close();
contactRemoved(fromAuthor);
}
}
} }
} }

View File

@ -10,7 +10,7 @@ StyledText {
text: "0x9ce0056c5fc6bb9459a4dcfa35eaad8c1fee5ce9" text: "0x9ce0056c5fc6bb9459a4dcfa35eaad8c1fee5ce9"
font.pixelSize: 13 font.pixelSize: 13
font.family: Style.current.fontHexRegular.name font.family: Style.current.fontHexRegular.name
elide: expanded ? Text.ElideNone : Text.ElideMiddle elide: Text.ElideMiddle
color: Style.current.secondaryText color: Style.current.secondaryText
MouseArea { MouseArea {
@ -23,8 +23,8 @@ StyledText {
this.width = addressComponent.width this.width = addressComponent.width
} else { } else {
addressComponent.oldWidth = addressComponent.width addressComponent.oldWidth = addressComponent.width
addressComponent.width = addressComponent.maxWidth > 0 && addressComponent.implicitWidth > addressComponent.maxWidth ? addressComponent.width = addressComponent.maxWidth > 0 ?
addressComponent.maxWidth : Math.min(addressComponent.implicitWidth, addressComponent.maxWidth) :
addressComponent.implicitWidth addressComponent.implicitWidth
this.width = addressComponent.width this.width = addressComponent.width
} }

View File

@ -6,6 +6,7 @@ import "../imports"
Popup { Popup {
property string title property string title
property bool noTopMargin: false
default property alias content: popupContent.children default property alias content: popupContent.children
property alias contentWrapper: popupContent property alias contentWrapper: popupContent
property alias header: headerContent.children property alias header: headerContent.children
@ -33,14 +34,18 @@ Popup {
Item { Item {
id: headerContent id: headerContent
height: { height: {
var idx = !!title ? 0 : 1 const count = children.length
return children[idx] && children[idx].height let h = 0
for (let i = 0; i < count; i++) {
h += children[i] ? children[i].height : 0
}
return h
} }
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: Style.current.padding anchors.topMargin: popup.noTopMargin ? 0 : Style.current.padding
anchors.bottomMargin: Style.current.padding anchors.bottomMargin: Style.current.padding
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
anchors.leftMargin: Style.current.padding anchors.leftMargin: Style.current.padding
@ -51,7 +56,7 @@ Popup {
anchors.left: parent.left anchors.left: parent.left
font.bold: true font.bold: true
font.pixelSize: 17 font.pixelSize: 17
height: 24 height: visible ? 24 : 0
visible: !!title visible: !!title
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
@ -62,10 +67,10 @@ Popup {
property bool hovered: false property bool hovered: false
height: 32 height: 32
width: 32 width: 32
anchors.top: headerContent.top anchors.top: parent.top
anchors.topMargin: -4 anchors.topMargin: 12
anchors.right: headerContent.right anchors.right: parent.right
anchors.rightMargin: -4 anchors.rightMargin: 12
radius: 8 radius: 8
color: hovered ? Style.current.backgroundHover : Style.current.transparent color: hovered ? Style.current.backgroundHover : Style.current.transparent
@ -103,6 +108,7 @@ Popup {
Separator { Separator {
id: separator id: separator
anchors.top: headerContent.bottom anchors.top: headerContent.bottom
anchors.topMargin: visible ? Style.current.padding : 0
visible: title.length > 0 visible: title.length > 0
} }

View File

@ -12,7 +12,7 @@ Item {
property bool wrap: false property bool wrap: false
id: infoText id: infoText
height: this.childrenRect.height implicitHeight: this.childrenRect.height
width: parent.width width: parent.width
StyledText { StyledText {
@ -30,7 +30,7 @@ Item {
font.family: fontFamily font.family: fontFamily
readOnly: true readOnly: true
anchors.top: inputLabel.bottom anchors.top: inputLabel.bottom
anchors.topMargin: 7 anchors.topMargin: 4
font.pixelSize: 15 font.pixelSize: 15
wrapMode: infoText.wrap ? Text.WordWrap : Text.NoWrap wrapMode: infoText.wrap ? Text.WordWrap : Text.NoWrap
anchors.left: parent.left anchors.left: parent.left