diff --git a/src/quo2/components/avatars/user_avatar/view.cljs b/src/quo2/components/avatars/user_avatar/view.cljs index b265577293..78abd836e1 100644 --- a/src/quo2/components/avatars/user_avatar/view.cljs +++ b/src/quo2/components/avatars/user_avatar/view.cljs @@ -26,13 +26,14 @@ uses `ring-background` to display the ring behind the initials when given. Otherwise, shows the `profile-picture` which already comes with the ring drawn." [{:keys [full-name status-indicator? online? size profile-picture ring-background - customization-color static? muted? theme] + customization-color static? muted? theme ring?] :or {status-indicator? true online? true + ring? true size :big customization-color :turquoise}}] (let [full-name (or full-name "empty name") - draw-ring? (when-not muted? (and ring-background (valid-ring-sizes size))) + draw-ring? (and ring? (when-not muted? (and ring-background (valid-ring-sizes size)))) outer-styles (style/outer size) ;; Once image is loaded, fast image rerenders view with the help of reagent atom, ;; But dynamic updates don't work when user-avatar is used inside hole-view diff --git a/src/quo2/components/drawers/permission_context/style.cljs b/src/quo2/components/drawers/permission_context/style.cljs index f84808a853..842d218c0b 100644 --- a/src/quo2/components/drawers/permission_context/style.cljs +++ b/src/quo2/components/drawers/permission_context/style.cljs @@ -1,15 +1,17 @@ (ns quo2.components.drawers.permission-context.style - (:require [quo2.foundations.colors :as colors])) + (:require [quo2.foundations.colors :as colors] + [react-native.safe-area :as safe-area])) (def radius 20) -(def container + +(defn container + [] {:flex-direction :row :background-color (colors/theme-colors colors/white colors/neutral-90) - :height 82 - :padding-top 16 - :padding-bottom 48 + :padding-top 12 + :padding-bottom (+ 12 (safe-area/get-bottom)) :justify-content :center - :padding-right :auto + :padding-horizontal 20 :shadow-offset {:width 0 :height 2} :shadow-radius radius diff --git a/src/quo2/components/drawers/permission_context/view.cljs b/src/quo2/components/drawers/permission_context/view.cljs index 3e0a304e2f..14e3e9e0af 100644 --- a/src/quo2/components/drawers/permission_context/view.cljs +++ b/src/quo2/components/drawers/permission_context/view.cljs @@ -7,6 +7,6 @@ [children on-press] [rn/touchable-highlight {:on-press on-press - :underlay-color (colors/theme-colors :transparent colors/neutral-95-opa-70) - :style style/container} + :style (style/container) + :underlay-color (colors/theme-colors :transparent colors/neutral-95-opa-70)} children]) diff --git a/src/quo2/components/messages/system_message.cljs b/src/quo2/components/messages/system_message.cljs index 1bbb7e9f9a..fe2f123c1e 100644 --- a/src/quo2/components/messages/system_message.cljs +++ b/src/quo2/components/messages/system_message.cljs @@ -4,172 +4,172 @@ [quo2.components.markdown.text :as text] [quo2.components.messages.author.view :as author] [quo2.foundations.colors :as colors] - [quo2.theme :as theme] [react-native.core :as rn] - [react-native.reanimated :as reanimated])) + [utils.i18n :as i18n] + [quo2.theme :as quo.theme] + [clojure.string :as string])) -(def themes-landed - {:pinned colors/primary-50-opa-5 - :added colors/primary-50-opa-5 - :deleted colors/danger-50-opa-5}) +(defn text-color + [theme] + (colors/theme-colors colors/neutral-100 colors/white theme)) -(def themes - {:light {:text colors/neutral-100 - :time colors/neutral-50 - :bg {:default colors/white - :pressed colors/neutral-5 - :landed themes-landed}} - :dark {:text colors/white - :time colors/neutral-40 - :bg {:default colors/neutral-90 - :pressed colors/neutral-80 - :landed themes-landed}}}) - -(defn get-color - [& keys] - (reduce (fn [acc k] (get acc k (reduced acc))) - ((theme/get-theme) themes) - (vec keys))) - -(defn sm-timestamp - [timestamp-str] - [rn/view {:margin-left 8} - [text/text - {:size :label - :style {:color (get-color :time) - :text-transform :none}} - timestamp-str]]) +(defn time-color + [theme] + (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)) (defn sm-icon [{:keys [icon color opacity]}] [rn/view - {:align-items :center - :margin-right 8} + {:margin-right 8} [icon-avatar/icon-avatar {:size :medium :icon icon :color color :opacity opacity}]]) +(defn sm-timestamp + [timestamp] + [rn/view {:margin-left 8 :margin-top 2} + [text/text + {:size :label + :style {:color (time-color :time) + :text-transform :none}} + timestamp]]) + (defn sm-user-avatar - [image] + [display-name photo-path] [rn/view {:margin-right 4} [user-avatar/user-avatar - {:status-indicator? false - :online? false - :size :xxxs - :profile-picture image - :ring? false}]]) + {:size :xxxs + :full-name display-name + :profile-picture photo-path + :ring? false + :status-indicator? false}]]) -(defmulti system-message-content :type) +(defn split-text + [label theme add-pred?] + (let [color (text-color theme)] + [:<> + (when add-pred? + [text/text {} " "]) + (for [[indx item] (map-indexed vector (string/split label " "))] + ^{:key indx} + [text/text + {:size :paragraph-2 + :style {:color color + :margin-right 3}} + item])])) -(defmethod system-message-content :deleted - [{:keys [label timestamp-str labels child]}] +(defn system-message-base + [{:keys [icon timestamp]} child] [rn/view {:flex-direction :row - :flex 1 - :align-items :center} - [sm-icon - {:icon :main-icons/delete - :color :danger - :opacity 5}] + :flex 1} + [sm-icon icon] [rn/view - {:align-items :baseline + {:align-self :center :flex-direction :row - :flex 1 - :flex-wrap :wrap} - (if child - child - [text/text - {:size :paragraph-2 - :style {:color (get-color :text)}} - (or (get labels label) - label - (:message-deleted labels))]) - [sm-timestamp timestamp-str]]]) - -(defmethod system-message-content :added - [{:keys [state mentions timestamp-str labels]}] - [rn/view - {:align-items :center - :flex-direction :row} - [sm-icon - {:icon :main-icons/add-user - :color :primary - :opacity (if (= state :landed) 0 5)}] - [sm-user-avatar (:image (first mentions))] - [text/text - {:weight :semi-bold - :size :paragraph-2} - (:name (first mentions))] - [text/text - {:size :paragraph-2 - :style {:color (get-color :text) - :margin-left 3 - :margin-right 3}} - (:added labels)] - [sm-user-avatar (:image (second mentions))] - [text/text - {:weight :semi-bold - :size :paragraph-2} - (:name (second mentions))] - [sm-timestamp timestamp-str]]) - -(defmethod system-message-content :pinned - [{:keys [state pinned-by child timestamp-str labels]}] - [rn/view - {:flex-direction :row - :flex 1 - :align-items :center} - [sm-icon - {:icon :main-icons/pin - :color :primary - :opacity (if (= state :landed) 0 5)}] - [rn/view - {:flex-direction :column + :margin-right 40 ;; dirty hack, flexbox won't work as expected :flex 1} - [rn/view - {:align-items :baseline - :flex-direction :row - :flex 1 - :flex-wrap :wrap} - [author/author - {:primary-name pinned-by - :style {:margin-right 4}}] - [rn/view - [text/text - {:size :paragraph-2 - :style {:color (get-color :text)}} - (:pinned-a-message labels)]] - [sm-timestamp timestamp-str]] - (when child - child)]]) + child + [sm-timestamp timestamp]]]) -(defn- f-system-message - [{:keys [type style non-pressable? animate-landing? labels on-long-press] :as message}] - (let [sv-color (reanimated/use-shared-value - (get-color :bg (if animate-landing? :landed :default) type))] - (when animate-landing? - (reanimated/animate-shared-value-with-delay - sv-color - (get-color :bg :default type) - 0 - :linear - 1000)) - [reanimated/touchable-opacity - {:on-press #(when-not non-pressable? - (reanimated/set-shared-value sv-color (get-color :bg :pressed type))) - :on-long-press on-long-press - :style (reanimated/apply-animations-to-style - {:background-color sv-color} - (merge {:flex-direction :row - :flex 1 - :padding-vertical 8 - :padding-horizontal 12 - :background-color sv-color} - style))} - [system-message-content message labels]])) +(defn system-message-deleted-internal + [{:keys [label child theme timestamp]}] + [system-message-base + {:icon {:icon :i/delete + :color :danger + :opacity 5} + :timestamp timestamp} + (if child + child + [text/text + {:size :paragraph-2 + :style {:color (text-color theme)}} + (or label (i18n/label :t/message-deleted))])]) + +(def system-message-deleted (quo.theme/with-theme system-message-deleted-internal)) + +(defn system-message-contact-internal + [{:keys [display-name photo-path customization-color theme timestamp]} label icon] + [system-message-base + {:icon {:icon icon + :color (or customization-color :primary) + :opacity 5} + :timestamp timestamp} + [rn/view + {:flex-direction :row + :align-items :center + :flex-wrap :wrap} + [rn/view {:flex-direction :row :align-items :center} + [sm-user-avatar display-name photo-path] + [text/text + {:weight :semi-bold + :size :paragraph-2} + display-name]] + [split-text label theme true]]]) + +(def system-message-contact (quo.theme/with-theme system-message-contact-internal)) + +(defn system-message-added + [data] + [system-message-contact data (i18n/label :t/contact-request-is-now-a-contact) :i/add-user]) + +(defn system-message-removed + [{:keys [incoming?] :as data}] + [system-message-contact + data + (if incoming? + (i18n/label :t/contact-request-removed-you-as-contact) + (i18n/label :t/contact-request-removed-as-contact)) + :i/sad]) + +(defn system-message-contact-request-internal + [{:keys [display-name photo-path customization-color theme timestamp incoming?]}] + [system-message-base + {:icon {:icon :i/add-user + :color (or customization-color :primary) + :opacity 5} + :timestamp timestamp} + [rn/view + {:flex-direction :row + :align-items :center + :flex-wrap :wrap} + (when-not incoming? [split-text "Contact request sent to" theme false]) + [rn/view {:flex-direction :row :align-items :center} + [sm-user-avatar display-name photo-path] + [text/text + {:weight :semi-bold + :size :paragraph-2} + display-name]] + (when incoming? [split-text "sent you a contact request" theme true])]]) + +(def system-message-contact-request (quo.theme/with-theme system-message-contact-request-internal)) + +(defn system-message-pinned-internal + [{:keys [pinned-by child customization-color theme timestamp]}] + [system-message-base + {:icon {:icon :i/pin + :color (or customization-color :primary) + :opacity 5} + :timestamp timestamp} + [rn/view + [rn/view + {:flex-direction :row + :flex-wrap :wrap} + [author/author {:primary-name pinned-by}] + [split-text (i18n/label :pinned-a-message) theme true]] + (when child child)]]) + +(def system-message-pinned (quo.theme/with-theme system-message-pinned-internal)) (defn system-message - [message] - [:f> f-system-message message]) + [{:keys [type] :as data}] + [rn/view {:padding-horizontal 12 :padding-vertical 8 :flex 1} + (case type + :pinned [system-message-pinned data] + :deleted [system-message-deleted data] + :contact-request [system-message-contact-request data] + :added [system-message-added data] + :removed [system-message-removed data] + nil)]) diff --git a/src/status_im/ui/screens/home/views/inner_item.cljs b/src/status_im/ui/screens/home/views/inner_item.cljs index a2714e3a30..aa252062f0 100644 --- a/src/status_im/ui/screens/home/views/inner_item.cljs +++ b/src/status_im/ui/screens/home/views/inner_item.cljs @@ -93,7 +93,6 @@ [preview-label :t/no-messages] (and (or (= constants/content-type-text content-type) - (= constants/content-type-contact-request content-type) (= constants/content-type-emoji content-type) (= constants/content-type-command content-type)) (not (string/blank? (:text content)))) diff --git a/src/status_im2/constants.cljs b/src/status_im2/constants.cljs index 1f34a65a8f..d1985d7a7a 100644 --- a/src/status_im2/constants.cljs +++ b/src/status_im2/constants.cljs @@ -12,7 +12,7 @@ (def ^:const content-type-audio 8) (def ^:const content-type-community 9) (def ^:const content-type-gap 10) -(def ^:const content-type-contact-request 11) ;; TODO: temp, will be removed +(def ^:const content-type-contact-request 11) (def ^:const content-type-system-pinned-message 14) (def ^:const content-type-system-message-mutual-event-sent 15) (def ^:const content-type-system-message-mutual-event-accepted 16) diff --git a/src/status_im2/contexts/chat/home/chat_list_item/view.cljs b/src/status_im2/contexts/chat/home/chat_list_item/view.cljs index 62993b0836..451c8d81f3 100644 --- a/src/status_im2/contexts/chat/home/chat_list_item/view.cljs +++ b/src/status_im2/contexts/chat/home/chat_list_item/view.cljs @@ -88,6 +88,9 @@ :dont-show (i18n/label :t/Pinned-a-message) (i18n/label :t/Pinned-a-message)) + constants/content-type-contact-request + (i18n/label :t/contact-request) + constants/content-type-sticker (case author :you (i18n/label :t/you-sent-a-sticker) diff --git a/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs b/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs index 607f1dfce2..fcebd36182 100644 --- a/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs +++ b/src/status_im2/contexts/chat/messages/contact_requests/bottom_drawer.cljs @@ -4,27 +4,46 @@ [utils.re-frame :as rf] [quo2.core :as quo] [quo2.components.drawers.permission-context.view :as permission-context] - [status-im2.constants :as constants])) + [status-im2.constants :as constants] + [react-native.core :as rn] + [status-im2.config :as config])) (defn view [contact-id contact-request-state group-chat] - (let [names (rf/sub [:contacts/contact-two-names-by-identity contact-id])] - [permission-context/view - [quo/button - {:type :ghost - :on-press #(rf/dispatch [:chat.ui/show-profile contact-id]) - :icon-left :i/communities} - (cond - group-chat - (i18n/label :t/group-chat-not-member) + (let [customization-color (rf/sub [:profile/customization-color]) + names (rf/sub [:contacts/contact-two-names-by-identity contact-id])] + [rn/view + [permission-context/view + [quo/button + {:type :ghost + :size 24 + :on-press #(rf/dispatch [:chat.ui/show-profile contact-id]) + :icon-left (if (= contact-request-state constants/contact-request-state-sent) + :i/pending-state + :i/add-user)} + (cond + group-chat + (i18n/label :t/group-chat-not-member) - (or (not contact-request-state) - (= contact-request-state - constants/contact-request-state-none) - (= contact-request-state - constants/contact-request-state-received)) - (i18n/label :t/contact-request-chat-add {:name (first names)}) - (= contact-request-state - constants/contact-request-state-sent) + (or (not contact-request-state) + (= contact-request-state + constants/contact-request-state-none)) + (i18n/label :t/contact-request-chat-add {:name (first names)}) - (i18n/label :t/contact-request-chat-pending))]])) + (= contact-request-state + constants/contact-request-state-received) + (str (first names) " sent you a contact request") + + (= contact-request-state + constants/contact-request-state-sent) + (i18n/label :t/contact-request-chat-pending))]] + [rn/view {:position :absolute :top -36 :align-self :center} + [quo/floating-shell-button + {:jump-to + {:on-press (fn [] + (when config/shell-navigation-disabled? + (rf/dispatch [:chat/close true])) + (rf/dispatch [:shell/navigate-to-jump-to])) + :customization-color customization-color + :label (i18n/label :t/jump-to)}} + {}]]])) diff --git a/src/status_im2/contexts/chat/messages/content/deleted/view.cljs b/src/status_im2/contexts/chat/messages/content/deleted/view.cljs index dc73d334b5..8bffa88b1c 100644 --- a/src/status_im2/contexts/chat/messages/content/deleted/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/deleted/view.cljs @@ -1,7 +1,6 @@ (ns status-im2.contexts.chat.messages.content.deleted.view (:require [quo2.core :as quo] [react-native.core :as rn] - [status-im2.contexts.chat.messages.drawers.view :as drawers] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -24,16 +23,6 @@ :number-of-lines 1} (i18n/label :t/deleted-this-message)]]) -(defn- compute-on-long-press-fn - [{:keys [deleted?] :as message} - context] - ;; only show drawer for user who has the permission to unpin messages - (when-not deleted? - (fn [] - (rf/dispatch [:dismiss-keyboard]) - (rf/dispatch [:show-bottom-sheet - {:content (drawers/reactions-and-actions message context)}])))) - (defn deleted-by-message [{:keys [deleted-by deleted-undoable-till timestamp-str deleted-for-me-undoable-till from]} on-long-press-fn] @@ -44,7 +33,7 @@ (rf/sub [:chats/photo-path (or deleted-by from)]))] [quo/system-message {:type :deleted - :timestamp-str timestamp-str + :timestamp timestamp-str :child [user-xxx-deleted-this-message {:display-name display-name :profile-picture photo-path}] :on-long-press on-long-press-fn @@ -52,21 +41,13 @@ :animate-landing? (or deleted-undoable-till deleted-for-me-undoable-till)}])) (defn deleted-message - [{:keys [deleted? deleted-by deleted-undoable-till timestamp-str - deleted-for-me-undoable-till from] - :as message} - context] - (let [pub-key (rf/sub [:multiaccount/public-key]) - deleted-by-me? (= (or deleted-by from) pub-key) - on-long-press-fn (compute-on-long-press-fn message context)] + [{:keys [deleted? deleted-by timestamp-str from] :as message}] + (let [pub-key (rf/sub [:multiaccount/public-key]) + deleted-by-me? (= (or deleted-by from) pub-key)] (if (and deleted? (not deleted-by-me?)) - [deleted-by-message message on-long-press-fn] + [deleted-by-message message] [quo/system-message - {:type :deleted - :label (if deleted? :message-deleted :message-deleted-for-you) - :labels {:message-deleted (i18n/label :t/message-deleted-for-everyone) - :message-deleted-for-you (i18n/label :t/message-deleted-for-you)} - :on-long-press on-long-press-fn - :timestamp-str timestamp-str - :non-pressable? (if on-long-press-fn false true) - :animate-landing? (or deleted-undoable-till deleted-for-me-undoable-till)}]))) + {:type :deleted + :label (i18n/label + (if deleted? :t/message-deleted-for-everyone :t/message-deleted-for-you)) + :timestamp timestamp-str}]))) diff --git a/src/status_im2/contexts/chat/messages/content/pin/view.cljs b/src/status_im2/contexts/chat/messages/content/pin/view.cljs index a1181578b8..7f2dd506bb 100644 --- a/src/status_im2/contexts/chat/messages/content/pin/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/pin/view.cljs @@ -28,10 +28,11 @@ (defn pinned-message [{:keys [from quoted-message timestamp-str]}] - (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity from]))] + (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity from])) + customization-color (rf/sub [:profile/customization-color])] [quo/system-message - {:type :pinned - :pinned-by display-name - :child [reply/quoted-message quoted-message false true] - :timestamp-str timestamp-str - :labels {:pinned-a-message (i18n/label :t/pinned-a-message)}}])) + {:type :pinned + :pinned-by display-name + :customization-color customization-color + :child [reply/quoted-message quoted-message false true] + :timestamp timestamp-str}])) diff --git a/src/status_im2/contexts/chat/messages/content/view.cljs b/src/status_im2/contexts/chat/messages/content/view.cljs index c1349add03..4a90dbc657 100644 --- a/src/status_im2/contexts/chat/messages/content/view.cljs +++ b/src/status_im2/contexts/chat/messages/content/view.cljs @@ -65,6 +65,21 @@ :contact? added? :verified? ens-verified}]))) +(defn system-message-contact-request + [{:keys [chat-id timestamp-str from]} type] + (let [display-name (first (rf/sub [:contacts/contact-two-names-by-identity chat-id])) + contact (rf/sub [:contacts/contact-by-address chat-id]) + photo-path (when (seq (:images contact)) (rf/sub [:chats/photo-path chat-id])) + customization-color (rf/sub [:profile/customization-color]) + {:keys [public-key]} (rf/sub [:profile/profile])] + [quo/system-message + {:type type + :timestamp timestamp-str + :display-name display-name + :customization-color customization-color + :photo-path photo-path + :incoming? (not= public-key from)}])) + (defn system-message-content [{:keys [content-type quoted-message] :as message-data}] (if quoted-message @@ -81,9 +96,14 @@ [not-implemented/not-implemented [old-message/community message-data]] - constants/content-type-contact-request - [not-implemented/not-implemented - [old-message/system-contact-request message-data]]))) + constants/content-type-system-message-mutual-event-accepted + [system-message-contact-request message-data :added] + + constants/content-type-system-message-mutual-event-removed + [system-message-contact-request message-data :removed] + + constants/content-type-system-message-mutual-event-sent + [system-message-contact-request message-data :contact-request]))) (declare on-long-press) @@ -193,23 +213,28 @@ :show-reactions? true :show-user-info? true}]])}])) +(defn system-message? + [content-type] + (#{constants/content-type-system-text + constants/content-type-community + constants/content-type-system-message-mutual-event-accepted + constants/content-type-system-message-mutual-event-removed + constants/content-type-system-message-mutual-event-sent + constants/content-type-system-pinned-message} + content-type)) + (defn message [{:keys [pinned-by mentioned content-type last-in-group? deleted? deleted-for-me?] - :as message-data} context keyboard-shown?] - (let [in-pinned-view? (:in-pinned-view? context)] - (if (or deleted? deleted-for-me?) - [rn/view {:style (style/message-container)} - [content.deleted/deleted-message message-data context]] - [rn/view - {:style (style/message-container in-pinned-view? pinned-by mentioned last-in-group?) - :accessibility-label :chat-item} - (if (#{constants/content-type-system-text constants/content-type-community - constants/content-type-contact-request - constants/content-type-system-pinned-message} - content-type) - [system-message-content message-data] - [user-message-content - {:message-data message-data - :context context - :keyboard-shown? keyboard-shown? - :show-reactions? true}])]))) + :as message-data} {:keys [in-pinned-view?] :as context} keyboard-shown?] + [rn/view + {:style (style/message-container in-pinned-view? pinned-by mentioned last-in-group?) + :accessibility-label :chat-item} + (if (or (system-message? content-type) deleted? deleted-for-me?) + (if (or deleted? deleted-for-me?) + [content.deleted/deleted-message message-data] + [system-message-content message-data]) + [user-message-content + {:message-data message-data + :context context + :keyboard-shown? keyboard-shown? + :show-reactions? true}])]) diff --git a/src/status_im2/contexts/chat/messages/list/view.cljs b/src/status_im2/contexts/chat/messages/list/view.cljs index b0e2049f2a..842762fc1f 100644 --- a/src/status_im2/contexts/chat/messages/list/view.cljs +++ b/src/status_im2/contexts/chat/messages/list/view.cljs @@ -126,15 +126,17 @@ loading-indicator-page-loading-height)]]))) (defn list-header - [insets] + [insets able-to-send-message?] [rn/view {:background-color (colors/theme-colors colors/white colors/neutral-95) :margin-bottom (- 0 (:top insets) (when platform/ios? style/overscroll-cover-height)) - :height (+ composer.constants/composer-default-height - (:bottom insets) - spacing-between-composer-and-content + :height (+ (if able-to-send-message? + (+ composer.constants/composer-default-height + spacing-between-composer-and-content + (:bottom insets)) + (- 70 (:bottom insets))) (when platform/ios? style/overscroll-cover-height))}]) (defn f-list-footer-avatar @@ -253,9 +255,7 @@ [{:keys [type value content-type] :as message-data} _ _ {:keys [context keyboard-shown?]}] ;;TODO temporary hide mutual-state-updates https://github.com/status-im/status-mobile/issues/16254 - (when-not (#{constants/content-type-system-message-mutual-event-sent - constants/content-type-system-message-mutual-event-accepted - constants/content-type-system-message-mutual-event-removed} + (when-not (#{constants/content-type-contact-request} content-type) [rn/view (add-inverted-y-android {:background-color (colors/theme-colors colors/white colors/neutral-95)}) @@ -289,7 +289,7 @@ {:key-fn list-key-fn :ref list-ref :header [:<> - [list-header insets] + [list-header insets (:able-to-send-message? context)] (when (= (:chat-type chat) constants/private-group-chat-type) [list-group-chat-header chat])] :footer [list-footer @@ -322,7 +322,10 @@ (reanimated/set-shared-value content-height y)))) :on-end-reached #(list-on-end-reached scroll-y) :on-scroll-to-index-failed identity - :scroll-indicator-insets {:top (- composer.constants/composer-default-height 16)} + :scroll-indicator-insets {:top (if (:able-to-send-message? context) + (- composer.constants/composer-default-height 16) + 0)} + :keyboard-dismiss-mode :interactive :keyboard-should-persist-taps :always :on-scroll-begin-drag rn/dismiss-keyboard! diff --git a/src/status_im2/contexts/contacts/events.cljs b/src/status_im2/contexts/contacts/events.cljs index 3f82ef0d70..ab437e10c3 100644 --- a/src/status_im2/contexts/contacts/events.cljs +++ b/src/status_im2/contexts/contacts/events.cljs @@ -99,10 +99,11 @@ (assoc-in [:contacts/contacts public-key :active?] false) (assoc-in [:contacts/contacts public-key :contact-request-state] constants/contact-request-state-none)) - :json-rpc/call [{:method "wakuext_retractContactRequest" - :params [{:id public-key}] - :on-success #(log/debug "contact removed successfully") - :on-error #(log/error "failed to remove contact" public-key %)}]}) + :json-rpc/call [{:method "wakuext_retractContactRequest" + :params [{:id public-key}] + :js-response true + :on-success #(rf/dispatch [:sanitize-messages-and-process-response %]) + :on-error #(log/error "failed to remove contact" public-key %)}]}) (rf/defn update-nickname {:events [:contacts/update-nickname]} diff --git a/src/status_im2/contexts/quo_preview/messages/system_message.cljs b/src/status_im2/contexts/quo_preview/messages/system_message.cljs index bde30d72d1..3702f0a3b4 100644 --- a/src/status_im2/contexts/quo_preview/messages/system_message.cljs +++ b/src/status_im2/contexts/quo_preview/messages/system_message.cljs @@ -3,8 +3,6 @@ [quo2.foundations.colors :as colors] [react-native.core :as rn] [reagent.core :as reagent] - [utils.i18n :as i18n] - [status-im2.common.resources :as resources] [status-im2.contexts.quo-preview.preview :as preview])) (def descriptor @@ -13,8 +11,12 @@ :type :select :options [{:value "Message pinned" :key :pinned} + {:value "Contact request" + :key :contact-request} {:value "User added" :key :added} + {:value "User removed" + :key :removed} {:value "Message deleted" :key :deleted}]} {:label "Action" @@ -32,39 +34,27 @@ :type :text} {:label "Content Info" :key :content-info - :type :text} - {:label "Timestamp" - :key :timestamp-str :type :text}]) (defn finalize-state [state] (merge @state - {:mentions [{:name "Alicia Keys" - :image (resources/get-mock-image :user-picture-female2)} - {:name "pedro.eth" - :image (resources/get-mock-image :user-picture-male4)}] - :content {:text (:content-text @state) - :info (:content-info @state) - :mentions {:name "Alisher" - :image (resources/get-mock-image :user-picture-male5)}}})) + {:child (when (= (:type @state) :pinned) [rn/text "Message content"]) + :display-name (:pinned-by @state)})) + (defn preview [] - (let [state (reagent/atom {:type :deleted - :pinned-by "Steve" - :content-text "Hello! This is an example of a pinned message!" - :content-info "3 photos" - :timestamp-str "09:41" - :labels {:pinned-a-message (i18n/label :pinned-a-message) - :message-deleted (i18n/label :message-deleted) - :added (i18n/label :added)}})] + (let [state (reagent/atom {:type :pinned + :pinned-by "Steve" + :timestamp "09:41" + :content-text "Hello! This is an example of a pinned message!" + :content-info "3 photos"})] (fn [] [rn/touchable-without-feedback {:on-press rn/dismiss-keyboard!} [rn/view {:padding-bottom 150} [preview/customizer state descriptor] [rn/view - {:padding-vertical 60 - :align-items :center} + {:padding-vertical 60 :flex 1} [system-message/system-message (finalize-state state)]]]]))) (defn preview-system-message diff --git a/src/status_im2/contexts/shell/jump_to/components/switcher_cards/view.cljs b/src/status_im2/contexts/shell/jump_to/components/switcher_cards/view.cljs index 9bf27f1125..6968c42c6e 100644 --- a/src/status_im2/contexts/shell/jump_to/components/switcher_cards/view.cljs +++ b/src/status_im2/contexts/shell/jump_to/components/switcher_cards/view.cljs @@ -181,6 +181,9 @@ constants/content-type-link (i18n/label :t/external-link) + constants/content-type-contact-request + (i18n/label :t/contact-request) + ""))) (defn open-screen diff --git a/src/status_im2/subs/shell.cljs b/src/status_im2/subs/shell.cljs index 5a06f3a252..6809d11b87 100644 --- a/src/status_im2/subs/shell.cljs +++ b/src/status_im2/subs/shell.cljs @@ -64,7 +64,11 @@ (let [community (get communities (:community-id last-message))] {:content-type constants/content-type-community :data {:avatar (community-avatar community) - :community-name (:name community)}}))) + :community-name (:name community)}}) + + (= content-type constants/content-type-contact-request) + {:content-type constants/content-type-contact-request})) + {:new-notifications? (pos? (:unviewed-messages-count chat)) :notification-indicator (if (pos? (:unviewed-mentions-count chat)) :counter diff --git a/translations/en.json b/translations/en.json index d9be8aea2d..0c4083063c 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1924,8 +1924,11 @@ "new-ui": "New UI", "send-contact-request-message": "To start a chat you need to become contacts", "contact-request": "Contact request", + "contact-request-sent-to": "Contact request sent to", "contact-request-was-accepted": "Contact request accepted", "contact-request-is-now-a-contact": "is now a contact", + "contact-request-removed-you-as-contact": "removed you as a contact", + "contact-request-removed-as-contact": "removed as a contact", "contact-requests": "Contact requests", "say-hi": "Say hi", "opened": "Opened", @@ -2058,7 +2061,7 @@ "selected-count-from-max": "{{selected}}/{{max}}", "online": "Online", "contact-request-chat-pending": "Your contact request is pending", - "contact-request-chat-add": "Add {{name}} to send a message", + "contact-request-chat-add": "Add {{name}} as contact to send a message", "join-request": "Join request", "join-one-user": "Join {{user}}", "join-two-users": "Join {{user1}} and {{user2}}",