Skip to content

Commit b0964ef

Browse files
authored
feat: contact CustomizationColor (#19087)
1 parent b0d2e6e commit b0964ef

File tree

18 files changed

+121
-107
lines changed

18 files changed

+121
-107
lines changed

src/legacy/status_im/multiaccounts/update/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[{:keys [db]}]
1111
(let [{:keys [name preferred-name display-name address]} (:profile/profile db)]
1212
{:json-rpc/call [{:method "wakuext_sendContactUpdates"
13-
:params [(or preferred-name display-name name) ""]
13+
:params [(or preferred-name display-name name) "" ""]
1414
:on-success #(log/debug "sent contact update")}]}))
1515

1616
(rf/defn update-multiaccount-account-name

src/quo/components/avatars/user_avatar/view.cljs

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
utils.string))
1212

1313
(defn initials-avatar
14-
[{:keys [full-name size customization-color theme]}]
14+
[{:keys [full-name size customization-color theme]
15+
:or {customization-color :blue}}]
1516
(let [font-size (get-in style/sizes [size :font-size])
1617
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)]
1718
[rn/view
@@ -30,13 +31,12 @@
3031
When calling the `profile-picture-fn` and passing the `:ring?` key, be aware that the `profile-picture-fn`
3132
may have an `:override-ring?` value. If it does then the `:ring?` value will not be used.
3233
For reference, refer to the `utils.image-server` namespace for these `profile-picture-fn` are generated."
33-
[{:keys [full-name size profile-picture customization-color static?
34+
[{:keys [full-name size profile-picture static?
3435
status-indicator? online? ring? theme]
35-
:or {size :big
36-
status-indicator? true
37-
online? true
38-
ring? true
39-
customization-color :blue}
36+
:or {size :big
37+
status-indicator? true
38+
online? true
39+
ring? true}
4040
:as props}]
4141
(let [full-name (or full-name "Your Name")
4242
;; image generated with `profile-picture-fn` is round cropped
@@ -75,7 +75,6 @@
7575
(:status-indicator-center-to-edge sizes))
7676
:indicator-color indicator-color
7777
:override-theme theme
78-
:background-color (style/customization-color customization-color theme)
7978
:color (:color style/initials-avatar-text)
8079
:size (:width outer-styles)
8180
:ring? ring?

src/quo/components/profile/profile_card/view.cljs

+5-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@
5454
[rn/view
5555
{:style style/card-header}
5656
[user-avatar/user-avatar
57-
{:full-name name
58-
:profile-picture profile-picture
59-
:size :medium
60-
:status-indicator? false
61-
:customization-color customization-color
62-
:static? true}]
57+
{:full-name name
58+
:profile-picture profile-picture
59+
:size :medium
60+
:status-indicator? false
61+
:static? true}]
6362
[rn/view {:flex-direction :row}
6463
(when show-logged-in?
6564
[tag/tag

src/schema/quo.cljs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns schema.quo
22
(:require
3+
[quo.foundations.colors :as colors]
34
[schema.registry :as registry]))
45

56
(def ^:private ?profile-picture-fn-params
@@ -23,6 +24,9 @@
2324
[:map
2425
[:fn [:=> [:cat ?profile-picture-fn-params] :string]]]])
2526

27+
(def ^:private ?customization-color (into [:enum] colors/account-colors))
28+
2629
(defn register-schemas
2730
[]
28-
(registry/register ::profile-picture-source ?profile-picture-source))
31+
(registry/register ::profile-picture-source ?profile-picture-source)
32+
(registry/register ::customization-color ?customization-color))

src/status_im/contexts/chat/contacts/events.cljs

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
:has-added-us? (oops/oget js-contact "hasAddedUs")
2828
:mutual? (oops/oget js-contact "mutual")
2929
:emoji-hash (oops/oget js-contact "emojiHash")
30-
:bio (oops/oget js-contact "bio")})
30+
:bio (oops/oget js-contact "bio")
31+
:customization-color (-> js-contact
32+
(oops/oget "customizationColor")
33+
keyword
34+
;; newly created accounts
35+
(or :blue))})
3136

3237
(defn prepare-events-for-contact
3338
[db chats-js]

src/status_im/contexts/chat/messenger/messages/list/view.cljs

+18-13
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,24 @@
328328
(defn messages-list-content
329329
[{:keys [insets distance-from-list-top content-height layout-height distance-atom
330330
chat-screen-layout-calculations-complete? chat-list-scroll-y]}]
331-
(let [theme (quo.theme/use-theme-value)
332-
chat (rf/sub [:chats/current-chat-chat-view])
333-
community-channel? (= constants/community-chat-type (:chat-type chat))
334-
customization-color (if community-channel?
335-
(or (:color chat)
336-
(rf/sub [:communities/community-color (:community-id chat)]))
337-
:turquoise)
338-
{:keys [keyboard-shown]} (hooks/use-keyboard)
339-
{window-height :height} (rn/get-window)
340-
context (rf/sub [:chats/current-chat-message-list-view-context])
341-
messages (rf/sub [:chats/raw-chat-messages-stream
342-
(:chat-id chat)])
343-
recording? (rf/sub [:chats/recording?])]
331+
(let [theme (quo.theme/use-theme-value)
332+
{:keys [chat-type chat-id] :as chat} (rf/sub [:chats/current-chat-chat-view])
333+
one-to-one-chat? (= chat-type constants/one-to-one-chat-type)
334+
community-channel? (= constants/community-chat-type chat-type)
335+
{contact-customization-color
336+
:customization-color} (when one-to-one-chat?
337+
(rf/sub [:contacts/contact-by-identity chat-id]))
338+
customization-color (cond community-channel?
339+
(or (:color chat)
340+
(rf/sub [:communities/community-color
341+
(:community-id chat)]))
342+
one-to-one-chat? contact-customization-color
343+
:else (or (:color chat) :turquoise))
344+
{:keys [keyboard-shown]} (hooks/use-keyboard)
345+
{window-height :height} (rn/get-window)
346+
context (rf/sub [:chats/current-chat-message-list-view-context])
347+
messages (rf/sub [:chats/raw-chat-messages-stream chat-id])
348+
recording? (rf/sub [:chats/recording?])]
344349
[rn/view {:style {:flex 3}} ;; Pushes composer to bottom
345350
[rn/view {:style {:flex-shrink 1}} ;; Keeps flat list on top
346351
[reanimated/flat-list

src/status_im/contexts/profile/contact/add_nickname/view.cljs

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
[]
1515
(let [{:keys [public-key primary-name nickname customization-color]
1616
:as profile} (rf/sub [:contacts/current-contact])
17-
;; TODO(@mohsen): remove default color,
18-
;; https://github.com/status-im/status-mobile/issues/18733
19-
customization-color (or customization-color constants/profile-default-color)
17+
customization-color customization-color
2018
full-name (profile.utils/displayed-name profile)
2119
profile-picture (profile.utils/photo profile)
2220
[unsaved-nickname set-unsaved-nickname] (rn/use-state nickname)

src/status_im/contexts/profile/contact/block_contact/view.cljs

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
[]
1414
(let [{:keys [customization-color contact-request-state public-key]
1515
:as contact} (rf/sub [:contacts/current-contact])
16-
;; TODO(@mohsen): remove default color,
17-
;; https://github.com/status-im/status-mobile/issues/18733
18-
customization-color (or customization-color constants/profile-default-color)
16+
customization-color customization-color
1917
full-name (profile.utils/displayed-name contact)
2018
profile-picture (profile.utils/photo contact)
2119
on-block-press (rn/use-callback

src/status_im/contexts/profile/contact/contact_request/view.cljs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
[]
1313
(let [{:keys [public-key customization-color]
1414
:as profile} (rf/sub [:contacts/current-contact])
15-
;; TODO: remove default color when #18733 merged.
16-
customization-color (or customization-color constants/profile-default-color)
15+
customization-color customization-color
1716
full-name (profile.utils/displayed-name profile)
1817
profile-picture (profile.utils/photo profile)
1918
[message set-message] (rn/use-state "")

src/status_im/contexts/profile/contact/header/view.cljs

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
(let [{:keys [public-key customization-color ens-name nickname secondary-name
3030
emoji-hash bio blocked? contact-request-state]
3131
:as contact} (rf/sub [:contacts/current-contact])
32-
;; TODO(@mohsen): remove default color,
33-
;; https://github.com/status-im/status-mobile/issues/18733
3432
customization-color (or customization-color constants/profile-default-color)
3533
full-name (profile.utils/displayed-name contact)
3634
profile-picture (profile.utils/photo contact)

src/status_im/contexts/profile/contact/view.cljs

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[quo.theme]
55
[react-native.reanimated :as reanimated]
66
[status-im.common.scroll-page.view :as scroll-page]
7-
[status-im.constants :as constants]
87
[status-im.contexts.profile.contact.actions.view :as actions]
98
[status-im.contexts.profile.contact.header.view :as contact-header]
109
[status-im.contexts.shell.jump-to.constants :as jump-to.constants]
@@ -25,16 +24,15 @@
2524
(defn view
2625
[]
2726
(let [{:keys [customization-color]} (rf/sub [:contacts/current-contact])
27+
profile-customization-color (rf/sub [:profile/customization-color])
2828
scroll-y (reanimated/use-shared-value 0)
2929
theme (quo.theme/use-theme-value)]
3030
[:<>
3131
[scroll-page/scroll-page
3232
{:navigate-back? true
3333
:height 148
3434
:on-scroll #(reanimated/set-shared-value scroll-y %)
35-
;; TODO(@mohsen): remove default color,
36-
;; https://github.com/status-im/status-mobile/issues/18733
37-
:cover-color (colors/resolve-color (or customization-color constants/profile-default-color)
35+
:cover-color (colors/resolve-color customization-color
3836
theme
3937
20)
4038
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)
@@ -45,7 +43,7 @@
4543
[quo/floating-shell-button
4644
{:jump-to
4745
{:on-press on-jump-to
48-
:customization-color customization-color
46+
:customization-color profile-customization-color
4947
:label (i18n/label :t/jump-to)}}
5048
{:position :absolute
5149
:bottom jump-to.constants/floating-shell-button-height}]]))

src/status_im/contexts/profile/edit/accent_colour/view.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
unsaved-custom-color (reagent/atom customization-color constants/profile-default-color)
1717
on-change #(reset! unsaved-custom-color %)]
1818
(fn [{:keys [customization-color]}]
19-
(let [profile (rf/sub [:profile/profile-with-image])
19+
(let [profile (rf/sub [:profile/profile-with-image
20+
{:customization-color @unsaved-custom-color}])
2021
profile-picture (profile.utils/photo profile)
2122
display-name (profile.utils/displayed-name profile)]
2223
(rn/use-effect

src/status_im/contexts/profile/settings/events.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
(let [{:keys [name preferred-name display-name]} (:profile/profile db)]
3030
[:json-rpc/call
3131
[{:method "wakuext_sendContactUpdates"
32-
:params [(or preferred-name display-name name) ""]
32+
:params [(or preferred-name display-name name) "" ""]
3333
:on-success #(log/debug "sent contact update")}]]))]}))
3434

3535
(rf/reg-event-fx :profile.settings/change-webview-debug

src/status_im/subs/contact.cljs

+9-8
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
(defn- replace-contact-image-uri
3636
[contact port public-key font-file]
3737
(let [theme (theme/get-theme)
38-
{:keys [images ens-name]} contact
38+
{:keys [images ens-name customization-color]} contact
3939
images
4040
(reduce (fn [acc image]
4141
(let [image-name (:type image)
@@ -63,13 +63,14 @@
6363
images
6464
{:thumbnail
6565
{:fn (image-server/get-initials-avatar-uri-fn
66-
{:port port
67-
:ratio pixel-ratio/ratio
68-
:public-key public-key
69-
:override-ring? (when ens-name false)
70-
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
71-
:theme theme
72-
:font-file font-file})}})]
66+
{:port port
67+
:ratio pixel-ratio/ratio
68+
:public-key public-key
69+
:override-ring? (when ens-name false)
70+
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
71+
:customization-color customization-color
72+
:theme theme
73+
:font-file font-file})}})]
7374

7475
(assoc contact :images images)))
7576

src/status_im/subs/profile.cljs

+40-37
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
:<- [:mediaserver/port]
6262
:<- [:initials-avatar-font-file]
6363
(fn [[profiles port font-file] [_ target-key-uid]]
64-
(let [{:keys [images ens-name?] :as profile} (get profiles target-key-uid)
65-
image-name (-> images first :type)
66-
override-ring? (when ens-name? false)]
64+
(let [{:keys [images ens-name? customization-color] :as profile} (get profiles target-key-uid)
65+
image-name (-> images first :type)
66+
override-ring? (when ens-name? false)]
6767
(when profile
6868
{:fn
6969
(if image-name
@@ -74,13 +74,14 @@
7474
:theme (theme/get-theme)
7575
:override-ring? override-ring?})
7676
(image-server/get-initials-avatar-uri-fn
77-
{:port port
78-
:ratio pixel-ratio/ratio
79-
:key-uid target-key-uid
80-
:theme (theme/get-theme)
81-
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
82-
:override-ring? override-ring?
83-
:font-file font-file}))}))))
77+
{:port port
78+
:ratio pixel-ratio/ratio
79+
:key-uid target-key-uid
80+
:theme (theme/get-theme)
81+
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
82+
:customization-color customization-color
83+
:override-ring? override-ring?
84+
:font-file font-file}))}))))
8485

8586
;; DEPRECATED
8687
;; use `:profile/public-key` instead
@@ -319,33 +320,35 @@
319320

320321
(defn- replace-multiaccount-image-uri
321322
[profile ens-names port font-file avatar-opts]
322-
(let [{:keys [key-uid ens-name? images]} profile
323-
ens-name? (or ens-name? (seq ens-names))
324-
theme (theme/get-theme)
325-
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
326-
images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}]
327-
(let [uri-fn (image-server/get-account-image-uri-fn
328-
(merge
329-
{:port port
330-
:ratio pixel-ratio/ratio
331-
:image-name image-name
332-
:key-uid key-uid
333-
:theme theme}
334-
avatar-opts))]
335-
(assoc image :fn uri-fn)))
336-
images)
337-
new-images (if (seq images-with-uri)
338-
images-with-uri
339-
[{:fn (image-server/get-initials-avatar-uri-fn
340-
(merge {:port port
341-
:ratio pixel-ratio/ratio
342-
:uppercase-ratio
343-
(:uppercase-ratio
344-
constants/initials-avatar-font-conf)
345-
:key-uid key-uid
346-
:theme theme
347-
:font-file font-file}
348-
avatar-opts))}])]
323+
(let [{:keys [key-uid ens-name? images
324+
customization-color]} profile
325+
ens-name? (or ens-name? (seq ens-names))
326+
theme (theme/get-theme)
327+
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
328+
images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}]
329+
(let [uri-fn (image-server/get-account-image-uri-fn
330+
(merge
331+
{:port port
332+
:ratio pixel-ratio/ratio
333+
:image-name image-name
334+
:key-uid key-uid
335+
:theme theme}
336+
avatar-opts))]
337+
(assoc image :fn uri-fn)))
338+
images)
339+
new-images (if (seq images-with-uri)
340+
images-with-uri
341+
[{:fn (image-server/get-initials-avatar-uri-fn
342+
(merge {:port port
343+
:ratio pixel-ratio/ratio
344+
:uppercase-ratio
345+
(:uppercase-ratio
346+
constants/initials-avatar-font-conf)
347+
:key-uid key-uid
348+
:customization-color customization-color
349+
:theme theme
350+
:font-file font-file}
351+
avatar-opts))}])]
349352
(assoc profile :images new-images)))
350353

351354
(re-frame/reg-sub

0 commit comments

Comments
 (0)