Skip to content

Commit 647dfc7

Browse files
Reply component in chat input & quoted message redesign
Signed-off-by: Brian Sztamfater <brian@status.im>
1 parent a08c7ff commit 647dfc7

File tree

11 files changed

+169
-108
lines changed

11 files changed

+169
-108
lines changed

resources/images/icons/close12@2x.png

335 Bytes
Loading

resources/images/icons/close12@3x.png

468 Bytes
Loading
628 Bytes
Loading
897 Bytes
Loading

src/status_im/ui/screens/chat/components/edit.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[rn/view {:style {:flex-direction :row}}
1717
[rn/view {}
1818
[icons/icon :tiny-icons/tiny-edit {:container-style {:margin-top 5}}]]
19-
[rn/view {:style (styles/reply-content)}
19+
[rn/view {:style (styles/reply-content-old)}
2020
[quo/text {:weight :medium
2121
:number-of-lines 1}
2222
(i18n/label :t/editing-message)]]

src/status_im/ui/screens/chat/components/reply.cljs

+83-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
[status-im.ethereum.stateofus :as stateofus]
1010
[status-im.ui.screens.chat.components.style :as styles]
1111
[re-frame.core :as re-frame]
12-
[clojure.string :as string]))
12+
[clojure.string :as string]
13+
[quo2.foundations.colors :as quo2.colors :refer [theme-colors]]
14+
[quo2.components.button :as quo2.button]
15+
[quo2.components.text :as quo2.text]
16+
[status-im.ui.screens.chat.photos :as photos]
17+
[status-im.constants :as constants]))
1318

1419
(def ^:private reply-symbol "")
1520

1621
(defn input-focus [text-input-ref]
1722
(some-> ^js (quo.react/current-ref text-input-ref) .focus))
1823

19-
(defn format-author [contact-name]
24+
(defn format-author-old [contact-name]
2025
(let [author (if (or (= (aget contact-name 0) "@")
2126
;; in case of replies
2227
(= (aget contact-name 1) "@"))
@@ -25,10 +30,24 @@
2530
contact-name)]
2631
(i18n/label :replying-to {:author author})))
2732

28-
(defn format-reply-author [from username current-public-key]
33+
(defn format-author [contact-name]
34+
(let [author (if (or (= (aget contact-name 0) "@")
35+
;; in case of replies
36+
(= (aget contact-name 1) "@"))
37+
(or (stateofus/username contact-name)
38+
(subs contact-name 0 81))
39+
contact-name)]
40+
author))
41+
42+
(defn format-reply-author-old [from username current-public-key]
2943
(or (and (= from current-public-key)
3044
(str reply-symbol (i18n/label :t/You)))
31-
(str reply-symbol (format-author username))))
45+
(str reply-symbol (format-author-old username))))
46+
47+
(defn format-reply-author [from username current-public-key]
48+
(or (and (= from current-public-key)
49+
(i18n/label :t/You))
50+
(format-author username)))
3251

3352
(defn get-quoted-text-with-mentions [parsed-text]
3453
(string/join
@@ -47,21 +66,62 @@
4766
literal))
4867
parsed-text)))
4968

50-
(defn reply-message [{:keys [from]}]
69+
(defn reply-message-old [{:keys [from]}]
5170
(let [contact-name @(re-frame/subscribe [:contacts/contact-name-by-identity from])
5271
current-public-key @(re-frame/subscribe [:multiaccount/public-key])]
5372
[rn/view {:style {:flex-direction :row}}
54-
[rn/view {:style (styles/reply-content)}
73+
[rn/view {:style (styles/reply-content-old)}
5574
[quo/text {:weight :medium
5675
:number-of-lines 1
5776
:style {:line-height 18}}
58-
(format-reply-author from contact-name current-public-key)]]
77+
(format-reply-author-old from contact-name current-public-key)]]
5978
[rn/view
6079
[pressable/pressable {:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply])
6180
:accessibility-label :cancel-message-reply}
6281
[icons/icon :main-icons/close-circle {:container-style (styles/close-button)
6382
:color (:icon-02 @quo.colors/theme)}]]]]))
6483

