From 6705e3f8c7bf86a65e67d48362a78d507edd9f09 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 11 Jan 2021 15:59:05 -0500 Subject: [PATCH] fix: fix profile popup buttons to fit the design --- .../Chat/components/ProfilePopup.qml | 79 +++++++++++-------- ui/shared/status/StatusButton.qml | 6 +- 2 files changed, 48 insertions(+), 37 deletions(-) diff --git a/ui/app/AppLayouts/Chat/components/ProfilePopup.qml b/ui/app/AppLayouts/Chat/components/ProfilePopup.qml index a46f7f9392..40cb8e6ded 100644 --- a/ui/app/AppLayouts/Chat/components/ProfilePopup.qml +++ b/ui/app/AppLayouts/Chat/components/ProfilePopup.qml @@ -4,6 +4,7 @@ import QtQuick.Layouts 1.13 import QtGraphicalEffects 1.13 import "../../../../imports" import "../../../../shared" +import "../../../../shared/status" import "./" ModalPopup { @@ -11,7 +12,6 @@ ModalPopup { property Popup parentPopup - property var identicon: "" property var userName: "" property string nickname: "" @@ -360,32 +360,18 @@ ModalPopup { width: parent.width height: children[0].height - StyledButton { - anchors.left: parent.left - anchors.leftMargin: 20 - //% "Send Message" - label: qsTrId("send-message") - anchors.bottom: parent.bottom - visible: !isBlocked - onClicked: { - if (tabBar.currentIndex !== 0) - tabBar.currentIndex = 0 - chatsModel.joinChat(fromAuthor, Constants.chatTypeOneToOne) - popup.close() - } - } - - StyledButton { - anchors.right: parent.right - anchors.rightMargin: isBlocked ? 0 : addToContactsButton.width + 32 - btnColor: Style.current.lightRed - btnBorderWidth: 1 - btnBorderColor: Style.current.grey - textColor: Style.current.red - label: isBlocked ? - qsTr("Unblock User") : - qsTr("Block User") + StatusButton { + id: blockBtn + anchors.right: addToContactsButton.left + anchors.rightMargin: addToContactsButton ? Style.current.padding : 0 anchors.bottom: parent.bottom + type: "secondary" + color: Style.current.red + showBorder: true + borderColor: Style.current.border + text: isBlocked ? + qsTr("Unblock User") : + qsTr("Block User") onClicked: { if (isBlocked) { unblockContactConfirmationDialog.contactName = userName; @@ -395,21 +381,28 @@ ModalPopup { } blockContactConfirmationDialog.contactName = userName; blockContactConfirmationDialog.contactAddress = fromAuthor; - blockContactConfirmationDialog.open(); + blockContactConfirmationDialog.open(); } } - StyledButton { + StatusButton { + property bool isAdded: profileModel.contacts.isAdded(fromAuthor) + id: addToContactsButton - anchors.right: parent.right - anchors.rightMargin: Style.current.smallPadding - label: profileModel.contacts.isAdded(fromAuthor) ? - //% "Remove Contact" - qsTrId("remove-contact") : - //% "Add to contacts" - qsTrId("add-to-contacts") + anchors.right: sendMessageBtn.left + anchors.rightMargin: sendMessageBtn.visible ? Style.current.padding : 0 + text: isAdded ? + //% "Remove Contact" + qsTrId("remove-contact") : + //% "Add to contacts" + qsTrId("add-to-contacts") anchors.bottom: parent.bottom + type: isAdded ? "secondary" : "primary" + color: isAdded ? Style.current.danger : Style.current.primary + showBorder: isAdded + borderColor: Style.current.border visible: !isBlocked + width: visible ? implicitWidth : 0 onClicked: { if (profileModel.contacts.isAdded(fromAuthor)) { removeContactConfirmationDialog.parentPopup = profilePopup; @@ -421,5 +414,21 @@ ModalPopup { } } } + + StatusButton { + id: sendMessageBtn + anchors.right: parent.right + anchors.bottom: parent.bottom + //% "Send Message" + text: qsTrId("send-message") + visible: !isBlocked && chatsModel.activeChannel.id !== popup.fromAuthor + width: visible ? implicitWidth : 0 + onClicked: { + if (tabBar.currentIndex !== 0) + tabBar.currentIndex = 0 + chatsModel.joinChat(fromAuthor, Constants.chatTypeOneToOne) + popup.close() + } + } } } diff --git a/ui/shared/status/StatusButton.qml b/ui/shared/status/StatusButton.qml index e679c1941e..884f484858 100644 --- a/ui/shared/status/StatusButton.qml +++ b/ui/shared/status/StatusButton.qml @@ -11,8 +11,10 @@ Button { property string state: "default" property color color: Style.current.buttonForegroundColor property color bgColor: Style.current.buttonBackgroundColor + property color borderColor: color property color bgHoverColor: Qt.darker(control.bgColor, 1.1) property bool disableColorOverlay: false + property bool showBorder: false property int iconRotation: 0 id: control @@ -94,8 +96,8 @@ Button { background: Rectangle { radius: Style.current.radius anchors.fill: parent - border.width: flat ? 1 : 0 - border.color: hovered ? buttonLabel.color : Style.current.transparent + border.width: flat || showBorder ? 1 : 0 + border.color: hovered || showBorder ? control.borderColor : Style.current.transparent color: { if (flat) { return "transparent"