2022-10-05 14:51:42 +00:00
|
|
|
import QtQuick 2.14
|
2023-08-07 09:21:46 +00:00
|
|
|
import QtQuick.Layouts 1.15
|
2022-10-05 14:51:42 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-10-20 11:57:41 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-10-05 14:51:42 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property bool pending: false
|
|
|
|
property bool accepted: false
|
|
|
|
property bool declined: false
|
2023-08-07 09:21:46 +00:00
|
|
|
property bool acceptedPending: false
|
|
|
|
property bool declinedPending: false
|
|
|
|
property bool ctaAllowed: true
|
2022-10-05 14:51:42 +00:00
|
|
|
|
|
|
|
signal acceptRequestToJoinCommunity()
|
|
|
|
signal declineRequestToJoinCommunity()
|
|
|
|
|
2022-10-20 11:57:41 +00:00
|
|
|
implicitWidth: Math.max(textItem.width, buttons.width)
|
|
|
|
implicitHeight: Math.max(textItem.height, buttons.height)
|
2022-10-05 14:51:42 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: textItem
|
2022-10-19 12:56:00 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
2022-11-15 10:11:55 +00:00
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2022-10-05 14:51:42 +00:00
|
|
|
visible: !pending
|
|
|
|
text: {
|
|
|
|
if (root.accepted) {
|
|
|
|
return qsTr("Accepted")
|
2022-10-20 11:57:41 +00:00
|
|
|
}
|
|
|
|
if (root.declined) {
|
2022-10-05 14:51:42 +00:00
|
|
|
return qsTr("Declined")
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
color: {
|
|
|
|
if (root.accepted) {
|
|
|
|
return Theme.palette.successColor1
|
2022-10-20 11:57:41 +00:00
|
|
|
}
|
|
|
|
if (root.declined) {
|
2022-10-05 14:51:42 +00:00
|
|
|
return Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
return Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-07 09:21:46 +00:00
|
|
|
RowLayout {
|
2022-10-05 14:51:42 +00:00
|
|
|
id: buttons
|
|
|
|
anchors.centerIn: parent
|
2023-08-07 09:21:46 +00:00
|
|
|
visible: pending || acceptedPending || declinedPending
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
StatusFlatButton {
|
|
|
|
icon.name: "checkmark-circle"
|
|
|
|
icon.color: enabled ? Theme.palette.successColor1 : disabledTextColor
|
2022-10-20 11:57:41 +00:00
|
|
|
onClicked: root.acceptRequestToJoinCommunity()
|
2023-08-07 09:21:46 +00:00
|
|
|
enabled: !root.acceptedPending
|
|
|
|
text: root.acceptedPending ? qsTr("Accept pending") : ""
|
|
|
|
verticalPadding: 4
|
|
|
|
horizontalPadding: 4
|
|
|
|
visible: root.ctaAllowed || !enabled
|
2022-10-05 14:51:42 +00:00
|
|
|
}
|
|
|
|
|
2023-08-07 09:21:46 +00:00
|
|
|
StatusFlatButton {
|
|
|
|
icon.name: "close-circle"
|
|
|
|
icon.color: enabled ? Theme.palette.dangerColor1 : disabledTextColor
|
2022-10-20 11:57:41 +00:00
|
|
|
onClicked: root.declineRequestToJoinCommunity()
|
2023-08-07 09:21:46 +00:00
|
|
|
enabled: !root.declinedPending
|
|
|
|
text: root.declinedPending ? qsTr("Reject pending") : ""
|
|
|
|
verticalPadding: 4
|
|
|
|
horizontalPadding: 4
|
|
|
|
visible: root.ctaAllowed || !enabled
|
2022-10-05 14:51:42 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-07 09:21:46 +00:00
|
|
|
}
|