From 61ccbdf40f02949cd5fe0beda46b0692fc1906b1 Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Fri, 28 Oct 2022 16:07:04 -0400
Subject: [PATCH] chatview: set timestamp component height

+ give the component some height when the hour is not shown
+ make sure the hour is shown if the day is shown

Change-Id: Ia6e4266539d60577899af63beca8017c6140644c
GitLab: #827
---
 src/app/commoncomponents/TimestampInfo.qml | 33 ++++++++++------------
 src/app/constant/JamiTheme.qml             |  7 +++--
 2 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/app/commoncomponents/TimestampInfo.qml b/src/app/commoncomponents/TimestampInfo.qml
index 8ba9e3a53..09aff1d00 100644
--- a/src/app/commoncomponents/TimestampInfo.qml
+++ b/src/app/commoncomponents/TimestampInfo.qml
@@ -24,7 +24,7 @@ import net.jami.Models 1.1
 import net.jami.Adapters 1.1
 import net.jami.Constants 1.1
 
-ColumnLayout{
+ColumnLayout {
     id: root
 
     property bool showTime
@@ -33,6 +33,8 @@ ColumnLayout{
     property string formattedDay
     property real detailsOpacity: 0.6
 
+    spacing: 0
+
     Connections {
         target: MessagesAdapter.messageListModel
         function onTimestampUpdate() {
@@ -45,9 +47,13 @@ ColumnLayout{
     Item {
         visible: showDay
         Layout.alignment: Qt.AlignHCenter
-        Layout.fillHeight: true
+
+        Layout.preferredHeight: childrenRect.height
         Layout.fillWidth: true
         Layout.topMargin: JamiTheme.dayTimestampTopMargin
+        Layout.bottomMargin: formattedTimeLabel.visible ?
+                                 0 :
+                                 JamiTheme.dayTimestampBottomMargin
 
         Rectangle {
             id: line
@@ -55,30 +61,21 @@ ColumnLayout{
             height: 1
             opacity: detailsOpacity
             color:JamiTheme.timestampColor
-            width: chatView.width - JamiTheme.timestampLinePadding
+            width: parent.width - JamiTheme.timestampLinePadding
             anchors.centerIn: parent
         }
 
         Rectangle {
             id: dayRectangle
 
-            width: borderRectangle.width
-            height: borderRectangle.height
+            width: formattedDayLabel.width + JamiTheme.dayTimestampVPadding
+            height: formattedDayLabel.height + JamiTheme.dayTimestampHPadding
             radius: 5
             color: JamiTheme.chatviewBgColor
             Layout.fillHeight: true
             anchors.centerIn: parent
 
-            Rectangle {
-                id: borderRectangle
-
-                border { color:  JamiTheme.timestampColor; width: 1}
-                opacity: detailsOpacity
-                width: formattedDayLabel.width + JamiTheme.dayTimestampVPadding
-                height: formattedDayLabel.height + JamiTheme.dayTimestampHPadding
-                radius: dayRectangle.radius
-                color: JamiTheme.transparentColor
-            }
+            border { color:  JamiTheme.timestampColor; width: 1 }
 
             Text {
                 id: formattedDayLabel
@@ -97,10 +94,10 @@ ColumnLayout{
         text: formattedTime
         Layout.bottomMargin: JamiTheme.timestampBottomMargin
         Layout.topMargin: JamiTheme.timestampTopMargin
-        Layout.alignment: Qt.AlignHCenter
+        Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
         color: JamiTheme.timestampColor
-        visible: showTime
-        height: visible * implicitHeight
+        visible: showTime || showDay
+        Layout.preferredHeight: visible * implicitHeight
         font.pointSize: JamiTheme.timestampFont
     }
 }
diff --git a/src/app/constant/JamiTheme.qml b/src/app/constant/JamiTheme.qml
index 421367575..f80e128f9 100644
--- a/src/app/constant/JamiTheme.qml
+++ b/src/app/constant/JamiTheme.qml
@@ -328,9 +328,10 @@ Item {
 
     //TimestampInfo
     property int timestampLinePadding: 40
-    property int dayTimestampTopMargin: 30
-    property int timestampBottomMargin: 42
-    property int timestampTopMargin: 20
+    property int dayTimestampTopMargin: 8
+    property int dayTimestampBottomMargin: 8
+    property int timestampBottomMargin: 16
+    property int timestampTopMargin: 16
     property int dayTimestampHPadding: 16
     property real dayTimestampVPadding: 32
     property real timestampFont: calcSize(12)
-- 
GitLab