Truncate chat name

Former-commit-id: c3496957ff
This commit is contained in:
virvar 2016-05-20 16:36:00 +03:00
parent 615cc4d73a
commit 585baa9d71
3 changed files with 10 additions and 7 deletions

View File

@ -13,6 +13,7 @@
chat-icon-view-menu-item]]
[status-im.chat.styles.screen :as st]
[status-im.utils.listview :refer [to-datasource]]
[status-im.utils.utils :refer [truncate-str]]
[status-im.components.invertible-scroll-view :refer [invertible-scroll-view]]
[status-im.components.toolbar :refer [toolbar]]
[status-im.chat.views.message :refer [chat-message]]
@ -99,11 +100,7 @@
[chat-icon-view-menu-item chat-id group-chat name color true])
(defn members-text [members]
(let [max 35
text (str (s/join ", " (map #(:name %) members)) " and you")]
(if (< max (count text))
(str (subs text 0 (- max 3)) "...")
text)))
(truncate-str (str (s/join ", " (map #(:name %) members)) " and you") 35))
(defn actions-list-view []
(let [{:keys [group-chat chat-id]}
@ -182,7 +179,7 @@
(fn []
[view (st/chat-name-view @show-actions)
[text {:style st/chat-name-text}
(or @name "Chat name")]
(truncate-str (or @name "Chat name") 30)]
(if @group-chat
[view {:flexDirection :row}
[icon :group st/group-icon]

View File

@ -3,6 +3,7 @@
(:require [status-im.components.react :refer [view image icon text]]
[status-im.components.chat-icon.screen :refer [chat-icon-view-chat-list]]
[status-im.chats-list.styles :as st]
[status-im.utils.utils :refer [truncate-str]]
[status-im.utils.datetime :as time]))
(defn chat-list-item-inner-view
@ -14,7 +15,7 @@
[chat-icon-view-chat-list chat-id group-chat name color online]]
[view st/item-container
[view st/name-view
[text {:style st/name-text} name]
[text {:style st/name-text} (truncate-str name 20)]
(when group-chat
[icon :group st/group-icon])
(when group-chat

View File

@ -47,3 +47,8 @@
(.catch (or on-error
(fn [error]
(toast (str error))))))))
(defn truncate-str [s max]
(if (< max (count s))
(str (subs s 0 (- max 3)) "...")
s))