diff --git a/src/gui/Pages/Chat/ChatPage.qml b/src/gui/Pages/Chat/ChatPage.qml index 80251d13..0ac2eebc 100644 --- a/src/gui/Pages/Chat/ChatPage.qml +++ b/src/gui/Pages/Chat/ChatPage.qml @@ -63,6 +63,7 @@ HColumnPage { } TypingMembersBar { + typingMembers: JSON.parse(chat.roomInfo.typing_members) Layout.fillWidth: true } diff --git a/src/gui/Pages/Chat/InfoBar.qml b/src/gui/Pages/Chat/InfoBar.qml new file mode 100644 index 00000000..6a03fed0 --- /dev/null +++ b/src/gui/Pages/Chat/InfoBar.qml @@ -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 + } + } +} diff --git a/src/gui/Pages/Chat/TypingMembersBar.qml b/src/gui/Pages/Chat/TypingMembersBar.qml index 5b9d2b23..2173bde6 100644 --- a/src/gui/Pages/Chat/TypingMembersBar.qml +++ b/src/gui/Pages/Chat/TypingMembersBar.qml @@ -4,49 +4,20 @@ import QtQuick 2.12 import QtQuick.Layouts 1.12 import "../../Base" -Rectangle { - id: typingMembersBar - - property alias label: typingLabel - +InfoBar { color: theme.chat.typingMembers.background - implicitHeight: typingLabel.text ? rowLayout.height : 0 - opacity: implicitHeight ? 1 : 0 + icon.svgName: "typing" // TODO: animate + label.textFormat: Text.StyledText + label.text: { + const tm = typingMembers - Behavior on implicitHeight { HNumberAnimation {} } + if (tm.length === 0) return "" + if (tm.length === 1) return qsTr("%1 is typing...").arg(tm[0]) - 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 === 1) return qsTr("%1 is typing...").arg(tm[0]) - - return qsTr("%1 and %2 are typing...") - .arg(tm.slice(0, -1).join(", ")).arg(tm.slice(-1)[0]) - } - - 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 - } + return qsTr("%1 and %2 are typing...") + .arg(tm.slice(0, -1).join(", ")).arg(tm.slice(-1)[0]) } + + + property var typingMembers: [] }