Base TypingMembersBar on new InfoBar component

This commit is contained in:
miruka 2020-05-20 04:45:30 -04:00
parent 63af4be1e2
commit 5128f0d888
3 changed files with 54 additions and 41 deletions

View File

@ -63,6 +63,7 @@ HColumnPage {
} }
TypingMembersBar { TypingMembersBar {
typingMembers: JSON.parse(chat.roomInfo.typing_members)
Layout.fillWidth: true Layout.fillWidth: true
} }

View File

@ -0,0 +1,41 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
Rectangle {
implicitHeight: label.text ? rowLayout.height : 0
opacity: implicitHeight ? 1 : 0
readonly property alias icon: icon
readonly property alias label: label
Behavior on implicitHeight { HNumberAnimation {} }
HRowLayout {
id: rowLayout
spacing: theme.spacing
HIcon {
id: icon
Layout.fillHeight: true
Layout.leftMargin: rowLayout.spacing / 2
}
HLabel {
id: label
elide: Text.ElideRight
Layout.fillWidth: true
Layout.fillHeight: true
Layout.topMargin: rowLayout.spacing / 4
Layout.bottomMargin: rowLayout.spacing / 4
Layout.leftMargin: rowLayout.spacing / 2
Layout.rightMargin: rowLayout.spacing / 2
}
}
}

View File

@ -4,35 +4,12 @@ import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import "../../Base" import "../../Base"
Rectangle { InfoBar {
id: typingMembersBar
property alias label: typingLabel
color: theme.chat.typingMembers.background color: theme.chat.typingMembers.background
implicitHeight: typingLabel.text ? rowLayout.height : 0 icon.svgName: "typing" // TODO: animate
opacity: implicitHeight ? 1 : 0 label.textFormat: Text.StyledText
label.text: {
Behavior on implicitHeight { HNumberAnimation {} } const tm = typingMembers
HRowLayout {
id: rowLayout
spacing: theme.spacing
HIcon {
id: icon
svgName: "typing" // TODO: animate
Layout.fillHeight: true
Layout.leftMargin: rowLayout.spacing / 2
}
HLabel {
id: typingLabel
textFormat: Text.StyledText
elide: Text.ElideRight
text: {
const tm = JSON.parse(chat.roomInfo.typing_members)
if (tm.length === 0) return "" if (tm.length === 0) return ""
if (tm.length === 1) return qsTr("%1 is typing...").arg(tm[0]) if (tm.length === 1) return qsTr("%1 is typing...").arg(tm[0])
@ -41,12 +18,6 @@ Rectangle {
.arg(tm.slice(0, -1).join(", ")).arg(tm.slice(-1)[0]) .arg(tm.slice(0, -1).join(", ")).arg(tm.slice(-1)[0])
} }
Layout.fillWidth: true
Layout.fillHeight: true property var typingMembers: []
Layout.topMargin: rowLayout.spacing / 4
Layout.bottomMargin: rowLayout.spacing / 4
Layout.leftMargin: rowLayout.spacing / 2
Layout.rightMargin: rowLayout.spacing / 2
}
}
} }