Prevent overflowing of chat name and message preview in the Chat List (#16210)

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
This commit is contained in:
Mohamed Javid 2023-06-10 00:06:38 +08:00 committed by GitHub
parent d5c7f0261e
commit 9376da6c5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 16 deletions

View File

@ -152,10 +152,9 @@
(preview-text-from-content group-chat primary-name message)))] (preview-text-from-content group-chat primary-name message)))]
[quo/text [quo/text
{:size :paragraph-2 {:size :paragraph-2
:style {:color (colors/theme-colors colors/neutral-50 :style {:color (colors/theme-colors colors/neutral-50
colors/neutral-40) colors/neutral-40)
:flex 1 :flex 1}
:margin-right 20}
:number-of-lines 1 :number-of-lines 1
:ellipsize-mode :tail :ellipsize-mode :tail
:accessibility-label :chat-message-text} :accessibility-label :chat-message-text}
@ -179,10 +178,15 @@
(defn name-view (defn name-view
[display-name contact timestamp] [display-name contact timestamp]
[rn/view {:style {:flex-direction :row}} [rn/view
{:style {:flex 1
:flex-direction :row}}
[quo/text [quo/text
{:weight :semi-bold {:weight :semi-bold
:accessibility-label :chat-name-text} :accessibility-label :chat-name-text
:style {:flex-shrink 1}
:number-of-lines 1
:ellipsize-mode :tail}
display-name] display-name]
[verified-or-contact-icon contact] [verified-or-contact-icon contact]
[quo/text [quo/text
@ -209,11 +213,12 @@
[{:keys [chat-id group-chat color name unviewed-messages-count [{:keys [chat-id group-chat color name unviewed-messages-count
timestamp last-message muted] timestamp last-message muted]
:as item}] :as item}]
(let [display-name (if group-chat (let [display-name (if group-chat
name name
(first (rf/sub [:contacts/contact-two-names-by-identity chat-id]))) (first (rf/sub [:contacts/contact-two-names-by-identity chat-id])))
contact (when-not group-chat contact (when-not group-chat
(rf/sub [:contacts/contact-by-address chat-id]))] (rf/sub [:contacts/contact-by-address chat-id]))
show-unread-badge? (and (not muted) (> unviewed-messages-count 0))]
[rn/touchable-opacity [rn/touchable-opacity
{:style (style/container) {:style (style/container)
:on-press (open-chat chat-id) :on-press (open-chat chat-id)
@ -224,10 +229,14 @@
:chat-id chat-id :chat-id chat-id
:full-name display-name :full-name display-name
:color color}] :color color}]
[rn/view {:style {:margin-left 8}} [rn/view
{:style {:flex 1
:margin-left 8
:margin-right (if show-unread-badge? 36 0)}}
[name-view display-name contact timestamp] [name-view display-name contact timestamp]
[last-message-preview group-chat last-message]] [last-message-preview group-chat last-message]]
(when-not muted (when show-unread-badge?
(when (> unviewed-messages-count 0) [quo/info-count
[quo/info-count {:style {:top 16}} {:style {:top 16
unviewed-messages-count]))])) :right 16}}
unviewed-messages-count])]))