|
| 1 | + |
1 | 2 | (ns status-im.ui.screens.desktop.main.chat.views |
2 | 3 | (:require-macros [status-im.utils.views :as views]) |
3 | 4 | (:require [re-frame.core :as re-frame] |
|
10 | 11 | [status-im.constants :as constants] |
11 | 12 | [status-im.utils.identicon :as identicon] |
12 | 13 | [status-im.utils.datetime :as time] |
| 14 | + [status-im.utils.utils :as utils] |
13 | 15 | [status-im.ui.components.react :as react] |
14 | 16 | [status-im.ui.components.colors :as colors] |
15 | 17 | [status-im.chat.views.message.datemark :as message.datemark] |
|
18 | 20 | [status-im.ui.screens.desktop.main.chat.styles :as styles] |
19 | 21 | [status-im.i18n :as i18n])) |
20 | 22 |
|
21 | | -(views/defview toolbar-chat-view [] |
22 | | - (views/letsubs [{:keys [chat-id public-key public? group-chat color]} [:get-current-chat] |
23 | | - {:keys [pending? whisper-identity photo-path]} [:get-current-chat-contact] |
24 | | - current-chat-name [:get-current-chat-name]] |
| 23 | +(views/defview toolbar-chat-view [{:keys [chat-id color public-key public? group-chat] |
| 24 | + :as current-chat}] |
| 25 | + (views/letsubs [photo-path [:get-chat-photo chat-id] |
| 26 | + chat-name [:get-current-chat-name] |
| 27 | + {:keys [pending? whisper-identity]} [:get-current-chat-contact]] |
25 | 28 | [react/view {:style styles/toolbar-chat-view} |
26 | | - [react/view {:style {:flex-direction :row |
27 | | - :align-items :center}} |
28 | | - |
29 | | - [react/view {:style styles/img-container} |
30 | | - (if public? |
31 | | - [react/view {:style (styles/topic-image color)} |
32 | | - [react/text {:style styles/topic-text} |
33 | | - (string/capitalize (first current-chat-name))]] |
34 | | - [react/image {:style styles/photo-style-toolbar |
35 | | - :source {:uri photo-path}}])] |
36 | | - |
37 | | - [react/view |
38 | | - [react/text {:style styles/toolbar-chat-name} current-chat-name] |
39 | | - (when pending? |
40 | | - [react/touchable-highlight |
41 | | - {:on-press #(re-frame/dispatch [:add-contact whisper-identity])} |
42 | | - [react/view {:style styles/add-contact} |
43 | | - [react/text {:style styles/add-contact-text} |
44 | | - (i18n/label :t/add-to-contacts)]]])] |
| 29 | + [react/view {:style {:flex-direction :row |
| 30 | + :flex 1}} |
| 31 | + (if public? |
| 32 | + [react/view {:style (styles/topic-image color)} |
| 33 | + [react/text {:style styles/topic-text} |
| 34 | + (string/capitalize (second chat-name))]] |
| 35 | + [react/image {:style styles/chat-icon |
| 36 | + :source {:uri photo-path}}]) |
| 37 | + [react/view {:style (styles/chat-title-and-type pending?)} |
| 38 | + [react/text {:style styles/chat-title} |
| 39 | + chat-name] |
| 40 | + (cond pending? |
| 41 | + [react/text {:style styles/add-contact-text |
| 42 | + :on-press #(re-frame/dispatch [:add-contact whisper-identity])} |
| 43 | + (i18n/label :t/add-to-contacts)] |
| 44 | + public? |
| 45 | + [react/text {:style styles/public-chat-text} |
| 46 | + (i18n/label :t/public-chat)])]] |
| 47 | + [react/view |
45 | 48 | (when (and (not group-chat) (not public?)) |
46 | | - [react/text {:style {:position :absolute |
47 | | - :right 20} |
| 49 | + [react/text {:style (styles/profile-actions-text colors/black) |
48 | 50 | :on-press #(re-frame/dispatch [:navigate-to :chat-profile])} |
49 | | - (i18n/label :t/view-profile)])]])) |
| 51 | + (i18n/label :t/view-profile)]) |
| 52 | + |
| 53 | + [react/text {:style (styles/profile-actions-text colors/red) |
| 54 | + :on-press (fn [] |
| 55 | + (utils/show-confirmation (i18n/label :clear-history-confirmation) |
| 56 | + "" |
| 57 | + (i18n/label :clear-history-action) |
| 58 | + #(re-frame/dispatch [:clear-history])))} |
| 59 | + (i18n/label :t/clear-history)] |
| 60 | + [react/text {:style (styles/profile-actions-text colors/red) |
| 61 | + :on-press (fn [] |
| 62 | + (utils/show-confirmation (i18n/label :delete-chat-confirmation) |
| 63 | + "" |
| 64 | + (i18n/label :delete-chat-action) |
| 65 | + #(re-frame/dispatch [:remove-chat-and-navigate-home chat-id])))} |
| 66 | + (i18n/label :t/delete-chat)]]])) |
50 | 67 |
|
51 | 68 | (views/defview message-author-name [{:keys [outgoing from] :as message}] |
52 | 69 | (views/letsubs [current-account [:get-current-account] |
|
56 | 73 | [react/text {:style styles/author} name]]))) |
57 | 74 |
|
58 | 75 | (views/defview member-photo [from] |
59 | | - [react/view |
60 | | - [react/image {:source {:uri (identicon/identicon from)} |
61 | | - :style styles/photo-style}]]) |
| 76 | + (letsubs [photo-path [:get-photo-path from]] |
| 77 | + [react/image {:source {:uri (if (string/blank? photo-path) |
| 78 | + (identicon/identicon from) |
| 79 | + photo-path)} |
| 80 | + :style styles/photo-style}])) |
62 | 81 |
|
63 | 82 | (views/defview my-photo [from] |
64 | 83 | (views/letsubs [account [:get-current-account]] |
|
188 | 207 | (views/defview chat-view [] |
189 | 208 | (views/letsubs [current-chat [:get-current-chat]] |
190 | 209 | [react/view {:style styles/chat-view} |
191 | | - [toolbar-chat-view] |
| 210 | + [toolbar-chat-view current-chat] |
192 | 211 | [messages-view current-chat] |
193 | 212 | [chat-text-input]])) |
194 | 213 |
|
|
0 commit comments