fix: fix profile popup buttons to fit the design

This commit is contained in:
Jonathan Rainville 2021-01-11 15:59:05 -05:00 committed by Iuri Matias
parent 686bcd03ca
commit 6705e3f8c7
2 changed files with 48 additions and 37 deletions

View File

@ -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()
}
}
}
}

View File

@ -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"