mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-20 02:28:56 +00:00
feat: implement new design for the nickname popup
This commit is contained in:
parent
577dbba831
commit
6a57eeccb2
@ -281,7 +281,10 @@ QtObject:
|
|||||||
return self.status.contacts.addContact(pk)
|
return self.status.contacts.addContact(pk)
|
||||||
|
|
||||||
proc changeContactNickname*(self: ProfileView, publicKey: string, nickname: string) {.slot.} =
|
proc changeContactNickname*(self: ProfileView, publicKey: string, nickname: string) {.slot.} =
|
||||||
discard self.status.contacts.addContact(publicKey, nickname)
|
var nicknameToSet = nickname
|
||||||
|
if (nicknameToSet == ""):
|
||||||
|
nicknameToSet = DELETE_CONTACT
|
||||||
|
discard self.status.contacts.addContact(publicKey, nicknameToSet)
|
||||||
|
|
||||||
proc unblockContact*(self: ProfileView, id: string) {.slot.} =
|
proc unblockContact*(self: ProfileView, id: string) {.slot.} =
|
||||||
discard self.status.contacts.unblockContact(id)
|
discard self.status.contacts.unblockContact(id)
|
||||||
|
@ -2,6 +2,8 @@ import eventemitter, json, sequtils
|
|||||||
import libstatus/contacts as status_contacts
|
import libstatus/contacts as status_contacts
|
||||||
import profile/profile
|
import profile/profile
|
||||||
|
|
||||||
|
const DELETE_CONTACT* = "__deleteThisContact__"
|
||||||
|
|
||||||
type
|
type
|
||||||
ContactModel* = ref object
|
ContactModel* = ref object
|
||||||
events*: EventEmitter
|
events*: EventEmitter
|
||||||
@ -45,6 +47,8 @@ proc addContact*(self: ContactModel, id: string, localNickname: string): string
|
|||||||
let nickname =
|
let nickname =
|
||||||
if (localNickname == ""):
|
if (localNickname == ""):
|
||||||
contact.localNickname
|
contact.localNickname
|
||||||
|
elif (localNickname == DELETE_CONTACT):
|
||||||
|
""
|
||||||
else:
|
else:
|
||||||
localNickname
|
localNickname
|
||||||
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.ensVerifiedAt, contact.ensVerificationRetries, contact.alias, contact.identicon, contact.systemTags, nickname)
|
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.ensVerifiedAt, contact.ensVerificationRetries, contact.alias, contact.identicon, contact.systemTags, nickname)
|
||||||
|
@ -12,7 +12,12 @@ ModalPopup {
|
|||||||
property bool nicknameTooLong: nicknameLength > maxNicknameLength
|
property bool nicknameTooLong: nicknameLength > maxNicknameLength
|
||||||
|
|
||||||
id: popup
|
id: popup
|
||||||
height: 325
|
width: 400
|
||||||
|
height: 390
|
||||||
|
|
||||||
|
onOpened: {
|
||||||
|
nicknameInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||||
|
}
|
||||||
|
|
||||||
header: Item {
|
header: Item {
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
@ -80,12 +85,17 @@ ModalPopup {
|
|||||||
//% "Done"
|
//% "Done"
|
||||||
label: qsTrId("done")
|
label: qsTrId("done")
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
disabled: popup.nicknameLength === 0 || popup.nicknameTooLong
|
disabled: popup.nicknameTooLong
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!userName.startsWith("@")) {
|
if (!isEnsVerified) {
|
||||||
// Replace username only if it was not an ENS name
|
// Change username title only if it was not an ENS name
|
||||||
|
if (nicknameInput.textField.text === "") {
|
||||||
|
// If we removed the nickname, go back to showing the alias
|
||||||
|
userName = alias
|
||||||
|
} else {
|
||||||
userName = nicknameInput.textField.text
|
userName = nicknameInput.textField.text
|
||||||
}
|
}
|
||||||
|
}
|
||||||
nickname = nicknameInput.textField.text
|
nickname = nicknameInput.textField.text
|
||||||
profileModel.changeContactNickname(fromAuthor, nicknameInput.textField.text)
|
profileModel.changeContactNickname(fromAuthor, nicknameInput.textField.text)
|
||||||
popup.close()
|
popup.close()
|
||||||
|
@ -10,7 +10,7 @@ ModalPopup {
|
|||||||
id: popup
|
id: popup
|
||||||
property var identicon: ""
|
property var identicon: ""
|
||||||
property var userName: ""
|
property var userName: ""
|
||||||
property var nickname: ""
|
property string nickname: ""
|
||||||
property var fromAuthor: ""
|
property var fromAuthor: ""
|
||||||
property var text: ""
|
property var text: ""
|
||||||
property var alias: ""
|
property var alias: ""
|
||||||
@ -300,15 +300,11 @@ ModalPopup {
|
|||||||
anchors.bottom: nicknameTitle.bottom
|
anchors.bottom: nicknameTitle.bottom
|
||||||
onClicked: {
|
onClicked: {
|
||||||
nicknamePopup.open()
|
nicknamePopup.open()
|
||||||
popup.close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NicknamePopup {
|
NicknamePopup {
|
||||||
id: nicknamePopup
|
id: nicknamePopup
|
||||||
onClosed: {
|
|
||||||
popup.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user