2023-02-01 17:26:59 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import AppLayouts.Chat.helpers 1.0
|
|
|
|
import AppLayouts.Chat.controls.community 1.0
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
2023-03-30 09:42:28 +00:00
|
|
|
import utils 1.0
|
2023-02-01 17:26:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
Control {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property bool joinCommunity: true // Otherwise it means join channel action
|
|
|
|
property bool requirementsMet: false
|
|
|
|
property bool requiresRequest: false
|
|
|
|
property bool isInvitationPending: false
|
|
|
|
property bool isJoinRequestRejected: false
|
|
|
|
property string communityName
|
2023-02-14 16:33:23 +00:00
|
|
|
property var communityHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
property string channelName
|
2023-02-14 16:33:23 +00:00
|
|
|
property var viewOnlyHoldingsModel
|
|
|
|
property var viewAndPostHoldingsModel
|
|
|
|
property var moderateHoldingsModel
|
|
|
|
property bool showOnlyPanels: false
|
2023-03-30 09:42:28 +00:00
|
|
|
property int loginType: Constants.LoginType.Password
|
2023-02-01 17:26:59 +00:00
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
property var assetsModel
|
|
|
|
property var collectiblesModel
|
|
|
|
|
2023-02-01 17:26:59 +00:00
|
|
|
signal revealAddressClicked
|
|
|
|
signal invitationPendingClicked
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property string communityRequirementsNotMetText: qsTr("Membership requirements not met")
|
|
|
|
readonly property string communityRevealAddressText: qsTr("Reveal your address to join")
|
|
|
|
readonly property string communityRevealAddressWithRequestText: qsTr("Reveal your address and request to join")
|
|
|
|
readonly property string communityMembershipRequestPendingText: qsTr("Membership Request Pending...")
|
|
|
|
readonly property string channelRequirementsNotMetText: qsTr("Channel requirements not met")
|
|
|
|
readonly property string channelRevealAddressText: qsTr("Reveal your address to enter")
|
|
|
|
readonly property string channelMembershipRequestPendingText: qsTr("Channel Membership Request Pending...")
|
|
|
|
readonly property string memberchipRequestRejectedText: qsTr("Membership Request Rejected")
|
|
|
|
|
|
|
|
function holdingsTextFormat(name, amount) {
|
|
|
|
return CommunityPermissionsHelpers.setHoldingsTextFormat(HoldingTypes.Type.Asset, name, amount)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getInvitationPendingText() {
|
|
|
|
return root.joinCommunity ? d.communityMembershipRequestPendingText : d.channelMembershipRequestPendingText
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRevealAddressText() {
|
|
|
|
return root.joinCommunity ? (root.requiresRequest ? d.communityRevealAddressWithRequestText : d.communityRevealAddressText) : d.channelRevealAddressText
|
|
|
|
}
|
2023-03-30 09:42:28 +00:00
|
|
|
|
|
|
|
function getRevealAddressIcon() {
|
|
|
|
if(root.loginType == Constants.LoginType.Password) return "password"
|
|
|
|
return root.loginType == Constants.LoginType.Biometrics ? "touch-id" : "keycard"
|
|
|
|
}
|
2023-02-01 17:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
padding: 35 // default by design
|
|
|
|
spacing: 32 // default by design
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
id: column
|
2023-02-13 10:40:13 +00:00
|
|
|
|
2023-02-01 17:26:59 +00:00
|
|
|
spacing: root.spacing
|
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
component CustomHoldingsListPanel: HoldingsListPanel {
|
2023-02-01 17:26:59 +00:00
|
|
|
Layout.fillWidth: true
|
2023-02-13 10:40:13 +00:00
|
|
|
|
|
|
|
assetsModel: root.assetsModel
|
|
|
|
collectiblesModel: root.collectiblesModel
|
|
|
|
|
2023-02-01 17:26:59 +00:00
|
|
|
spacing: root.spacing
|
2023-02-13 10:40:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CustomHoldingsListPanel {
|
2023-02-14 16:33:23 +00:00
|
|
|
visible: root.joinCommunity && root.communityHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
introText: qsTr("To join <b>%1</b> you need to prove that you hold").arg(root.communityName)
|
2023-02-14 16:33:23 +00:00
|
|
|
model: root.communityHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
}
|
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
CustomHoldingsListPanel {
|
2023-02-14 16:33:23 +00:00
|
|
|
visible: !root.joinCommunity && !!root.viewOnlyHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
introText: qsTr("To only view the <b>%1</b> channel you need to hold").arg(root.channelName)
|
2023-02-14 16:33:23 +00:00
|
|
|
model: root.viewOnlyHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
}
|
|
|
|
|
2023-02-13 10:40:13 +00:00
|
|
|
CustomHoldingsListPanel {
|
2023-02-14 16:33:23 +00:00
|
|
|
visible: !root.joinCommunity && !!root.viewAndPostHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
introText: qsTr("To view and post in the <b>%1</b> channel you need to hold").arg(root.channelName)
|
2023-02-14 16:33:23 +00:00
|
|
|
model: root.viewAndPostHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HoldingsListPanel {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: root.spacing
|
2023-02-13 10:40:13 +00:00
|
|
|
visible: !root.joinCommunity && !!root.moderateHoldings
|
2023-02-01 17:26:59 +00:00
|
|
|
introText: qsTr("To moderate in the <b>%1</b> channel you need to hold").arg(root.channelName)
|
2023-02-14 16:33:23 +00:00
|
|
|
model: root.moderateHoldingsModel
|
2023-02-01 17:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-02-14 16:33:23 +00:00
|
|
|
visible: !root.showOnlyPanels && !root.isJoinRequestRejected
|
2023-02-01 17:26:59 +00:00
|
|
|
text: root.isInvitationPending ? d.getInvitationPendingText() : d.getRevealAddressText()
|
2023-03-30 09:42:28 +00:00
|
|
|
icon.name: root.isInvitationPending ? "" : d.getRevealAddressIcon()
|
2023-02-01 17:26:59 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
enabled: root.requirementsMet
|
|
|
|
onClicked: root.isInvitationPending ? root.invitationPendingClicked() : root.revealAddressClicked()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-02-14 16:33:23 +00:00
|
|
|
visible: !root.showOnlyPanels && (root.isJoinRequestRejected || !root.requirementsMet)
|
2023-02-01 17:26:59 +00:00
|
|
|
text: root.isJoinRequestRejected ? d.memberchipRequestRejectedText :
|
|
|
|
(root.joinCommunity ? d.communityRequirementsNotMetText : d.channelRequirementsNotMetText)
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|