status-desktop/ui/app/AppLayouts/Chat/components/NicknamePopup.qml

95 lines
3.0 KiB
QML
Raw Normal View History

2020-09-16 16:00:21 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13
import "../../../../imports"
import "../../../../shared"
import "./"
ModalPopup {
property int nicknameLength: nicknameInput.textField.text.length
readonly property int maxNicknameLength: 32
property bool nicknameTooLong: nicknameLength > maxNicknameLength
id: popup
height: 325
2020-09-16 16:00:21 +00:00
header: Item {
height: childrenRect.height
width: parent.width
StyledText {
id: nicknameTitle
2020-09-22 07:53:03 +00:00
//% "Nickname"
text: qsTrId("nickname")
2020-09-16 16:00:21 +00:00
anchors.top: parent.top
anchors.topMargin: 18
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
font.bold: true
font.pixelSize: 14
}
StyledText {
text: isEnsVerified ? alias : fromAuthor
width: 160
elide: !isEnsVerified ? Text.ElideMiddle : Text.ElideNone
anchors.left: nicknameTitle.left
anchors.top: nicknameTitle.bottom
anchors.topMargin: 2
font.pixelSize: 14
color: Style.current.secondaryText
}
}
StyledText {
id: descriptionText
2020-09-22 07:53:03 +00:00
//% "Nicknames help you identify others in Status. Only you can see the nicknames youve added"
text: qsTrId("nicknames-help-you-identify-others-in-status--only-you-can-see-the-nicknames-you-ve-added")
2020-09-16 16:00:21 +00:00
font.pixelSize: 15
wrapMode: Text.WordWrap
color: Style.current.secondaryText
width: parent.width
}
Input {
id: nicknameInput
2020-09-22 07:53:03 +00:00
//% "Nickname"
placeholderText: qsTrId("nickname")
text: nickname
2020-09-16 16:00:21 +00:00
anchors.top: descriptionText.bottom
anchors.topMargin: Style.current.padding
2020-09-22 07:53:03 +00:00
//% "Your nickname is too long"
validationError: popup.nicknameTooLong ? qsTrId("your-nickname-is-too-long") : ""
2020-09-16 16:00:21 +00:00
}
StyledText {
id: lengthLimitText
text: popup.nicknameLength + "/" + popup.maxNicknameLength
font.pixelSize: 15
anchors.top: nicknameInput.bottom
anchors.topMargin: 12
anchors.right: parent.right
color: popup.nicknameTooLong ? Style.current.danger : Style.current.secondaryText
}
footer: StyledButton {
id: doneBtn
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
2020-09-22 07:53:03 +00:00
//% "Done"
label: qsTrId("done")
2020-09-16 16:00:21 +00:00
anchors.bottom: parent.bottom
disabled: popup.nicknameLength === 0 || popup.nicknameTooLong
onClicked: {
if (!userName.startsWith("@")) {
// Replace username only if it was not an ENS name
userName = nicknameInput.textField.text
}
2020-09-17 14:26:26 +00:00
nickname = nicknameInput.textField.text
profileModel.changeContactNickname(fromAuthor, nicknameInput.textField.text)
popup.close()
2020-09-16 16:00:21 +00:00
}
}
}