chore(settings/profile): address social links QA issues

This commit is contained in:
Patryk Osmaczko 2022-08-16 19:22:19 +02:00 committed by osmaczko
parent aeb64e2029
commit 4c2a7656f2
6 changed files with 51 additions and 6 deletions

View File

@ -16,6 +16,9 @@ Item {
property alias url: urlInput.text property alias url: urlInput.text
readonly property alias removeButton: removeButton readonly property alias removeButton: removeButton
readonly property var focusItem: hyperlinkInput.input.edit
property var nextFocusItem: null
implicitHeight: layout.implicitHeight implicitHeight: layout.implicitHeight
implicitWidth: layout.implicitWidth implicitWidth: layout.implicitWidth
@ -37,6 +40,8 @@ Item {
label: qsTr("Hyperlink Text") label: qsTr("Hyperlink Text")
placeholderText: qsTr("Example: My Myspace Profile") placeholderText: qsTr("Example: My Myspace Profile")
charLimit: 24 charLimit: 24
input.tabNavItem: urlInput.input.edit
} }
StatusInput { StatusInput {
@ -46,6 +51,8 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
label: qsTr("URL") label: qsTr("URL")
placeholderText: qsTr("Link URL") placeholderText: qsTr("Link URL")
input.tabNavItem: root.nextFocusItem
} }
} }
@ -69,6 +76,7 @@ Item {
} }
SocialLinkPreview { SocialLinkPreview {
Layout.preferredHeight: 32
text: !!hyperlinkInput.text ? hyperlinkInput.text : qsTr("My Myspace Profile") text: !!hyperlinkInput.text ? hyperlinkInput.text : qsTr("My Myspace Profile")
url: !!urlInput.text ? urlInput.text : urlInput.placeholderText url: !!urlInput.text ? urlInput.text : urlInput.placeholderText
linkType: Constants.socialLinkType.custom linkType: Constants.socialLinkType.custom

View File

@ -10,6 +10,8 @@ StatusInput {
property int linkType property int linkType
leftPadding: 18 // by design
placeholderText: { placeholderText: {
if (linkType === Constants.socialLinkType.twitter) return qsTr("Twitter Handle") if (linkType === Constants.socialLinkType.twitter) return qsTr("Twitter Handle")
if (linkType === Constants.socialLinkType.personalSite) return qsTr("Personal Site") if (linkType === Constants.socialLinkType.personalSite) return qsTr("Personal Site")

View File

@ -39,6 +39,8 @@ Item {
placeholderText: qsTr("Display Name") placeholderText: qsTr("Display Name")
charLimit: 24 charLimit: 24
validators: Constants.validators.displayName validators: Constants.validators.displayName
input.tabNavItem: bioInput.input.edit
} }
@ -56,9 +58,13 @@ Item {
minimumHeight: 108 minimumHeight: 108
maximumHeight: 108 maximumHeight: 108
input.verticalAlignment: TextEdit.AlignTop input.verticalAlignment: TextEdit.AlignTop
input.tabNavItem: socialLinksRepeater.count ? socialLinksRepeater.itemAt(0).input.edit : null
} }
Repeater { Repeater {
id: socialLinksRepeater
model: root.socialLinksModel model: root.socialLinksModel
delegate: StaticSocialLinkInput { delegate: StaticSocialLinkInput {
objectName: model.text + "-socialLinkInput" objectName: model.text + "-socialLinkInput"
@ -68,10 +74,19 @@ Item {
text: model.url text: model.url
onTextChanged: root.socialLinkChanged(model.uuid, model.text, text) onTextChanged: root.socialLinkChanged(model.uuid, model.text, text)
input.tabNavItem: {
if (index < socialLinksRepeater.count - 1) {
return socialLinksRepeater.itemAt(index + 1).input.edit
}
return addMoreSocialLinksButton
}
} }
} }
StatusIconTextButton { StatusIconTextButton {
id: addMoreSocialLinksButton
objectName: "addMoreSocialLinksButton" objectName: "addMoreSocialLinksButton"
Layout.topMargin: -8 // by design Layout.topMargin: -8 // by design
text: qsTr("Add more social links") text: qsTr("Add more social links")

View File

@ -83,7 +83,18 @@ StatusDialog {
linkType: model.linkType linkType: model.linkType
text: model.url text: model.url
input.tabNavItem: {
if (index < staticLinksRepeater.count - 1) {
return staticLinksRepeater.itemAt(index + 1).input.edit
}
return customLinksRepeater.count ? customLinksRepeater.itemAt(0).focusItem : null
}
onTextChanged: root.profileStore.updateLink(model.uuid, model.text, text) onTextChanged: root.profileStore.updateLink(model.uuid, model.text, text)
Component.onCompleted: if (index === 0) {
input.edit.forceActiveFocus()
}
} }
} }
@ -113,6 +124,13 @@ StatusDialog {
removeButton.visible: index > 0 removeButton.visible: index > 0
removeButton.onClicked: root.profileStore.removeCustomLink(model.uuid) removeButton.onClicked: root.profileStore.removeCustomLink(model.uuid)
nextFocusItem: {
if (index < customLinksRepeater.count - 1) {
return customLinksRepeater.itemAt(index + 1).focusItem
}
return addAnotherCustomLinkButton
}
onHyperlinkChanged: root.profileStore.updateLink(model.uuid, hyperlink, url) onHyperlinkChanged: root.profileStore.updateLink(model.uuid, hyperlink, url)
onUrlChanged: root.profileStore.updateLink(model.uuid, hyperlink, url) onUrlChanged: root.profileStore.updateLink(model.uuid, hyperlink, url)
@ -128,6 +146,7 @@ StatusDialog {
} }
StatusIconTextButton { StatusIconTextButton {
id: addAnotherCustomLinkButton
text: qsTr("Add another custom link") text: qsTr("Add another custom link")
onClicked: { onClicked: {
root.profileStore.createCustomLink("", "") root.profileStore.createCustomLink("", "")

View File

@ -46,9 +46,11 @@ Rectangle {
} }
StatusBaseText { StatusBaseText {
Layout.maximumWidth: 150
text: root.linkType === Constants.socialLinkType.custom ? root.text : root.url text: root.linkType === Constants.socialLinkType.custom ? root.text : root.url
color: Theme.palette.directColor4 color: Theme.palette.directColor4
font.weight: Font.Medium font.weight: Font.Medium
elide: Text.ElideMiddle
} }
} }
@ -58,11 +60,12 @@ Rectangle {
contentItem: RowLayout { contentItem: RowLayout {
StatusBaseText { StatusBaseText {
Layout.fillHeight: true Layout.fillHeight: true
Layout.maximumWidth: 300
Layout.bottomMargin: 8 Layout.bottomMargin: 8
text: toolTip.text text: toolTip.text
color: Theme.palette.white color: Theme.palette.white
wrapMode: Text.WordWrap elide: Text.ElideMiddle
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Medium font.weight: Font.Medium
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter

View File

@ -79,10 +79,6 @@ Item {
sorters: [ sorters: [
ExpressionSorter { ExpressionSorter {
expression: sortedSocialLinksModel.customsLastPredicate(modelLeft.linkType, modelRight.linkType) expression: sortedSocialLinksModel.customsLastPredicate(modelLeft.linkType, modelRight.linkType)
},
StringSorter {
roleName: "text"
caseSensitivity: Qt.CaseInsensitive
} }
] ]
} }
@ -96,8 +92,9 @@ Item {
StatusBaseText { StatusBaseText {
Layout.fillWidth: true Layout.fillWidth: true
visible: text !== ""
text: root.bio text: root.bio
wrapMode: Text.WordWrap wrapMode: Text.Wrap
} }
Flow { Flow {
@ -114,6 +111,7 @@ Item {
model: sortedSocialLinksModel model: sortedSocialLinksModel
delegate: SocialLinkPreview { delegate: SocialLinkPreview {
height: 32
text: model.text text: model.text
url: model.url url: model.url
linkType: model.linkType linkType: model.linkType