Compare commits

..
Author SHA1 Message Date
Andrea Maria Piana 51687e23bd disable password 2024-05-08 11:31:47 +01:00
24 changed files with 274 additions and 300 deletions
@@ -12,8 +12,7 @@
[re-frame.core :as re-frame.core]
[react-native.core :as rn]
[status-im.contexts.profile.utils :as profile.utils]
[utils.ens.core :as utils.ens]
[utils.image-server :as image-server]))
[utils.ens.core :as utils.ens]))
;;TODO REWORK THIS NAMESPACE
@@ -157,11 +156,9 @@
(styles/default-chat-icon-text size)
(styles/emoji-chat-icon-text size))}
override-styles)
img-config (:config photo-path)
photo-path (if img-config
photo-path (if (:fn photo-path)
;; temp support new media server avatar for old component
{:uri (image-server/get-image-uri
img-config
{:uri ((:fn photo-path)
{:size size
:full-name name
:font-size (get-in styles [:default-chat-icon-text :font-size])
@@ -8,7 +8,6 @@
[react-native.core :as rn]
[react-native.fast-image :as fast-image]
[schema.core :as schema]
[utils.image-server :as image-server]
utils.string))
(defn initials-avatar
@@ -39,23 +38,23 @@
online? true
ring? true}
:as props}]
(let [theme (quo.theme/use-theme)
picture-config (:config profile-picture)
full-name (or full-name "Your Name")
(let [theme (quo.theme/use-theme)
full-name (or full-name "Your Name")
;; image generated with `profile-picture-fn` is round cropped
;; no need to add border-radius for them
outer-styles (style/outer size (not picture-config))
outer-styles (style/outer size (not (:fn profile-picture)))
;; Once image is loaded, fast image re-renders view with the help of reagent atom,
;; But dynamic updates don't work when user-avatar is used inside hole-view
;; https://github.com/status-im/status-mobile/issues/15553
image-view (if static? no-flicker-image/image fast-image/fast-image)
font-size (get-in style/sizes [size :font-size])
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)
sizes (get style/sizes size)
indicator-color (get (style/indicator-color theme) (if online? :online :offline))]
image-view (if static? no-flicker-image/image fast-image/fast-image)
font-size (get-in style/sizes [size :font-size])
amount-initials (if (#{:xs :xxs :xxxs} size) 1 2)
sizes (get style/sizes size)
indicator-color (get (style/indicator-color theme) (if online? :online :offline))
profile-picture-fn (:fn profile-picture)]
[rn/view {:style outer-styles :accessibility-label :user-avatar}
(if (and full-name (not (or picture-config profile-picture)))
(if (and full-name (not (or profile-picture-fn profile-picture)))
;; this is for things that's not user-avatar but are currently using user-avatar to render
;; the initials e.g. community avatar
[initials-avatar props]
@@ -63,9 +62,8 @@
{:accessibility-label :profile-picture
:style outer-styles
:source
(cond picture-config
{:uri (image-server/get-image-uri
picture-config
(cond profile-picture-fn
{:uri (profile-picture-fn
{:length amount-initials
:full-name full-name
:font-size (:font-size (text/text-style {:size
@@ -78,7 +76,7 @@
:indicator-center-to-edge (when status-indicator?
(:status-indicator-center-to-edge sizes))
:indicator-color indicator-color
:theme theme
:override-theme theme
:color (:color style/initials-avatar-text)
:size (:width outer-styles)
:ring? ring?
@@ -24,7 +24,7 @@
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)}} text]])
(defn view
[{:keys [buy-action send-action receive-action bridge-action swap-action container-style]}]
[{:keys [buy-action send-action receive-action bridge-action container-style]}]
(let [theme (quo.theme/use-theme)]
[rn/view {:style container-style}
[rn/view {:style style/inner-container}
@@ -46,13 +46,6 @@
:on-press receive-action
:theme theme
:accessibility-label :receive}]
(when swap-action
[action-button
{:icon :i/swap
:text (i18n/label :t/swap)
:on-press swap-action
:theme theme
:accessibility-label :swap}])
[action-button
{:icon :i/bridge
:text (i18n/label :t/bridge)
@@ -8,10 +8,9 @@
[rn/view {:style (assoc container-style :flex-direction :row)}
(map-indexed
(fn [index action]
(when action
^{:key index}
[:<>
[channel-action/view action]
(when (not= action (last actions))
[rn/view {:style {:width 16}}])]))
^{:key index}
[:<>
[channel-action/view action]
(when (not= action (last actions))
[rn/view {:width 16}])])
actions)])
+7 -54
View File
@@ -3,9 +3,7 @@
[quo.foundations.colors :as colors]
[schema.registry :as registry]))
(def ^:private ?customization-color (into [:enum :primary] colors/account-colors))
(def ^:private ?profile-picture-options
(def ^:private ?profile-picture-fn-params
[:map
[:length :int]
[:full-name :string]
@@ -13,67 +11,22 @@
[:indicator-size {:optional true} [:maybe :int]]
[:indicator-color {:optional true} [:maybe :string]]
[:indicator-center-to-edge {:optional true} [:maybe :int]]
[:theme :schema.common/theme]
[:override-theme :schema.common/theme]
[:background-color :string]
[:color :string]
[:size :int]
[:ring? :boolean]
[:ring-width :int]])
(def ^:private ?account-image-uri-options
[:map
[:port :int]
[:ratio :double]
[:key-uid :string]
[:image-name :string]
[:theme :schema.common/theme]
[:override-ring? [:maybe :boolean]]])
(def ^:private ?initials-image-uri-options
[:map
[:port :int]
[:ratio :double]
[:uppercase-ratio :double]
[:font-file :string]
[:theme :schema.common/theme]
[:customization-color ?customization-color]
[:key-uid {:optional true} [:maybe :string]]
[:public-key {:optional true} [:maybe :string]]
[:override-ring? {:optional true} [:maybe :boolean]]])
(def ^:private ?contact-image-uri-options
[:map
[:port :int]
[:clock :int]
[:ratio :double]
[:image-name :string]
[:public-key :string]
[:theme :schema.common/theme]
[:override-ring? [:maybe :boolean]]])
(def ^:private ?image-uri-config
[:multi {:dispatch :type}
[:account
[:map
[:type [:= :account]]
[:options ?account-image-uri-options]]]
[:contact
[:map
[:type [:= :contact]]
[:options ?contact-image-uri-options]]]
[:initials
[:map
[:type [:= :initials]]
[:options ?initials-image-uri-options]]]])
(def ^:private ?profile-picture-source
[:or
:schema.common/image-source
[:map
[:config ?image-uri-config]]])
[:fn [:=> [:cat ?profile-picture-fn-params] :string]]]])
(def ^:private ?customization-color (into [:enum] colors/account-colors))
(defn register-schemas
[]
(registry/register ::customization-color ?customization-color)
(registry/register ::image-uri-config ?image-uri-config)
(registry/register ::profile-picture-source ?profile-picture-source)
(registry/register ::profile-picture-options ?profile-picture-options))
(registry/register ::customization-color ?customization-color))
@@ -78,10 +78,9 @@
(defn add-character
[state character]
(if (can-add-character? state character)
(when (can-add-character? state character)
(set-input-value state
(normalize-value-as-numeric (input-value state) character))
state))
(normalize-value-as-numeric (input-value state) character))))
(defn delete-last
[state]
+11 -6
View File
@@ -365,21 +365,23 @@
:sub-label nil
:chevron? false}))
;; TODO(OmarBasem): to be implemented.
(defn add-members-entry
[chat-id]
[]
(entry {:icon :i/add-user
:label (i18n/label :t/add-members)
:on-press #(rf/dispatch [:open-modal :group-add-manage-members chat-id])
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :add-members
:sub-label nil
:chevron? false}))
;; TODO(OmarBasem): to be implemented.
(defn manage-members-entry
[chat-id]
[]
(entry {:icon :i/add-user
:label (i18n/label :t/manage-members)
:on-press #(rf/dispatch [:open-modal :group-add-manage-members chat-id])
:on-press #(js/alert "TODO: to be implemented")
:danger? false
:accessibility-label :manage-members
:sub-label nil
@@ -433,8 +435,11 @@
admin? (get admins current-pub-key)]
[(group-details-entry chat-id)
(when inside-chat?
(when admin?
(manage-members-entry chat-id)))
(if admin?
(when config/show-not-implemented-features?
(manage-members-entry))
(when config/show-not-implemented-features?
(add-members-entry))))
(when (and admin? inside-chat?)
(when config/show-not-implemented-features?
(edit-group-entry)))
@@ -4,7 +4,6 @@
[quo.foundations.colors :as colors]
[quo.theme]
[react-native.core :as rn]
[react-native.gesture :as gesture]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.common.contact-list-item.view :as contact-list-item]
@@ -44,11 +43,12 @@
(defn add-manage-members
[]
(let [selected-participants (rf/sub [:group-chat/selected-participants])
deselected-members (rf/sub [:group-chat/deselected-members])
chat-id (rf/sub [:get-screen-params :group-add-manage-members])
group (rf/sub [:chats/chat-by-id chat-id])
theme (quo.theme/use-theme)]
(let [selected-participants (rf/sub [:group-chat/selected-participants])
deselected-members (rf/sub [:group-chat/deselected-members])
chat-id (rf/sub [:get-screen-params :group-details])
{:keys [admins] :as group} (rf/sub [:chats/chat-by-id chat-id])
theme (quo.theme/use-theme)
admin? (get admins (rf/sub [:multiaccount/public-key]))]
[rn/view {:flex 1 :margin-top 20}
[rn/touchable-opacity
{:on-press #(rf/dispatch [:navigate-back])
@@ -59,8 +59,8 @@
{:size :heading-1
:weight :semi-bold
:style {:margin-left 20}}
(i18n/label :t/manage-members)]
[gesture/section-list
(i18n/label (if admin? :t/manage-members :t/add-members))]
[rn/section-list
{:key-fn :title
:sticky-section-headers-enabled false
:sections (rf/sub [:contacts/grouped-by-first-letter])
@@ -139,8 +139,7 @@
:customization-color color}}]
[quo/channel-actions
{:container-style style/actions-view
:actions [{:big? (not admin?)
:accessibility-label :pinned-messages
:actions [{:accessibility-label :pinned-messages
:label (i18n/label :t/pinned-messages)
:customization-color color
:icon :i/pin
@@ -156,17 +155,16 @@
:on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted)
(when-not muted
constants/mute-till-unmuted)])}
(when admin?
{:accessibility-label :manage-members
:customization-color color
:icon :i/add-user
:label (i18n/label :t/manage-members)
:counter-value (count contacts)
:on-press (fn []
(rf/dispatch [:group/clear-added-participants])
(rf/dispatch [:group/clear-removed-members])
(rf/dispatch [:open-modal :group-add-manage-members
chat-id]))})]}]
{:accessibility-label :manage-members
:customization-color color
:icon :i/add-user
:label (i18n/label (if admin? :t/manage-members :t/add-members))
:counter-value (count contacts)
:on-press (fn []
(rf/dispatch [:group/clear-added-participants])
(rf/dispatch [:group/clear-removed-members])
(rf/dispatch [:open-modal :group-add-manage-members
chat-id]))}]}]
[rn/section-list
{:key-fn :title
:sticky-section-headers-enabled false
@@ -14,5 +14,4 @@
:buy-action #(js/alert "Buy button pressed")
:send-action #(js/alert "Send button pressed")
:receive-action #(js/alert "Receive button pressed")
:bridge-action #(js/alert "Bridge button pressed")
:swap-action #(js/alert "Swap button pressed")}]])
:bridge-action #(js/alert "Bridge button pressed")}]])
@@ -33,11 +33,12 @@
{:type :wallet-networks
:on-press #(rf/dispatch [:wallet/close-account-page])}]
[quo/account-overview
{:current-value formatted-balance
{:container-style style/account-overview
:current-value formatted-balance
:account-name name
:account (if watch-only? :watched-address :default)
:customization-color color}]
[quo/wallet-graph {:time-frame :empty}]
(when (ff/enabled? ::ff/wallet.graph) [quo/wallet-graph {:time-frame :empty}])
(when (not watch-only?)
[quo/wallet-ctas
{:container-style style/cta-buttons
@@ -45,18 +46,12 @@
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-send-flow}]))
:flow-id :wallet-flow}]))
:receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address
{:status :receive}])
:buy-action #(rf/dispatch [:show-bottom-sheet
{:content buy-token/view}])
:bridge-action (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:wallet/wizard-navigate-forward
{:start-flow? true
:flow-id :wallet-bridge-flow}]))
:swap-action (when (ff/enabled? ::ff/wallet.swap)
#(rf/dispatch [:wallet/start-swap]))}])
:bridge-action #(rf/dispatch [:wallet/start-bridge])}])
[quo/tabs
{:style style/tabs
:size 32
@@ -1,11 +0,0 @@
(ns status-im.contexts.wallet.bridge.flow-config)
(def steps
[{:screen-id :screen/wallet.bridge-select-asset
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :token])))}
{:screen-id :screen/wallet.bridge-to
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :bridge-to-chain-id])))}
{:screen-id :screen/wallet.bridge-input-amount
:skip-step? (fn [db] (some? (get-in db [:wallet :ui :send :amount])))}
{:screen-id :screen/wallet.transaction-confirmation}
{:screen-id :screen/wallet.transaction-progress}])
@@ -34,13 +34,11 @@
:on-press #(rf/dispatch [:open-modal :screen/wallet.share-address {:status :receive}])})
(defn- action-bridge
[token-data]
[]
{:icon :i/bridge
:accessibility-label :bridge
:label (i18n/label :t/bridge)
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:wallet/bridge-select-token {:token token-data}]))})
:on-press #(js/alert "to be implemented")})
(defn- action-manage-tokens
[watch-only?]
@@ -68,7 +66,7 @@
(not watch-only?) (concat [(action-buy)
(action-send token-data)
(action-receive)
(action-bridge token-data)]))]]))
(action-bridge)]))]]))
(defn view
[item _ _ {:keys [watch-only?]}]
@@ -0,0 +1,22 @@
(ns status-im.contexts.wallet.common.wizard
(:require [status-im.contexts.wallet.send.flow-config :as wallet-flow]
[utils.re-frame :as rf]))
(defn- wizard-find-next-screen
[db flow-id current-screen]
(let [flow-config (case flow-id
:wallet-flow wallet-flow/steps
nil)]
(first (filter (fn [{:keys [skip-step? screen-id]}]
(and (not= screen-id current-screen)
(not (and (fn? skip-step?) (skip-step? db)))))
flow-config))))
(rf/reg-event-fx
:wallet/wizard-navigate-forward
(fn [{:keys [db]} [{:keys [current-screen flow-id start-flow?]}]]
(let [next-screen (wizard-find-next-screen db flow-id current-screen)]
{:fx [[:dispatch
(if start-flow?
[:open-modal (:screen-id next-screen)]
[:navigate-to-within-stack [(:screen-id next-screen) current-screen]])]]})))
@@ -1,13 +1,11 @@
(ns status-im.contexts.wallet.common.wizard.events
(:require [status-im.contexts.wallet.bridge.flow-config :as wallet-bridge-flow]
[status-im.contexts.wallet.send.flow-config :as wallet-send-flow]
(:require [status-im.contexts.wallet.send.flow-config :as wallet-flow]
[utils.re-frame :as rf]))
(defn- wizard-find-next-screen
[db flow-id current-screen]
(let [flow-config (case flow-id
:wallet-send-flow wallet-send-flow/steps
:wallet-bridge-flow wallet-bridge-flow/steps
:wallet-flow wallet-flow/steps
nil)]
(first (filter (fn [{:keys [skip-step? screen-id]}]
(and (not= screen-id current-screen)
+3 -11
View File
@@ -247,13 +247,8 @@
(let [to-address (get-in db [:wallet :current-viewing-account-address])]
{:db (-> db
(assoc-in [:wallet :ui :send :token] token)
(assoc-in [:wallet :ui :send :to-address] to-address)
(assoc-in [:wallet :ui :send :tx-type] :bridge))
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? true
:flow-id :wallet-bridge-flow}]]]})))
(assoc-in [:wallet :ui :send :to-address] to-address))
:fx [[:dispatch [:navigate-to-within-stack [:screen/wallet.bridge-to stack-id]]]]})))
(rf/reg-event-fx :wallet/start-bridge
(fn [{:keys [db]}]
@@ -263,10 +258,7 @@
(rf/reg-event-fx :wallet/select-bridge-network
(fn [{:keys [db]} [{:keys [network-chain-id stack-id]}]]
{:db (assoc-in db [:wallet :ui :send :bridge-to-chain-id] network-chain-id)
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:flow-id :wallet-bridge-flow}]]]}))
:fx [[:dispatch [:navigate-to-within-stack [:screen/wallet.bridge-input-amount stack-id]]]]}))
(rf/reg-event-fx
:wallet/get-ethereum-chains
@@ -146,7 +146,7 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]})))
:flow-id :wallet-flow}]]]})))
(rf/reg-event-fx
:wallet/update-receiver-networks
@@ -174,7 +174,7 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]}))
:flow-id :wallet-flow}]]]}))
(rf/reg-event-fx
:wallet/edit-token-to-send
@@ -236,7 +236,7 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]}))
:flow-id :wallet-flow}]]]}))
(rf/reg-event-fx :wallet/disable-from-networks
(fn [{:keys [db]} [chain-ids]]
@@ -339,7 +339,7 @@
:fx [[:dispatch
[:wallet/wizard-navigate-forward
{:current-screen :screen/wallet.transaction-confirmation
:flow-id :wallet-send-flow}]]]})))
:flow-id :wallet-flow}]]]})))
(rf/reg-event-fx :wallet/close-transaction-progress-page
(fn [_]
@@ -509,4 +509,4 @@
[:wallet/wizard-navigate-forward
{:current-screen stack-id
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]}))
:flow-id :wallet-flow}]]]}))
@@ -1,10 +0,0 @@
(ns status-im.contexts.wallet.swap.events
(:require [re-frame.core :as rf]))
(rf/reg-event-fx :wallet/start-swap
(fn [{:keys [_db]}]
{:fx [[:dispatch
[:toasts/upsert
{:id :swap-error
:type :negative
:text "Swap is under construction"}]]]}))
-1
View File
@@ -39,7 +39,6 @@
status-im.contexts.wallet.events
status-im.contexts.wallet.send.events
status-im.contexts.wallet.signals
status-im.contexts.wallet.swap.events
[status-im.db :as db]
status-im.navigation.effects
status-im.navigation.events
-1
View File
@@ -20,7 +20,6 @@
::wallet.graph (enabled-in-env? :FLAG_GRAPH_ENABLED)
::wallet.import-private-key (enabled-in-env? :FLAG_IMPORT_PRIVATE_KEY_ENABLED)
::wallet.long-press-watch-only-asset (enabled-in-env? :FLAG_LONG_PRESS_WATCH_ONLY_ASSET_ENABLED)
::wallet.swap (enabled-in-env? :FLAG_SWAP_ENABLED)
::wallet.wallet-connect (enabled-in-env? :FLAG_WALLET_CONNECT_ENABLED)}))
(defn feature-flags [] @feature-flags-config)
+1 -2
View File
@@ -392,8 +392,7 @@
:component wallet-bridge-select-asset/view}
{:name :screen/wallet.bridge-to
:options {:insets {:top? true}
:modalPresentationStyle :overCurrentContext}
:options {:insets {:top? true}}
:component wallet-bridge-to/view}
{:name :screen/wallet.bridge-input-amount
+32 -46
View File
@@ -8,10 +8,10 @@
[status-im.common.pixel-ratio :as pixel-ratio]
[status-im.constants :as constants]
[status-im.contexts.profile.utils :as profile.utils]
[status-im.subs.chat.utils :as chat.utils]
[utils.address :as address]
[utils.collection]
[utils.i18n :as i18n]))
[utils.i18n :as i18n]
[utils.image-server :as image-server]))
(defn query-chat-contacts
[{:keys [contacts]} all-contacts query-fn]
@@ -44,40 +44,37 @@
(reduce (fn [acc image]
(let [image-name (:type image)
clock (:clock image)
options {:port port
:ratio pixel-ratio/ratio
:public-key
public-key
:image-name
image-name
; We pass the clock so that we reload the
; image if the image is updated
:clock
clock
:theme
theme
:override-ring?
(when ens-name false)}]
(assoc-in acc
[(keyword image-name) :config]
{:type :contact
:options options})))
uri (image-server/get-contact-image-uri-fn
{:port port
:ratio pixel-ratio/ratio
:public-key
public-key
:image-name
image-name
; We pass the clock so that we reload the
; image if the image is updated
:clock
clock
:theme
theme
:override-ring?
(when ens-name false)})]
(assoc-in acc [(keyword image-name) :fn] uri)))
images
(vals images))
images (if (seq images)
images
{:thumbnail
{:config {:type :initials
:options {:port port
:ratio pixel-ratio/ratio
:public-key public-key
:override-ring? (when ens-name false)
:uppercase-ratio (:uppercase-ratio
constants/initials-avatar-font-conf)
:customization-color customization-color
:theme theme
:font-file font-file}}}})]
{:fn (image-server/get-initials-avatar-uri-fn
{:port port
:ratio pixel-ratio/ratio
:public-key public-key
:override-ring? (when ens-name false)
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
:customization-color customization-color
:theme theme
:font-file font-file})}})]
(assoc contact :images images)))
@@ -154,7 +151,7 @@
(fn [[members contacts]]
(-> (reduce
(fn [acc contact]
(let [first-char (first (:primary-name contact))]
(let [first-char (first (:alias contact))]
(if (get acc first-char)
(update-in acc [first-char :data] #(conj % contact))
(assoc acc first-char {:title first-char :data [contact]}))))
@@ -168,7 +165,7 @@
:<- [:contacts/active]
(fn [active-contacts]
(->> active-contacts
(sort-by :primary-name)
(sort-by :alias)
(sort-by
#(visibility-status-utils/visibility-status-order (:public-key %))))))
@@ -361,20 +358,9 @@
(re-frame/reg-sub
:contacts/group-members-sections
(fn [[_ chat-id]]
[(re-frame/subscribe [:contacts/contacts-by-chat chat-id])
(re-frame/subscribe [:visibility-status-updates])
(re-frame/subscribe [:multiaccount/public-key])
(re-frame/subscribe [:multiaccount/current-user-visibility-status])])
(fn [[members status-updates current-user-public-key current-user-visibility-status]]
(let [members (map (fn [{:keys [public-key] :as member}]
(assoc member
:online?
(chat.utils/online?
(if (= public-key current-user-public-key)
(:status-type current-user-visibility-status)
(get-in status-updates [public-key :status-type])))))
members)
admins (filter :admin? members)
[(re-frame/subscribe [:contacts/contacts-by-chat chat-id])])
(fn [[members]]
(let [admins (filter :admin? members)
online (filter #(and (not (:admin? %)) (:online? %)) members)
offline (filter #(and (not (:admin? %)) (not (:online? %))) members)]
(vals (cond-> {}
+37 -39
View File
@@ -10,6 +10,7 @@
[status-im.common.pixel-ratio :as pixel-ratio]
[status-im.constants :as constants]
[status-im.contexts.profile.utils :as profile.utils]
[utils.image-server :as image-server]
[utils.security.core :as security]))
(re-frame/reg-sub
@@ -42,24 +43,23 @@
image-name (-> images first :type)
override-ring? (when ens-name? false)]
(when profile
{:config
{:fn
(if image-name
{:type :account
:options {:port port
:ratio pixel-ratio/ratio
:image-name image-name
:key-uid target-key-uid
:theme theme
:override-ring? override-ring?}}
{:type :initials
:options {:port port
:ratio pixel-ratio/ratio
:key-uid target-key-uid
:theme theme
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
:customization-color customization-color
:override-ring? override-ring?
:font-file font-file}})}))))
(image-server/get-account-image-uri-fn {:port port
:ratio pixel-ratio/ratio
:image-name image-name
:key-uid target-key-uid
:theme theme
:override-ring? override-ring?})
(image-server/get-initials-avatar-uri-fn
{:port port
:ratio pixel-ratio/ratio
:key-uid target-key-uid
:theme theme
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
:customization-color customization-color
:override-ring? override-ring?
:font-file font-file}))}))))
;; DEPRECATED
;; use `:profile/public-key` instead
@@ -244,31 +244,29 @@
ens-name? (or ens-name? (seq ens-names))
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}]
(assoc image
:config
{:type :account
:options (merge
{:port port
:ratio pixel-ratio/ratio
:image-name image-name
:key-uid key-uid
:theme theme}
avatar-opts)}))
(let [uri-fn (image-server/get-account-image-uri-fn
(merge
{:port port
:ratio pixel-ratio/ratio
:image-name image-name
:key-uid key-uid
:theme theme}
avatar-opts))]
(assoc image :fn uri-fn)))
images)
new-images (if (seq images-with-uri)
images-with-uri
[{:config {:type :initials
:options (merge
{:port port
:ratio pixel-ratio/ratio
:uppercase-ratio
(:uppercase-ratio
constants/initials-avatar-font-conf)
:key-uid key-uid
:customization-color customization-color
:theme theme
:font-file font-file}
avatar-opts)}}])]
[{:fn (image-server/get-initials-avatar-uri-fn
(merge {:port port
:ratio pixel-ratio/ratio
:uppercase-ratio
(:uppercase-ratio
constants/initials-avatar-font-conf)
:key-uid key-uid
:customization-color customization-color
:theme theme
:font-file font-file}
avatar-opts))}])]
(assoc profile :images new-images)))
(re-frame/reg-sub
+99 -31
View File
@@ -4,7 +4,6 @@
[react-native.fs :as utils.fs]
[react-native.platform :as platform]
[schema.core :as schema]
[schema.quo]
[utils.datetime :as datetime]))
(def ^:const image-server-uri-prefix "https://localhost:")
@@ -55,7 +54,8 @@
4))
(defn get-account-image-uri
"fn to get the avatar uri when multiaccount has custom image set.
"fn to get the avatar uri when multiaccount has custom image set
not directly called, check `get-account-image-uri-fn`
color formats (for all color options):
#RRGGBB
@@ -67,8 +67,7 @@
placeholder-avatar: pass image file path as `image-name`
`indicator-size` is outer indicator radius
`indicator-size` - `indicator-border` is inner indicator radius
`ring?` shows or hides ring for account with ens name"
`indicator-size` - `indicator-border` is inner indicator radius"
[{:keys [port public-key image-name key-uid size theme indicator-size
indicator-border indicator-center-to-edge indicator-color ring?
ring-width ratio]}]
@@ -101,8 +100,38 @@
"&ringWidth="
(* ring-width ratio)))
(defn get-account-image-uri-fn
"pass the result fn to user-avatar component as `:profile-picture`
use this fn in subs to set multiaccount `:images` as [{:fn ...}]
pass the image to user-avatar
user-avatar can fill the rest style related options
set `override-ring?` to a non-nil value to override `ring?`, mainly used to
hide ring for account with ens name
check `get-account-image-uri` for color formats"
[{:keys [port public-key key-uid image-name theme override-ring? ratio]}]
(fn [{:keys [size indicator-size indicator-border indicator-center-to-edge
indicator-color ring? ring-width override-theme]}]
(get-account-image-uri
{:port port
:image-name image-name
:size size
:public-key public-key
:ratio ratio
:key-uid key-uid
:theme (if (nil? override-theme) theme override-theme)
:indicator-size indicator-size
:indicator-border indicator-border
:indicator-center-to-edge indicator-center-to-edge
:indicator-color indicator-color
:ring? (if (nil? override-ring?) ring? override-ring?)
:ring-width ring-width})))
(defn get-initials-avatar-uri
"fn to get the avatar uri when account/contact/placeholder has no custom pic set
not directly called, check `get-account-initials-uri-fn`
multiaccount: at least one of `key-uid`, `public-key` is required to render the ring
contact: `public-key` is required to render the ring
@@ -110,7 +139,6 @@
check `get-account-image-uri` for color formats
check `get-font-file-ready` for `font-file`
`ring?` shows or hides ring for account with ens name
`uppercase-ratio` is the uppercase-height/line-height for `font-file`"
[{:keys [port public-key key-uid theme ring? length size customization-color
color font-size font-file uppercase-ratio indicator-size
@@ -157,13 +185,56 @@
"&ringWidth="
(* ring-width ratio)))
(defn get-contact-image-uri
"check `get-account-image-uri` for color formats
(schema/=> get-initials-avatar-uri
[:=>
[:cat
[:map
[:theme :schema.common/theme]
[:color string?]
[:background-color {:optional true} [:maybe string?]]
[:size number?]
[:ratio float?]
[:uppercase-ratio number?]
[:customization-color :schema.common/customization-color]
[:font-size number?]
[:font-file string?]]]
[:string]])
(defn get-initials-avatar-uri-fn
"return a fn that calls `get-account-initials-uri`
pass the fn to user-avatar component to fill the style related options
check `get-account-image-uri` for color formats
check `get-font-file-ready` for `font-file`
`public-key` is required to render the ring
`ring?` shows or hides ring for account with ens name
`uppercase-ratio` is the uppercase-height/line-height for `font-file`"
check `get-account-image-uri-fn` for `override-ring?`"
[{:keys [port public-key key-uid theme override-ring? font-file ratio
uppercase-ratio customization-color]}]
(fn [{:keys [full-name length size font-size color indicator-size indicator-border
indicator-color indicator-center-to-edge ring? ring-width
override-theme]}]
(get-initials-avatar-uri
{:port port
:public-key public-key
:ratio ratio
:key-uid key-uid
:full-name full-name
:length length
:size size
:customization-color customization-color
:theme (if (nil? override-theme) theme override-theme)
:ring? (if (nil? override-ring?) ring? override-ring?)
:ring-width ring-width
:font-size font-size
:color color
:font-file font-file
:uppercase-ratio uppercase-ratio
:indicator-size indicator-size
:indicator-border indicator-border
:indicator-center-to-edge indicator-center-to-edge
:indicator-color indicator-color})))
(defn get-contact-image-uri
[{:keys [port public-key image-name clock theme indicator-size indicator-border
indicator-center-to-edge indicator-color size ring? ring-width ratio]}]
(str
@@ -193,6 +264,24 @@
"&ringWidth="
(* ring-width ratio)))
(defn get-contact-image-uri-fn
[{:keys [port public-key image-name theme override-ring? clock ratio]}]
(fn [{:keys [size indicator-size indicator-border indicator-center-to-edge
indicator-color ring? ring-width override-theme]}]
(get-contact-image-uri {:port port
:ratio ratio
:image-name image-name
:public-key public-key
:size size
:theme (if (nil? override-theme) theme override-theme)
:clock clock
:indicator-size indicator-size
:indicator-border indicator-border
:indicator-center-to-edge indicator-center-to-edge
:indicator-color indicator-color
:ring? (if (nil? override-ring?) ring? override-ring?)
:ring-width ring-width})))
(defn get-qr-image-uri-for-any-url
[{:keys [url port qr-size error-level]}]
(let [qr-url-base64 (js/btoa url)
@@ -210,24 +299,3 @@
"&size="
qr-size)]
media-server-url))
(defn get-image-uri
[{:keys [type options]}
profile-picture-options]
((case type
:account get-account-image-uri
:contact get-contact-image-uri
:initials get-initials-avatar-uri
str)
(-> (merge options profile-picture-options)
(assoc :ring?
(if (nil? (:override-ring? options))
(:ring? profile-picture-options)
(:override-ring? options))))))
(schema/=> get-image-uri
[:=>
[:cat
:schema.quo/image-uri-config
:schema.quo/profile-picture-options]
:string])
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.179.15",
"commit-sha1": "7ba78cd6e97ba1180e2cbab9ad8fc1e666b92a73",
"src-sha256": "0gafxkha9mcdnl91w1f786ax0z3yqgl55qblw9xazhm7lpm44vgj"
"version": "test-pr-new-release",
"commit-sha1": "0122a3237b62c89c2f65c55de0d837a1a16a88b4",
"src-sha256": "1kpgf74x416qxxsid976bhp59qh8yhmp2whd2zq0zqb8yn5iswp8"
}