Show the creator or future room's avatar

This commit is contained in:
miruka 2019-11-07 11:08:47 -04:00
parent d6fd518334
commit 11c8af7c19
3 changed files with 37 additions and 2 deletions

View File

@ -4,13 +4,18 @@ import QtQuick.Layouts 1.12
import "../../Base"
HPage {
id: addChatPage
onFocusChanged: createRoom.forceActiveFocus()
property string userId
HColumnLayout {
Layout.alignment: Qt.AlignCenter
Layout.minimumWidth: Layout.maximumWidth
Layout.maximumWidth:
Math.max(tabBar.implicitWidth, swipeView.contentWidth)
Math.max(tabBar.contentWidth, swipeView.contentWidth)
TabBar {
id: tabBar

View File

@ -1,6 +1,7 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
import "../../utils.js" as Utils
HBox {
id: addChatBox
@ -16,6 +17,33 @@ HBox {
buttonCallbacks: ({
})
HRoomAvatar {
// TODO: click to change the avatar
id: avatar
clientUserId: addChatPage.userId
displayName: nameField.text
Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: 128
Layout.preferredHeight: Layout.preferredWidth
HUserAvatar {
anchors.fill: parent
z: 10
opacity: nameField.text ? 0 : 1
visible: opacity > 0
clientUserId: parent.clientUserId
userId: clientUserId
displayName: account ? account.display_name : ""
mxc: account ? account.avatar_url : ""
readonly property var account:
Utils.getItem(modelSources["Account"] || [], "user_id", userId)
Behavior on opacity { HNumberAnimation {} }
}
}
HTextField {
id: nameField
placeholderText: qsTr("Name")

View File

@ -63,7 +63,9 @@ HTileDelegate {
icon.name: "add-account" // TODO
backgroundColor: "transparent"
toolTip.text: qsTr("Add new chat")
onClicked: pageLoader.showPage("AddChat/AddChat")
onClicked: pageLoader.showPage(
"AddChat/AddChat", {userId: model.data.user_id},
)
leftPadding: theme.spacing / 2
rightPadding: leftPadding