Display 3-word names even for known contacts (and for yourself).

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
Igor Mandrigin 2018-10-04 12:01:35 +02:00
parent f4eff839ce
commit 42951c7a67
No known key found for this signature in database
GPG Key ID: 4A0EDDE26E66BC8B
6 changed files with 34 additions and 13 deletions

View File

@ -10,6 +10,7 @@
[status-im.ui.screens.chat.input.suggestions :as suggestions] [status-im.ui.screens.chat.input.suggestions :as suggestions]
[status-im.ui.screens.chat.input.validation-messages :as validation-messages] [status-im.ui.screens.chat.input.validation-messages :as validation-messages]
[status-im.ui.screens.chat.photos :as photos] [status-im.ui.screens.chat.photos :as photos]
[status-im.ui.screens.chat.utils :as chat-utils]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.ui.components.animation :as animation] [status-im.ui.components.animation :as animation]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
@ -108,10 +109,7 @@
(letsubs [username [:get-contact-name-by-identity from] (letsubs [username [:get-contact-name-by-identity from]
current-public-key [:get-current-public-key]] current-public-key [:get-current-public-key]]
[react/view {:style style/reply-message-content} [react/view {:style style/reply-message-content}
[react/text {:style style/reply-message-author} (or (and (= from current-public-key) [react/text {:style style/reply-message-author} (chat-utils/format-reply-author from username current-public-key)]
(i18n/label :t/You))
username
(gfycat/generate-gfy from))]
[react/text {:style message-style/style-message-text} message-text]])) [react/text {:style message-style/style-message-text} message-text]]))
(defview reply-message-view [] (defview reply-message-view []

View File

@ -15,6 +15,7 @@
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.ui.components.chat-icon.screen :as chat-icon.screen] [status-im.ui.components.chat-icon.screen :as chat-icon.screen]
[status-im.utils.core :as utils] [status-im.utils.core :as utils]
[status-im.ui.screens.chat.utils :as chat-utils]
[status-im.utils.identicon :as identicon] [status-im.utils.identicon :as identicon]
[status-im.utils.gfycat.core :as gfycat] [status-im.utils.gfycat.core :as gfycat]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
@ -171,10 +172,8 @@
[react/view {:style (style/quoted-message-container outgoing)} [react/view {:style (style/quoted-message-container outgoing)}
[react/view {:style style/quoted-message-author-container} [react/view {:style style/quoted-message-author-container}
[vector-icons/icon :icons/reply {:color (if outgoing colors/wild-blue-yonder colors/gray)}] [vector-icons/icon :icons/reply {:color (if outgoing colors/wild-blue-yonder colors/gray)}]
[react/text {:style (style/quoted-message-author outgoing)} (or (and (= from current-public-key) [react/text {:style (style/quoted-message-author outgoing)}
(i18n/label :t/You)) (chat-utils/format-reply-author from username current-public-key)]]
username
(gfycat/generate-gfy from))]]
[react/text {:style (style/quoted-message-text outgoing) [react/text {:style (style/quoted-message-text outgoing)
:number-of-lines 5} :number-of-lines 5}
text]])) text]]))
@ -328,9 +327,8 @@
(defview message-author-name [from message-username] (defview message-author-name [from message-username]
(letsubs [username [:get-contact-name-by-identity from]] (letsubs [username [:get-contact-name-by-identity from]]
[react/text {:style style/message-author-name} (or username [react/text {:style style/message-author-name}
message-username (chat-utils/format-author from (or username message-username))]))
(gfycat/generate-gfy from))])) ; TODO: We defensively generate the name for now, to be revisited when new protocol is defined
(defn message-body (defn message-body
[{:keys [last-in-group? [{:keys [last-in-group?

View File

@ -0,0 +1,12 @@
(ns status-im.ui.screens.chat.utils
(:require [status-im.utils.gfycat.core :as gfycat]
[status-im.i18n :as i18n]))
(defn format-author [from username]
(str (when username (str username " :: "))
(gfycat/generate-gfy from))) ; TODO: We defensively generate the name for now, to be revisited when new protocol is defined
(defn format-reply-author [from username current-public-key]
(or (and (= from current-public-key) (i18n/label :t/You))
(format-author from username)))

View File

@ -8,6 +8,7 @@
[status-im.utils.gfycat.core :as gfycat.core] [status-im.utils.gfycat.core :as gfycat.core]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[reagent.core :as reagent] [reagent.core :as reagent]
[status-im.ui.screens.chat.utils :as chat-utils]
[status-im.utils.gfycat.core :as gfycat] [status-im.utils.gfycat.core :as gfycat]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.utils.identicon :as identicon] [status-im.utils.identicon :as identicon]
@ -69,7 +70,7 @@
(views/defview message-author-name [{:keys [outgoing from] :as message}] (views/defview message-author-name [{:keys [outgoing from] :as message}]
(views/letsubs [current-account [:get-current-account] (views/letsubs [current-account [:get-current-account]
incoming-name [:get-contact-name-by-identity from]] incoming-name [:get-contact-name-by-identity from]]
(let [name (or incoming-name (gfycat/generate-gfy from))] (let [name (chat-utils/format-author from incoming-name)]
[react/touchable-highlight {:on-press #(re-frame/dispatch [:show-contact-dialog from name (boolean incoming-name)])} [react/touchable-highlight {:on-press #(re-frame/dispatch [:show-contact-dialog from name (boolean incoming-name)])}
[react/text {:style styles/author} name]]))) [react/text {:style styles/author} name]])))

View File

@ -21,6 +21,12 @@
:ios {:letter-spacing -0.2} :ios {:letter-spacing -0.2}
:android {:color colors/black}}) :android {:color colors/black}})
(defstyle profile-three-words
{:font-size 12
:text-align :center
:ios {:letter-spacing -0.2}
:android {:color colors/black}})
(defstyle profile-name-input-text (defstyle profile-name-input-text
{:font-size 15 {:font-size 15
:text-align :center :text-align :center

View File

@ -7,6 +7,7 @@
[status-im.ui.components.common.common :as common] [status-im.ui.components.common.common :as common]
[status-im.ui.components.icons.vector-icons :as vector-icons] [status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im.utils.gfycat.core :as gfy]
[status-im.ui.components.list-selection :as list-selection] [status-im.ui.components.list-selection :as list-selection]
[status-im.ui.screens.profile.components.styles :as styles])) [status-im.ui.screens.profile.components.styles :as styles]))
@ -38,7 +39,12 @@
[react/text {:style styles/profile-name-text [react/text {:style styles/profile-name-text
:font :medium :font :medium
:number-of-lines 1} :number-of-lines 1}
name]]]) name]
(when (:public-key contact)
[react/text {:style styles/profile-three-words
:font :medium
:number-of-lines 1}
(gfy/generate-gfy (:public-key contact))])]])
(defn- profile-header-edit [{:keys [name group-chat] :as contact} (defn- profile-header-edit [{:keys [name group-chat] :as contact}
icon-options on-change-text-event allow-icon-change?] icon-options on-change-text-event allow-icon-change?]