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" import "../../Base"
HPage { HPage {
id: addChatPage
onFocusChanged: createRoom.forceActiveFocus() onFocusChanged: createRoom.forceActiveFocus()
property string userId
HColumnLayout { HColumnLayout {
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
Layout.minimumWidth: Layout.maximumWidth Layout.minimumWidth: Layout.maximumWidth
Layout.maximumWidth: Layout.maximumWidth:
Math.max(tabBar.implicitWidth, swipeView.contentWidth) Math.max(tabBar.contentWidth, swipeView.contentWidth)
TabBar { TabBar {
id: tabBar id: tabBar

View File

@ -1,6 +1,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
import "../../utils.js" as Utils
HBox { HBox {
id: addChatBox id: addChatBox
@ -16,6 +17,33 @@ HBox {
buttonCallbacks: ({ 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 { HTextField {
id: nameField id: nameField
placeholderText: qsTr("Name") placeholderText: qsTr("Name")

View File

@ -63,7 +63,9 @@ HTileDelegate {
icon.name: "add-account" // TODO icon.name: "add-account" // TODO
backgroundColor: "transparent" backgroundColor: "transparent"
toolTip.text: qsTr("Add new chat") 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 leftPadding: theme.spacing / 2
rightPadding: leftPadding rightPadding: leftPadding