refactor: simplify ProfilePopup usage
This commit is contained in:
parent
2fb9d569f7
commit
cdcb928a0c
|
@ -52,29 +52,9 @@ SplitView {
|
||||||
}
|
}
|
||||||
destroy()
|
destroy()
|
||||||
}
|
}
|
||||||
onBlockButtonClicked: {
|
|
||||||
blockContactConfirmationDialog.contactName = name;
|
|
||||||
blockContactConfirmationDialog.contactAddress = address;
|
|
||||||
blockContactConfirmationDialog.parentPopup = profilePopup;
|
|
||||||
blockContactConfirmationDialog.open();
|
|
||||||
}
|
|
||||||
onRemoveButtonClicked: {
|
|
||||||
chatColumn.contactToRemove = address;
|
|
||||||
removeContactConfirmationDialog.parentPopup = profilePopup;
|
|
||||||
removeContactConfirmationDialog.open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BlockContactConfirmationDialog {
|
|
||||||
id: blockContactConfirmationDialog
|
|
||||||
onBlockButtonClicked: {
|
|
||||||
profileModel.blockContact(blockContactConfirmationDialog.contactAddress)
|
|
||||||
blockContactConfirmationDialog.parentPopup.close()
|
|
||||||
blockContactConfirmationDialog.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfirmationDialog {
|
ConfirmationDialog {
|
||||||
id: removeContactConfirmationDialog
|
id: removeContactConfirmationDialog
|
||||||
// % "Remove contact"
|
// % "Remove contact"
|
||||||
|
|
|
@ -26,8 +26,11 @@ ModalPopup {
|
||||||
signal blockButtonClicked(name: string, address: string)
|
signal blockButtonClicked(name: string, address: string)
|
||||||
signal removeButtonClicked(address: string)
|
signal removeButtonClicked(address: string)
|
||||||
|
|
||||||
function setPopupData(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
|
signal contactBlocked(publicKey: string)
|
||||||
showQR = false
|
signal contactAdded(publicKey: string)
|
||||||
|
signal contactRemoved(publicKey: string)
|
||||||
|
|
||||||
|
function openPopup(showFooter, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
|
||||||
userName = userNameParam || ""
|
userName = userNameParam || ""
|
||||||
nickname = nicknameParam || ""
|
nickname = nicknameParam || ""
|
||||||
fromAuthor = fromAuthorParam || ""
|
fromAuthor = fromAuthorParam || ""
|
||||||
|
@ -35,10 +38,8 @@ ModalPopup {
|
||||||
text = textParam || ""
|
text = textParam || ""
|
||||||
isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor)
|
isEnsVerified = chatsModel.isEnsVerified(this.fromAuthor)
|
||||||
alias = chatsModel.alias(this.fromAuthor) || ""
|
alias = chatsModel.alias(this.fromAuthor) || ""
|
||||||
}
|
|
||||||
|
|
||||||
function openPopup(showFooter, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam) {
|
showQR = false
|
||||||
setPopupData(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam)
|
|
||||||
noFooter = !showFooter;
|
noFooter = !showFooter;
|
||||||
popup.open()
|
popup.open()
|
||||||
}
|
}
|
||||||
|
@ -124,6 +125,36 @@ ModalPopup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
BlockContactConfirmationDialog {
|
||||||
|
id: blockContactConfirmationDialog
|
||||||
|
onBlockButtonClicked: {
|
||||||
|
profileModel.blockContact(fromAuthor)
|
||||||
|
blockContactConfirmationDialog.close();
|
||||||
|
popup.close()
|
||||||
|
|
||||||
|
contactBlocked(fromAuthor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfirmationDialog {
|
||||||
|
id: removeContactConfirmationDialog
|
||||||
|
// % "Remove contact"
|
||||||
|
title: qsTrId("remove-contact")
|
||||||
|
//% "Are you sure you want to remove this contact?"
|
||||||
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
||||||
|
onConfirmButtonClicked: {
|
||||||
|
if (profileModel.isAdded(fromAuthor)) {
|
||||||
|
profileModel.removeContact(fromAuthor);
|
||||||
|
}
|
||||||
|
removeContactConfirmationDialog.close();
|
||||||
|
popup.close();
|
||||||
|
|
||||||
|
contactRemoved(fromAuthor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: showQR
|
visible: showQR
|
||||||
|
@ -349,7 +380,11 @@ ModalPopup {
|
||||||
//% "Block User"
|
//% "Block User"
|
||||||
label: qsTrId("block-user")
|
label: qsTrId("block-user")
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
onClicked: popup.blockButtonClicked(userName, fromAuthor)
|
onClicked: {
|
||||||
|
blockContactConfirmationDialog.contactName = userName;
|
||||||
|
blockContactConfirmationDialog.contactAddress = fromAuthor;
|
||||||
|
blockContactConfirmationDialog.open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledButton {
|
StyledButton {
|
||||||
|
@ -364,10 +399,12 @@ ModalPopup {
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (profileModel.isAdded(fromAuthor)) {
|
if (profileModel.isAdded(fromAuthor)) {
|
||||||
popup.removeButtonClicked(fromAuthor)
|
removeContactConfirmationDialog.parentPopup = profilePopup;
|
||||||
|
removeContactConfirmationDialog.open();
|
||||||
} else {
|
} else {
|
||||||
profileModel.addContact(fromAuthor)
|
profileModel.addContact(fromAuthor);
|
||||||
profilePopup.close()
|
contactAdded(fromAuthor);
|
||||||
|
profilePopup.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ ListView {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
model: contacts
|
model: contacts
|
||||||
|
|
||||||
delegate: Contact {
|
delegate: Contact {
|
||||||
name: Utils.removeStatusEns(model.name)
|
name: Utils.removeStatusEns(model.name)
|
||||||
address: model.address
|
address: model.address
|
||||||
|
@ -38,28 +39,16 @@ ListView {
|
||||||
blockContactConfirmationDialog.open()
|
blockContactConfirmationDialog.open()
|
||||||
}
|
}
|
||||||
onRemoveContactActionTriggered: {
|
onRemoveContactActionTriggered: {
|
||||||
contactList.contactToRemove = address
|
removeContactConfirmationDialog.value = address
|
||||||
removeContactConfirmationDialog.open()
|
removeContactConfirmationDialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfilePopup {
|
ProfilePopup {
|
||||||
id: profilePopup
|
id: profilePopup
|
||||||
onBlockButtonClicked: {
|
|
||||||
blockContactConfirmationDialog.contactName = name
|
|
||||||
blockContactConfirmationDialog.contactAddress = address
|
|
||||||
blockContactConfirmationDialog.open()
|
|
||||||
}
|
|
||||||
onRemoveButtonClicked: {
|
|
||||||
contactList.contactToRemove = address
|
|
||||||
removeContactConfirmationDialog.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonGroup {
|
|
||||||
id: contactGroup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make BlockContactConfirmationDialog a dynamic component on a future refactor
|
||||||
BlockContactConfirmationDialog {
|
BlockContactConfirmationDialog {
|
||||||
id: blockContactConfirmationDialog
|
id: blockContactConfirmationDialog
|
||||||
onBlockButtonClicked: {
|
onBlockButtonClicked: {
|
||||||
|
@ -68,18 +57,25 @@ ListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make ConfirmationDialog a dynamic component on a future refactor
|
||||||
ConfirmationDialog {
|
ConfirmationDialog {
|
||||||
id: removeContactConfirmationDialog
|
id: removeContactConfirmationDialog
|
||||||
title: qsTrId("remove-contact")
|
title: qsTrId("remove-contact")
|
||||||
//% "Are you sure you want to remove this contact?"
|
//% "Are you sure you want to remove this contact?"
|
||||||
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
confirmationText: qsTrId("are-you-sure-you-want-to-remove-this-contact-")
|
||||||
onConfirmButtonClicked: {
|
onConfirmButtonClicked: {
|
||||||
if (profileModel.isAdded(contactList.contactToRemove)) {
|
if (profileModel.isAdded(removeContactConfirmationDialog.value)) {
|
||||||
profileModel.removeContact(contactList.contactToRemove)
|
profileModel.removeContact(removeContactConfirmationDialog.value);
|
||||||
}
|
}
|
||||||
removeContactConfirmationDialog.close()
|
removeContactConfirmationDialog.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ButtonGroup {
|
||||||
|
id: contactGroup
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*##^##
|
/*##^##
|
||||||
Designer {
|
Designer {
|
||||||
|
|
|
@ -18,7 +18,6 @@ ModalPopup {
|
||||||
title: qsTrId("block-user")
|
title: qsTrId("block-user")
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
//%
|
|
||||||
text: qsTr("Blocking will remove any messages you received from %1 and stop new messages from reaching you.").arg(contactName)
|
text: qsTr("Blocking will remove any messages you received from %1 and stop new messages from reaching you.").arg(contactName)
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|
|
@ -20,6 +20,8 @@ ModalPopup {
|
||||||
//% "Are you sure you want to this?"
|
//% "Are you sure you want to this?"
|
||||||
property string confirmationText: qsTrId("are-you-sure-you-want-to-this-")
|
property string confirmationText: qsTrId("are-you-sure-you-want-to-this-")
|
||||||
|
|
||||||
|
property var value
|
||||||
|
|
||||||
signal confirmButtonClicked()
|
signal confirmButtonClicked()
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
|
Loading…
Reference in New Issue