84+
(defn reply-message [{:keys [from identicon content-type contentType parsed-text content]} in-chat-input?]
85+
(let [contact-name @(re-frame/subscribe [:contacts/contact-name-by-identity from])
86+
current-public-key @(re-frame/subscribe [:multiaccount/public-key])
87+
content-type (or content-type contentType)]
88+
[rn/view {:style {:flex-direction :row :height 24}}
89+
[rn/view {:style (styles/reply-content)}
90+
[icons/icon :main-icons/connector {:color (theme-colors quo2.colors/neutral-40 quo2.colors/neutral-60)
91+
:container-style {:position :absolute :left 10 :bottom -4 :width 16 :height 16}}]
92+
[rn/view {:style {:position :absolute :left 34 :right 54 :top 3 :flex-direction :row :align-items :center}}
93+
[photos/member-photo from identicon 16]
94+
[quo2.text/text {:weight :semi-bold
95+
:size :paragraph-2
96+
:number-of-lines 1
97+
:style {:margin-left 4}}
98+
(format-reply-author from contact-name current-public-key)]
99+
[quo2.text/text {:number-of-lines 1
100+
:size :label
101+
:weight :regular
102+
:style (merge {:ellipsize-mode :tail
103+
:text-transform :none
104+
:margin-left 4
105+
:margin-top 2}
106+
(when (or (= constants/content-type-image content-type)
107+
(= constants/content-type-sticker content-type)
108+
(= constants/content-type-audio content-type))
109+
{:color (theme-colors quo2.colors/neutral-50 quo2.colors/neutral-40)}))}
110+
(case (or content-type contentType)
111+
constants/content-type-image "Image"
112+
constants/content-type-sticker "Sticker"
113+
constants/content-type-audio "Audio"
114+
(get-quoted-text-with-mentions (or parsed-text (:parsed-text content))))]]]
115+
(when in-chat-input?
116+
[quo2.button/button {:width 24
117+
:size 24
118+
:type :outline
119+
:accessibility-label :reply-cancel-button
120+
:on-press #(re-frame/dispatch [:chat.ui/cancel-message-reply])}
121+
[icons/icon :main-icons/close {:width 16
122+
:height 16
123+
:color (theme-colors quo2.colors/black quo2.colors/neutral-40)}]])]))
124+
65125
(defn send-image [images]
66126
[rn/view {:style (styles/reply-container-image)}
67127
[rn/scroll-view {:horizontal true
@@ -86,12 +146,27 @@
86146
(when reply
87147
(js/setTimeout #(input-focus text-input-ref) 250))))
88148

149+
(defn reply-message-wrapper-old [reply]
150+
[rn/view {:style {:padding-horizontal 15
151+
:border-top-width 1
152+
:border-top-color (:ui-01 @quo.colors/theme)
153+
:padding-vertical 8}}
154+
[reply-message-old reply]])
155+
89156
(defn reply-message-wrapper [reply]
90157
[rn/view {:style {:padding-horizontal 15
91158
:border-top-width 1
92159
:border-top-color (:ui-01 @quo.colors/theme)
93160
:padding-vertical 8}}
94-
[reply-message reply]])
161+
[reply-message reply true]])
162+
163+
(defn reply-message-auto-focus-wrapper-old [text-input-ref]
164+
(let [had-reply (atom nil)]
165+
(fn []
166+
(let [reply @(re-frame/subscribe [:chats/reply-message])]
167+
(focus-input-on-reply reply had-reply text-input-ref)
168+
(when reply
169+
[reply-message-wrapper-old reply])))))
95170

96171
(defn reply-message-auto-focus-wrapper [text-input-ref]
97172
(let [had-reply (atom nil)]

src/status_im/ui/screens/chat/components/style.cljs

+6-1
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,16 @@
8787
(defn reply-container []
8888
{:flex-direction :row})
8989

90-
(defn reply-content []
90+
(defn reply-content-old []
9191
{:padding-vertical 6
9292
:padding-horizontal 10
9393
:flex 1})
9494

95+
(defn reply-content []
96+
{:padding-horizontal 10
97+
:flex 1
98+
:flex-direction :row})
99+
95100
(defn contact-request-content []
96101
{:flex 1
97102
:flex-direction :row

src/status_im/ui/screens/chat/message/message.cljs

+66-87
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,9 @@
8787
timestamp-str]])))
8888

8989
(defview quoted-message
90-
[_ {:keys [from parsed-text image]} current-public-key public? pinned]
91-
(letsubs [contact-name [:contacts/contact-name-by-identity from]]
92-
[react/view {:style (style/quoted-message-container)}
93-
[react/view {:style style/quoted-message-author-container}
94-
[chat.utils/format-reply-author
95-
from
96-
contact-name
97-
current-public-key
98-
(partial style/quoted-message-author (not pinned))
99-
false]]
100-
(if (and image
101-
;; Disabling images for public-chats
102-
(not public?))
103-
[fast-image/fast-image {:style {:width 56
104-
:height 56
105-
:background-color :black
106-
:border-radius 4}
107-
:source {:uri image}}]
108-
[react/text {:style (style/quoted-message-text)
109-
:number-of-lines 5}
110-
(components.reply/get-quoted-text-with-mentions parsed-text)])]))
90+
[_ reply]
91+
[react/view {:style (style/quoted-message-container)}
92+
[components.reply/reply-message reply false]])
11193

11294
(defn render-inline [message-text content-type acc {:keys [type literal destination]}]
11395
(case type
@@ -312,37 +294,40 @@
312294
identicon
313295
from in-popover? timestamp-str]
314296
:as message} content {:keys [modal close-modal]}]
315-
[react/view {:style (style/message-wrapper message)
316-
:pointer-events :box-none
317-
:accessibility-label :chat-item}
318-
[react/view {:style (style/message-body)
319-
:pointer-events :box-none}
320-
[react/view (style/message-author-userpic)
321-
(when last-in-group?
322-
[react/touchable-highlight {:on-press #(do (when modal (close-modal))
323-
(re-frame/dispatch [:chat.ui/show-profile from]))}
324-
[photos/member-photo from identicon]])]
325-
[react/view {:style (style/message-author-wrapper)}
326-
(when last-in-group?
327-
[react/view {:style {:flex-direction :row :align-items :center}}
328-
[react/touchable-opacity {:style style/message-author-touchable
329-
:disabled in-popover?
330-
:on-press #(do (when modal (close-modal))
331-
(re-frame/dispatch [:chat.ui/show-profile from]))}
332-
[message-author-name from {:modal modal}]]
333-
[react/text
334-
{:style (merge
335-
{:padding-left 5
336-
:margin-top 2}
337-
(style/message-timestamp-text))
338-
:accessibility-label :message-timestamp}
339-
timestamp-str]])
297+
(let [response-to (:response-to (:content message))]
298+
[react/view {:style (style/message-wrapper message)
299+
:pointer-events :box-none
300+
:accessibility-label :chat-item}
301+
(when (and (seq response-to) (:quoted-message message))
302+
[quoted-message response-to (:quoted-message message)])
303+
[react/view {:style (style/message-body)
304+
:pointer-events :box-none}
305+
[react/view (style/message-author-userpic)
306+
(when (or (and (seq response-to) (:quoted-message message)) last-in-group?)
307+
[react/touchable-highlight {:on-press #(do (when modal (close-modal))
308+
(re-frame/dispatch [:chat.ui/show-profile from]))}
309+
[photos/member-photo from identicon]])]
310+
[react/view {:style (style/message-author-wrapper)}
311+
(when (or (and (seq response-to) (:quoted-message message)) last-in-group?)
312+
[react/view {:style {:flex-direction :row :align-items :center}}
313+
[react/touchable-opacity {:style style/message-author-touchable
314+
:disabled in-popover?
315+
:on-press #(do (when modal (close-modal))
316+
(re-frame/dispatch [:chat.ui/show-profile from]))}
317+
[message-author-name from {:modal modal}]]
318+
[react/text
319+
{:style (merge
320+
{:padding-left 5
321+
:margin-top 2}
322+
(style/message-timestamp-text))
323+
:accessibility-label :message-timestamp}
324+
timestamp-str]])
340325
;;MESSAGE CONTENT
341-
content
342-
[link-preview/link-preview-wrapper (:links (:content message)) false false]]]
326+
content
327+
[link-preview/link-preview-wrapper (:links (:content message)) false false]]]
343328
; delivery status
344-
[react/view (style/delivery-status)
345-
[message-delivery-status message]]])
329+
[react/view (style/delivery-status)
330+
[message-delivery-status message]]]))
346331

