chore(settings/profile): rework ProfilePopup to StatusDialog
iterates: status-im/StatusQ#760
This commit is contained in:
parent
4c2a7656f2
commit
185de9f4c8
|
@ -1,6 +1,7 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import QtQml.Models 2.14
|
||||
import QtGraphicalEffects 1.13
|
||||
|
||||
import utils 1.0
|
||||
|
@ -15,9 +16,9 @@ import StatusQ.Core 0.1
|
|||
import StatusQ.Core.Theme 0.1
|
||||
import StatusQ.Components 0.1
|
||||
import StatusQ.Controls 0.1
|
||||
import StatusQ.Popups 0.1
|
||||
import StatusQ.Popups.Dialog 0.1
|
||||
|
||||
StatusModal {
|
||||
StatusDialog {
|
||||
id: popup
|
||||
|
||||
property Popup parentPopup
|
||||
|
@ -117,7 +118,6 @@ StatusModal {
|
|||
text = ""; // this is most likely unneeded
|
||||
isCurrentUser = popup.profileStore.pubkey === publicKey;
|
||||
|
||||
showFooter = !isCurrentUser;
|
||||
popup.open();
|
||||
|
||||
if (state === Constants.profilePopupStates.openNickname) {
|
||||
|
@ -168,19 +168,24 @@ StatusModal {
|
|||
}
|
||||
|
||||
width: 700
|
||||
padding: 8
|
||||
|
||||
header.title: {
|
||||
header: StatusDialogHeader {
|
||||
id: dialogHeader
|
||||
|
||||
headline.title: {
|
||||
if(showVerifyIdentitySection || showVerificationPendingSection){
|
||||
return qsTr("Verify %1's Identity").arg(userIsEnsVerified ? userName : userDisplayName)
|
||||
}
|
||||
return popup.isCurrentUser ? qsTr("My Profile") :
|
||||
qsTr("%1's Profile").arg(userIsEnsVerified ? userName : userDisplayName)
|
||||
}
|
||||
header.subTitle: popup.isCurrentUser ? "" : userIsEnsVerified ? userName : Utils.getElidedCompressedPk(userPublicKey)
|
||||
header.subTitleElide: Text.ElideMiddle
|
||||
padding: 8
|
||||
|
||||
headerActionButton: StatusFlatRoundButton {
|
||||
headline.subtitle: popup.isCurrentUser ? "" : userIsEnsVerified ? userName : Utils.getElidedCompressedPk(userPublicKey)
|
||||
|
||||
actions {
|
||||
customButtons: ObjectModel {
|
||||
StatusFlatRoundButton {
|
||||
type: StatusFlatRoundButton.Type.Secondary
|
||||
width: 32
|
||||
height: 32
|
||||
|
@ -190,10 +195,192 @@ StatusModal {
|
|||
icon.name: "qr"
|
||||
onClicked: profileView.qrCodePopup.open()
|
||||
}
|
||||
}
|
||||
|
||||
closeButton.onClicked: popup.close()
|
||||
}
|
||||
}
|
||||
|
||||
footer: StatusDialogFooter {
|
||||
visible: !popup.isCurrentUser
|
||||
|
||||
leftButtons: ObjectModel {
|
||||
StatusButton {
|
||||
text: qsTr("Cancel verification")
|
||||
visible: !isVerified && isContact && isVerificationSent && showVerificationPendingSection
|
||||
onClicked: {
|
||||
popup.contactsStore.cancelVerificationRequest(userPublicKey);
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rightButtons: ObjectModel {
|
||||
StatusFlatButton {
|
||||
text: userIsBlocked ?
|
||||
qsTr("Unblock User") :
|
||||
qsTr("Block User")
|
||||
type: StatusBaseButton.Type.Danger
|
||||
visible: !isAddedContact
|
||||
onClicked: userIsBlocked ? unblockUser() : blockUser()
|
||||
}
|
||||
|
||||
StatusFlatButton {
|
||||
visible: !showRemoveVerified && !showIdentityVerified && !showVerifyIdentitySection && !showVerificationPendingSection && !userIsBlocked && isAddedContact
|
||||
type: StatusBaseButton.Type.Danger
|
||||
text: qsTr('Remove Contact')
|
||||
onClicked: {
|
||||
profileView.removeContactConfirmationDialog.parentPopup = popup;
|
||||
profileView.removeContactConfirmationDialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Send Contact Request")
|
||||
visible: !userIsBlocked && !isAddedContact
|
||||
onClicked: sendContactRequestModal.open()
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Mark Untrustworthy")
|
||||
visible: !showIdentityVerifiedUntrustworthy && !showIdentityVerified && !showVerifyIdentitySection && userTrustIsUnknown
|
||||
enabled: !showVerificationPendingSection || verificationResponse !== ""
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: {
|
||||
if (showVerificationPendingSection) {
|
||||
popup.showIdentityVerified = false;
|
||||
popup.showIdentityVerifiedUntrustworthy = true;
|
||||
popup.showVerificationPendingSection = false;
|
||||
popup.showVerifyIdentitySection = false;
|
||||
profileView.stepsListModel.setProperty(2, "stepCompleted", true);
|
||||
popup.contactsStore.verifiedUntrustworthy(userPublicKey);
|
||||
} else {
|
||||
popup.contactsStore.markUntrustworthy(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Remove 'Identity Verified' status")
|
||||
visible: isTrusted && !showIdentityVerified && !showRemoveVerified
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: {
|
||||
showRemoveVerified = true
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("No")
|
||||
visible: showRemoveVerified
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: {
|
||||
showRemoveVerified = false
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Yes")
|
||||
visible: showRemoveVerified
|
||||
onClicked: {
|
||||
popup.contactsStore.removeTrustStatus(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Remove Untrustworthy Mark")
|
||||
visible: userIsUntrustworthy
|
||||
onClicked: {
|
||||
popup.contactsStore.removeTrustStatus(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Verify Identity")
|
||||
visible: !showIdentityVerifiedUntrustworthy && !showIdentityVerified &&
|
||||
!showVerifyIdentitySection && isContact && !isVerificationSent
|
||||
&& !hasReceivedVerificationRequest
|
||||
onClicked: {
|
||||
popup.showVerifyIdentitySection = true
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Verify Identity pending...")
|
||||
visible: (!showIdentityVerifiedUntrustworthy && !showIdentityVerified && !isTrusted
|
||||
&& isContact && isVerificationSent && !showVerificationPendingSection) ||
|
||||
(hasReceivedVerificationRequest && !isTrusted)
|
||||
onClicked: {
|
||||
if (hasReceivedVerificationRequest) {
|
||||
popup.openPendingRequestPopup()
|
||||
} else {
|
||||
popup.showVerificationPendingSection = true
|
||||
profileView.wizardAnimation.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Send verification request")
|
||||
visible: showVerifyIdentitySection && isContact && !isVerificationSent
|
||||
onClicked: {
|
||||
popup.contactsStore.sendVerificationRequest(userPublicKey, Utils.escapeHtml(profileView.challengeTxt.input.text));
|
||||
profileView.stepsListModel.setProperty(1, "stepCompleted", true);
|
||||
Global.displayToastMessage(qsTr("Verification request sent"),
|
||||
"",
|
||||
"checkmark-circle",
|
||||
false,
|
||||
Constants.ephemeralNotificationType.normal,
|
||||
"");
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Confirm Identity")
|
||||
visible: isContact && isVerificationSent && !isTrusted && showVerificationPendingSection
|
||||
enabled: verificationChallenge !== "" && verificationResponse !== ""
|
||||
onClicked: {
|
||||
popup.showIdentityVerified = true;
|
||||
popup.showIdentityVerifiedUntrustworthy = false;
|
||||
popup.showVerificationPendingSection = false;
|
||||
popup.showVerifyIdentitySection = false;
|
||||
profileView.stepsListModel.setProperty(2, "stepCompleted", true);
|
||||
popup.contactsStore.verifiedTrusted(userPublicKey);
|
||||
popup.isTrusted = true
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
visible: showIdentityVerified || showIdentityVerifiedUntrustworthy
|
||||
text: qsTr("Rename")
|
||||
onClicked: {
|
||||
profileView.nicknamePopup.open()
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
visible: showIdentityVerified || showIdentityVerifiedUntrustworthy
|
||||
text: qsTr("Close")
|
||||
onClicked: {
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatusScrollView {
|
||||
id: scrollView
|
||||
|
||||
anchors.fill: parent
|
||||
padding: 0
|
||||
|
||||
SharedViews.ProfileView {
|
||||
id: profileView
|
||||
anchors.fill: parent
|
||||
|
||||
width: scrollView.availableWidth
|
||||
|
||||
profileStore: popup.profileStore
|
||||
contactsStore: popup.contactsStore
|
||||
|
@ -262,6 +449,7 @@ StatusModal {
|
|||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace with StatusStackModal
|
||||
SendContactRequestModal {
|
||||
|
@ -277,173 +465,6 @@ StatusModal {
|
|||
onClosed: popup.close()
|
||||
}
|
||||
|
||||
leftButtons:[
|
||||
StatusButton {
|
||||
text: qsTr("Cancel verification")
|
||||
visible: !isVerified && isContact && isVerificationSent && showVerificationPendingSection
|
||||
onClicked: {
|
||||
popup.contactsStore.cancelVerificationRequest(userPublicKey);
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
rightButtons: [
|
||||
StatusFlatButton {
|
||||
text: userIsBlocked ?
|
||||
qsTr("Unblock User") :
|
||||
qsTr("Block User")
|
||||
type: StatusBaseButton.Type.Danger
|
||||
visible: !isAddedContact
|
||||
onClicked: userIsBlocked ? unblockUser() : blockUser()
|
||||
},
|
||||
|
||||
StatusFlatButton {
|
||||
visible: !showRemoveVerified && !showIdentityVerified && !showVerifyIdentitySection && !showVerificationPendingSection && !userIsBlocked && isAddedContact
|
||||
type: StatusBaseButton.Type.Danger
|
||||
text: qsTr('Remove Contact')
|
||||
onClicked: {
|
||||
profileView.removeContactConfirmationDialog.parentPopup = popup;
|
||||
profileView.removeContactConfirmationDialog.open();
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Send Contact Request")
|
||||
visible: !userIsBlocked && !isAddedContact
|
||||
onClicked: sendContactRequestModal.open()
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Mark Untrustworthy")
|
||||
visible: !showIdentityVerifiedUntrustworthy && !showIdentityVerified && !showVerifyIdentitySection && userTrustIsUnknown
|
||||
enabled: !showVerificationPendingSection || verificationResponse !== ""
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: {
|
||||
if (showVerificationPendingSection) {
|
||||
popup.showIdentityVerified = false;
|
||||
popup.showIdentityVerifiedUntrustworthy = true;
|
||||
popup.showVerificationPendingSection = false;
|
||||
popup.showVerifyIdentitySection = false;
|
||||
profileView.stepsListModel.setProperty(2, "stepCompleted", true);
|
||||
popup.contactsStore.verifiedUntrustworthy(userPublicKey);
|
||||
} else {
|
||||
popup.contactsStore.markUntrustworthy(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Remove 'Identity Verified' status")
|
||||
visible: isTrusted && !showIdentityVerified && !showRemoveVerified
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: {
|
||||
showRemoveVerified = true
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("No")
|
||||
visible: showRemoveVerified
|
||||
type: StatusBaseButton.Type.Danger
|
||||
onClicked: {
|
||||
showRemoveVerified = false
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Yes")
|
||||
visible: showRemoveVerified
|
||||
onClicked: {
|
||||
popup.contactsStore.removeTrustStatus(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Remove Untrustworthy Mark")
|
||||
visible: userIsUntrustworthy
|
||||
onClicked: {
|
||||
popup.contactsStore.removeTrustStatus(userPublicKey);
|
||||
popup.close();
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Verify Identity")
|
||||
visible: !showIdentityVerifiedUntrustworthy && !showIdentityVerified &&
|
||||
!showVerifyIdentitySection && isContact && !isVerificationSent
|
||||
&& !hasReceivedVerificationRequest
|
||||
onClicked: {
|
||||
popup.showVerifyIdentitySection = true
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Verify Identity pending...")
|
||||
visible: (!showIdentityVerifiedUntrustworthy && !showIdentityVerified && !isTrusted
|
||||
&& isContact && isVerificationSent && !showVerificationPendingSection) ||
|
||||
(hasReceivedVerificationRequest && !isTrusted)
|
||||
onClicked: {
|
||||
if (hasReceivedVerificationRequest) {
|
||||
popup.openPendingRequestPopup()
|
||||
} else {
|
||||
popup.showVerificationPendingSection = true
|
||||
profileView.wizardAnimation.running = true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Send verification request")
|
||||
visible: showVerifyIdentitySection && isContact && !isVerificationSent
|
||||
onClicked: {
|
||||
popup.contactsStore.sendVerificationRequest(userPublicKey, Utils.escapeHtml(profileView.challengeTxt.input.text));
|
||||
profileView.stepsListModel.setProperty(1, "stepCompleted", true);
|
||||
Global.displayToastMessage(qsTr("Verification request sent"),
|
||||
"",
|
||||
"checkmark-circle",
|
||||
false,
|
||||
Constants.ephemeralNotificationType.normal,
|
||||
"");
|
||||
popup.close();
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Confirm Identity")
|
||||
visible: isContact && isVerificationSent && !isTrusted && showVerificationPendingSection
|
||||
enabled: verificationChallenge !== "" && verificationResponse !== ""
|
||||
onClicked: {
|
||||
popup.showIdentityVerified = true;
|
||||
popup.showIdentityVerifiedUntrustworthy = false;
|
||||
popup.showVerificationPendingSection = false;
|
||||
popup.showVerifyIdentitySection = false;
|
||||
profileView.stepsListModel.setProperty(2, "stepCompleted", true);
|
||||
popup.contactsStore.verifiedTrusted(userPublicKey);
|
||||
popup.isTrusted = true
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
visible: showIdentityVerified || showIdentityVerifiedUntrustworthy
|
||||
text: qsTr("Rename")
|
||||
onClicked: {
|
||||
profileView.nicknamePopup.open()
|
||||
}
|
||||
},
|
||||
|
||||
StatusButton {
|
||||
visible: showIdentityVerified || showIdentityVerifiedUntrustworthy
|
||||
text: qsTr("Close")
|
||||
onClicked: {
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Component {
|
||||
id: contactVerificationRequestPopupComponent
|
||||
ContactVerificationRequestPopup {
|
||||
|
|
Loading…
Reference in New Issue