From 9ab1b70e0e25dfb79b212b1397a0a18e84725e76 Mon Sep 17 00:00:00 2001 From: Ibrahem Khalil Date: Wed, 30 Aug 2023 16:04:08 +0300 Subject: [PATCH] Pinned messages drawer comments (#16998) --- .../chat/menus/pinned_messages/style.cljs | 6 +++-- .../chat/menus/pinned_messages/view.cljs | 22 +++++++++++++++---- src/status_im2/subs/communities.cljs | 6 +++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/status_im2/contexts/chat/menus/pinned_messages/style.cljs b/src/status_im2/contexts/chat/menus/pinned_messages/style.cljs index 862cb228a8..33502dcddd 100644 --- a/src/status_im2/contexts/chat/menus/pinned_messages/style.cljs +++ b/src/status_im2/contexts/chat/menus/pinned_messages/style.cljs @@ -1,8 +1,10 @@ (ns status-im2.contexts.chat.menus.pinned-messages.style (:require [quo2.foundations.colors :as colors])) -(def heading - {:margin-horizontal 20}) +(defn heading + [community?] + {:margin-horizontal 20 + :margin-bottom (when-not community? 24)}) (defn heading-container [] diff --git a/src/status_im2/contexts/chat/menus/pinned_messages/view.cljs b/src/status_im2/contexts/chat/menus/pinned_messages/view.cljs index 40205cc555..453bc2e596 100644 --- a/src/status_im2/contexts/chat/menus/pinned_messages/view.cljs +++ b/src/status_im2/contexts/chat/menus/pinned_messages/view.cljs @@ -8,10 +8,18 @@ [status-im2.contexts.chat.menus.pinned-messages.style :as style] [utils.i18n :as i18n] [utils.re-frame :as rf] - [react-native.gesture :as gesture])) + [react-native.gesture :as gesture] + [react-native.fast-image :as fast-image])) (def list-key-fn #(or (:message-id %) (:value %))) +(defn community-avatar + [community-images] + (when community-images + (:uri (or (:thumbnail community-images) + (:large community-images) + (first community-images))))) + (defn message-render-fn [{:keys [deleted? deleted-for-me?] :as message} _ _ context] (if (or deleted? deleted-for-me?) @@ -25,17 +33,23 @@ current-chat (rf/sub [:chat-by-id chat-id]) {:keys [community-id]} current-chat community (rf/sub [:communities/community community-id]) - bottom-inset (safe-area/get-bottom)] + bottom-inset (safe-area/get-bottom) + community-images (rf/sub [:community/images community-id])] [gesture/scroll-view {:accessibility-label :pinned-messages-menu} [:<> [quo/text - {:size :heading-1 + {:size :heading-2 :weight :semi-bold - :style style/heading} + :style (style/heading community)} (i18n/label :t/pinned-messages)] (when community [rn/view {:style (style/heading-container)} + [fast-image/fast-image + {:source (community-avatar community-images) + :style {:width 20 + :height 20 + :border-radius 20}}] [rn/text {:style (style/heading-text)} (:name community)] [quo/icon :i/chevron-right diff --git a/src/status_im2/subs/communities.cljs b/src/status_im2/subs/communities.cljs index 25d2566f6e..e6645e7072 100644 --- a/src/status_im2/subs/communities.cljs +++ b/src/status_im2/subs/communities.cljs @@ -297,3 +297,9 @@ token_criteria (or check-criteria token_criteria)))) token-permissions)})) + +(re-frame/reg-sub + :community/images + :<- [:communities] + (fn [communities [_ id]] + (get-in communities [id :images])))