347332
(def image-max-width 260)
348333
(def image-max-height 192)
@@ -449,7 +434,7 @@
449434
(defn collapsible-text-message [_ _]
450435
(let [collapsed? (reagent/atom false)
451436
show-timestamp? (reagent/atom false)]
452-
(fn [{:keys [content current-public-key public? pinned in-popover?] :as message} on-long-press modal]
437+
(fn [{:keys [content in-popover?] :as message} on-long-press modal]
453438
[react/touchable-highlight
454439
(when-not modal
455440
{:on-press (fn [_]
@@ -466,11 +451,8 @@
466451
[message-timestamp message show-timestamp?]
467452
[react/view {:style (style/message-view message)}
468453
[react/view {:style (style/message-view-content)}
469-
(let [response-to (:response-to content)]
470-
[react/view
471-
(when (and (seq response-to) (:quoted-message message))
472-
[quoted-message response-to (:quoted-message message) current-public-key public? pinned])
473-
[render-parsed-text-with-message-status message (:parsed-text content)]])]]]])))
454+
[react/view
455+
[render-parsed-text-with-message-status message (:parsed-text content)]]]]]])))
474456

475457
(defmethod ->message constants/content-type-text
476458
[message {:keys [on-long-press modal] :as reaction-picker}]
@@ -494,39 +476,36 @@
494476

495477
(defmethod ->message constants/content-type-emoji []
496478
(let [show-timestamp? (reagent/atom false)]
497-
(fn [{:keys [content current-public-key outgoing public? pinned in-popover? message-pin-enabled] :as message}
479+
(fn [{:keys [content pinned in-popover? message-pin-enabled] :as message}
498480
{:keys [on-long-press modal]
499481
:as reaction-picker}]
500-
(let [response-to (:response-to content)]
501-
[message-content-wrapper message
502-
[react/touchable-highlight (when-not modal
503-
{:disabled in-popover?
504-
:on-press (fn []
505-
(react/dismiss-keyboard!)
506-
(reset! show-timestamp? true))
507-
:delay-long-press 100
508-
:on-long-press (fn []
509-
(on-long-press
510-
(concat
511-
[{:on-press #(re-frame/dispatch [:chat.ui/reply-to-message message])
512-
:id :reply
513-
:label (i18n/label :t/message-reply)}
514-
{:on-press #(react/copy-to-clipboard (get content :text))
515-
:id :copy
516-
:label (i18n/label :t/sharing-copy-to-clipboard)}]
517-
(when message-pin-enabled [{:on-press #(pin-message message)
518-
:label (if pinned (i18n/label :t/unpin) (i18n/label :t/pin))}]))))})
519-
[react/view style/message-view-wrapper
520-
[message-timestamp message show-timestamp?]
521-
[react/view (style/message-view message)
522-
[react/view {:style (style/message-view-content)}
523-
[react/view {:style (style/style-message-text)}
524-
(when (and (seq response-to) (:quoted-message message))
525-
[quoted-message response-to (:quoted-message message) outgoing current-public-key public? pinned])
526-
[react/text {:style (style/emoji-message message)}
527-
(:text content)]]
528-
[message-status message]]]]]
529-
reaction-picker]))))
482+
[message-content-wrapper message
483+
[react/touchable-highlight (when-not modal
484+
{:disabled in-popover?
485+
:on-press (fn []
486+
(react/dismiss-keyboard!)
487+
(reset! show-timestamp? true))
488+
:delay-long-press 100
489+
:on-long-press (fn []
490+
(on-long-press
491+
(concat
492+
[{:on-press #(re-frame/dispatch [:chat.ui/reply-to-message message])
493+
:id :reply
494+
:label (i18n/label :t/message-reply)}
495+
{:on-press #(react/copy-to-clipboard (get content :text))
496+
:id :copy
497+
:label (i18n/label :t/sharing-copy-to-clipboard)}]
498+
(when message-pin-enabled [{:on-press #(pin-message message)
499+
:label (if pinned (i18n/label :t/unpin) (i18n/label :t/pin))}]))))})
500+
[react/view style/message-view-wrapper
501+
[message-timestamp message show-timestamp?]
502+
[react/view (style/message-view message)
503+
[react/view {:style (style/message-view-content)}
504+
[react/view {:style (style/style-message-text)}
505+
[react/text {:style (style/emoji-message message)}
506+
(:text content)]]
507+
[message-status message]]]]]
508+
reaction-picker])))
530509

