moment/src/qml/Chat/Timeline/EventDelegate.qml

62 lines
1.9 KiB
QML
Raw Normal View History

2019-07-08 13:52:41 +10:00
// Copyright 2019 miruka
// This file is part of harmonyqml, licensed under LGPLv3.
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../Base"
2019-03-22 14:28:14 +11:00
Column {
id: eventDelegate
2019-03-22 14:28:14 +11:00
// Remember timeline goes from newest message at index 0 to oldest
property var previousItem: eventList.model.get(model.index + 1)
property var nextItem: eventList.model.get(model.index - 1)
2019-03-22 14:28:14 +11:00
property int modelIndex: model.index
onModelIndexChanged: {
previousItem = eventList.model.get(model.index + 1)
nextItem = eventList.model.get(model.index - 1)
}
property var senderInfo: senderInfo = users.find(model.senderId)
2019-07-20 10:55:52 +10:00
property bool isOwn: chatPage.userId === model.senderId
property bool onRight: eventList.ownEventsOnRight && isOwn
property bool combine: eventList.canCombine(previousItem, model)
property bool talkBreak: eventList.canTalkBreak(previousItem, model)
property bool dayBreak: eventList.canDayBreak(previousItem, model)
2019-07-20 10:55:52 +10:00
readonly property bool smallAvatar:
eventList.canCombine(model, nextItem) &&
(model.eventType == "RoomMessageEmote" ||
! model.eventType.startsWith("RoomMessage"))
2019-03-22 14:28:14 +11:00
readonly property bool collapseAvatar: combine
readonly property bool hideAvatar: onRight
2019-03-22 14:28:14 +11:00
readonly property bool hideNameLine:
model.eventType == "RoomMessageEmote" ||
! model.eventType.startsWith("RoomMessage") ||
onRight ||
combine
width: eventList.width
2019-03-22 14:28:14 +11:00
topPadding:
model.eventType == "RoomCreateEvent" ? 0 :
dayBreak ? theme.spacing * 4 :
2019-07-16 19:29:47 +10:00
talkBreak ? theme.spacing * 6 :
combine ? theme.spacing / 2 :
2019-07-16 19:29:47 +10:00
theme.spacing * 2
Daybreak {
visible: dayBreak
width: eventDelegate.width
2019-04-29 04:48:59 +10:00
}
2019-03-22 14:28:14 +11:00
2019-07-03 12:29:09 +10:00
EventContent {
2019-07-18 21:22:41 +10:00
x: onRight ? parent.width - width : 0
Behavior on x { HNumberAnimation {} }
2019-04-29 04:48:59 +10:00
}
2019-03-22 14:28:14 +11:00
}