From 3c9ad509cdb9703a15ddf4c1c2087af43c749a43 Mon Sep 17 00:00:00 2001 From: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> Date: Thu, 18 May 2023 19:08:18 +0800 Subject: [PATCH] [Fix] Activity Center Empty Community Icons (#15907) Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com> --- .../components/tags/context_tag/view.cljs | 24 ++++++++------ .../ui/screens/communities/icon.cljs | 2 +- .../notification/admin/view.cljs | 9 ++---- .../notification/common/view.cljs | 11 ++++--- .../notification/community_kicked/view.cljs | 2 +- .../notification/community_request/view.cljs | 2 +- .../notification/mentions/view.cljs | 12 ++----- .../notification/reply/view.cljs | 12 ++----- .../quo_preview/tags/context_tags.cljs | 32 ++++++++++++------- 9 files changed, 51 insertions(+), 55 deletions(-) diff --git a/src/quo2/components/tags/context_tag/view.cljs b/src/quo2/components/tags/context_tag/view.cljs index 770b256568..1dd512e08a 100644 --- a/src/quo2/components/tags/context_tag/view.cljs +++ b/src/quo2/components/tags/context_tag/view.cljs @@ -4,6 +4,7 @@ [quo2.components.icon :as icons] [quo2.components.markdown.text :as text] [quo2.components.tags.context-tag.style :as style] + [quo2.components.avatars.user-avatar.style :as user-avatar-style] [react-native.core :as rn])) (defn trim-public-key @@ -39,16 +40,21 @@ (trim-public-key public-key)]]) (defn context-tag - [{:keys [text-style blur?] :as params} photo name channel-name] - (let [text-params {:weight :medium - :size :paragraph-2 - :style (assoc text-style :justify-content :center)}] + [{:keys [text-style blur? no-avatar-placeholder?] :as params} photo name channel-name] + (let [text-params {:weight :medium + :size :paragraph-2 + :style (assoc text-style :justify-content :center)} + empty-photo? (empty? photo) + avatar-size :xxs + avatar-outer-size (get-in user-avatar-style/sizes [avatar-size :outer])] [base-tag (assoc-in params [:style :padding-left] 3) - [user-avatar/user-avatar - {:full-name name - :profile-picture photo - :size :xxs - :status-indicator? false}] + (if (and empty-photo? no-avatar-placeholder?) + [rn/view {:style {:width avatar-outer-size}}] + [user-avatar/user-avatar + {:full-name name + :profile-picture photo + :size avatar-size + :status-indicator? false}]) [rn/view {:style style/context-tag-text-container} [text/text text-params (str " " name)] (when channel-name diff --git a/src/status_im/ui/screens/communities/icon.cljs b/src/status_im/ui/screens/communities/icon.cljs index 4a00ccf79d..38e8dbb4a8 100644 --- a/src/status_im/ui/screens/communities/icon.cljs +++ b/src/status_im/ui/screens/communities/icon.cljs @@ -17,7 +17,7 @@ :style {:width 40 :height 40}}] (seq thumbnail-image) - [photos/photo thumbnail-image {:size 40}] + [photos/photo {:uri thumbnail-image} {:size 40}] :else [chat-icon.screen/chat-icon-view-chat-list diff --git a/src/status_im2/contexts/activity_center/notification/admin/view.cljs b/src/status_im2/contexts/activity_center/notification/admin/view.cljs index a0e63e4dcb..d8332788df 100644 --- a/src/status_im2/contexts/activity_center/notification/admin/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/admin/view.cljs @@ -1,6 +1,5 @@ (ns status-im2.contexts.activity-center.notification.admin.view (:require [quo2.core :as quo] - [quo2.foundations.colors :as colors] [status-im2.constants :as constants] [status-im2.contexts.activity-center.notification.common.style :as common-style] [status-im2.contexts.activity-center.notification.common.view :as common] @@ -69,12 +68,8 @@ :context [[common/user-avatar-tag author] (i18n/label :t/wants-to-join) [quo/context-tag - {:size :small - :override-theme :dark - :color colors/primary-50 - :style common-style/user-avatar-tag - :text-style common-style/user-avatar-tag-text} - {:uri community-image} community-name]] + common/tag-params + community-image community-name]] :items (case membership-status constants/activity-center-membership-status-accepted [{:type :status diff --git a/src/status_im2/contexts/activity_center/notification/common/view.cljs b/src/status_im2/contexts/activity_center/notification/common/view.cljs index 194a0f5020..a451f5ee3e 100644 --- a/src/status_im2/contexts/activity_center/notification/common/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/common/view.cljs @@ -9,11 +9,12 @@ [utils.re-frame :as rf])) (def tag-params - {:size :small - :override-theme :dark - :color colors/primary-50 - :style style/user-avatar-tag - :text-style style/user-avatar-tag-text}) + {:size :small + :override-theme :dark + :color colors/primary-50 + :style style/user-avatar-tag + :text-style style/user-avatar-tag-text + :no-avatar-placeholder? true}) (defn user-avatar-tag [user-id] diff --git a/src/status_im2/contexts/activity_center/notification/community_kicked/view.cljs b/src/status_im2/contexts/activity_center/notification/community_kicked/view.cljs index cf5865778c..23107a9250 100644 --- a/src/status_im2/contexts/activity_center/notification/community_kicked/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/community_kicked/view.cljs @@ -33,5 +33,5 @@ :unread? (not read) :context [[quo/text {:style common-style/user-avatar-tag-text} (i18n/label :t/community-kicked-body)] - [quo/context-tag common/tag-params {:uri community-image} + [quo/context-tag common/tag-params community-image community-name]]}]])) diff --git a/src/status_im2/contexts/activity_center/notification/community_request/view.cljs b/src/status_im2/contexts/activity_center/notification/community_request/view.cljs index 8d73da6685..45c11d874f 100644 --- a/src/status_im2/contexts/activity_center/notification/community_request/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/community_request/view.cljs @@ -22,7 +22,7 @@ [community membership-status] (let [community-name (:name community) community-image (get-in community [:images :thumbnail :uri]) - community-context-tag [quo/context-tag common/tag-params {:uri community-image} + community-context-tag [quo/context-tag common/tag-params community-image community-name]] (cond (= membership-status constants/activity-center-membership-status-idle) diff --git a/src/status_im2/contexts/activity_center/notification/mentions/view.cljs b/src/status_im2/contexts/activity_center/notification/mentions/view.cljs index be80bae5f9..5477d118f8 100644 --- a/src/status_im2/contexts/activity_center/notification/mentions/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/mentions/view.cljs @@ -1,7 +1,6 @@ (ns status-im2.contexts.activity-center.notification.mentions.view (:require [clojure.string :as string] [quo2.core :as quo] - [quo2.foundations.colors :as colors] [react-native.gesture :as gesture] [status-im2.contexts.activity-center.notification.common.view :as common] [status-im2.contexts.activity-center.notification.mentions.style :as style] @@ -9,13 +8,6 @@ [utils.i18n :as i18n] [utils.re-frame :as rf])) -(def ^:private tag-params - {:size :small - :override-theme :dark - :color colors/primary-50 - :style style/tag - :text-style style/tag-text}) - (defn- message-body [message] (let [parsed-text (get-in message [:content :parsed-text]) @@ -68,6 +60,6 @@ :context [[common/user-avatar-tag author] [quo/text {:style style/tag-text} (string/lower-case (i18n/label :t/on))] (if community-chat? - [quo/context-tag tag-params {:uri community-image} community-name chat-name] - [quo/group-avatar-tag chat-name tag-params])] + [quo/context-tag common/tag-params community-image community-name chat-name] + [quo/group-avatar-tag chat-name common/tag-params])] :message {:body (message-body message)}}]]])) diff --git a/src/status_im2/contexts/activity_center/notification/reply/view.cljs b/src/status_im2/contexts/activity_center/notification/reply/view.cljs index a71b878954..969f9b7a10 100644 --- a/src/status_im2/contexts/activity_center/notification/reply/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/reply/view.cljs @@ -1,7 +1,6 @@ (ns status-im2.contexts.activity-center.notification.reply.view (:require [clojure.string :as string] [quo2.core :as quo] - [quo2.foundations.colors :as colors] [react-native.gesture :as gesture] [status-im.ui2.screens.chat.messages.message :as old-message] [status-im2.common.not-implemented :as not-implemented] @@ -12,13 +11,6 @@ [utils.i18n :as i18n] [utils.re-frame :as rf])) -(def ^:private tag-params - {:size :small - :override-theme :dark - :color colors/primary-50 - :style style/tag - :text-style style/tag-text}) - ;; NOTE: Replies support text, image and stickers only. (defn- get-message-content [{:keys [content-type] :as message}] @@ -76,7 +68,7 @@ :context [[common/user-avatar-tag author] [quo/text {:style style/lowercase-text} (i18n/label :t/on)] (if community-chat? - [quo/context-tag tag-params {:uri community-image} community-name chat-name] - [quo/group-avatar-tag chat-name tag-params])] + [quo/context-tag common/tag-params community-image community-name chat-name] + [quo/group-avatar-tag chat-name common/tag-params])] :message {:body-number-of-lines 1 :body (get-message-content message)}}]]])) diff --git a/src/status_im2/contexts/quo_preview/tags/context_tags.cljs b/src/status_im2/contexts/quo_preview/tags/context_tags.cljs index b1dc0da83d..0bbed36475 100644 --- a/src/status_im2/contexts/quo_preview/tags/context_tags.cljs +++ b/src/status_im2/contexts/quo_preview/tags/context_tags.cljs @@ -43,19 +43,27 @@ :type :boolean}]) (def context-tag-descriptor - [{:label "Label" + [{:label "Show avatar" + :key :show-avatar? + :type :boolean} + {:label "Label" :key :label :type :text} - {:label "Channel Name" + {:label "Channel name" :key :channel-name - :type :text}]) + :type :text} + {:label "Avatar placeholder" + :key :no-avatar-placeholder? + :type :boolean}]) (defn cool-preview [] - (let [state (reagent/atom {:label "Name" - :channel-name "Channel" - :type :group-avatar - :duration "00:32"})] + (let [state (reagent/atom {:label "Name" + :channel-name "Channel" + :type :group-avatar + :duration "00:32" + :show-avatar? true + :no-avatar-placeholder? false})] (fn [] (let [contacts {example-pk {:public-key example-pk :primary-name "Automatic incompatible Coati" @@ -122,10 +130,12 @@ :show-blur-background? (:blur? @state)} (case (:type @state) :context-tag [quo2/context-tag - {:blur? (:blur? @state) - :size :small - :color :purple} - {:uri example-photo2} + {:blur? (:blur? @state) + :size :small + :color :purple + :no-avatar-placeholder? (:no-avatar-placeholder? @state)} + (when (:show-avatar? @state) + example-photo2) (:label @state) (:channel-name @state)]