531510
(defmethod ->message constants/content-type-sticker
532511
[{:keys [content from outgoing in-popover?]

src/status_im/ui/screens/chat/photos.cljs

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
2424
[memo-photo-rend photo-path size accessibility-label (colors/dark?)])
2525

2626
;; We optionally pass identicon for perfomance reason, so it does not have to be calculated for each message
27-
(defn member-photo [pub-key identicon]
28-
(let [path @(re-frame/subscribe [:chats/photo-path pub-key identicon])]
29-
[photo path {:size style/default-size
30-
:accessibility-label :member-photo}]))
27+
(defn member-photo
28+
([pub-key]
29+
(member-photo pub-key nil))
30+
([pub-key identicon]
31+
(member-photo pub-key identicon style/default-size))
32+
([pub-key identicon size]
33+
(let [path @(re-frame/subscribe [:chats/photo-path pub-key identicon])]
34+
[photo path {:size size
35+
:accessibility-label :member-photo}])))
3136

3237
(defn account-photo [account]
3338
(let [path (multiaccounts/displayed-photo account)]

src/status_im/ui/screens/chat/styles/message/message.cljs

+3-6
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,9 @@
209209
:text-align-vertical :center})
210210

211211
(defn quoted-message-container []
212-
{:margin-bottom 6
213-
:padding-bottom 6
214-
:border-bottom-color colors/black-transparent
215-
:border-bottom-width 2
216-
:border-bottom-left-radius 2
217-
:border-bottom-right-radius 2})
212+
{:margin-bottom 6
213+
:margin-top 5
214+
:padding-horizontal 15})
218215

219216
(def quoted-message-author-container
220217
{:flex-direction :row

0 commit comments

Comments
 (0)