fix profile photo icon - no border in non-identicon photo
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
66b982c3fb
commit
843de6aa90
|
@ -2,18 +2,21 @@
|
|||
(:require [clojure.string :as string]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.screens.chat.styles.photos :as style]
|
||||
[status-im.ui.screens.profile.db :as profile.db]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
[status-im.utils.image :as utils.image])
|
||||
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
|
||||
|
||||
(defn photo [photo-path {:keys [size
|
||||
accessibility-label]}]
|
||||
[react/view {:style (style/photo-container size)}
|
||||
[react/image {:source (utils.image/source photo-path)
|
||||
:style (style/photo size)
|
||||
:resize-mode :cover
|
||||
:accessibility-label (or accessibility-label :chat-icon)}]
|
||||
[react/view {:style (style/photo-border size)}]])
|
||||
(let [identicon? (when photo-path (profile.db/base64-png? photo-path))]
|
||||
[react/view {:style (style/photo-container size)}
|
||||
[react/image {:source (utils.image/source photo-path)
|
||||
:style (style/photo size)
|
||||
:resize-mode :cover
|
||||
:accessibility-label (or accessibility-label :chat-icon)}]
|
||||
(when identicon?
|
||||
[react/view {:style (style/photo-border size)}])]))
|
||||
|
||||
(defview member-photo [from & [size]]
|
||||
(letsubs [photo-path [:chats/photo-path from]]
|
||||
|
|
|
@ -9,9 +9,15 @@
|
|||
[(string/blank? username)
|
||||
(string/includes? username chat.constants/command-char)])))
|
||||
|
||||
(defn base64-png? [photo-path]
|
||||
(string/starts-with? photo-path "data:image/png;base64,"))
|
||||
|
||||
(defn base64-jpeg? [photo-path]
|
||||
(string/starts-with? photo-path "data:image/jpeg;base64,"))
|
||||
|
||||
(defn base64-encoded-image-path? [photo-path]
|
||||
(or (string/starts-with? photo-path "data:image/jpeg;base64,")
|
||||
(string/starts-with? photo-path "data:image/png;base64,")))
|
||||
(or (base64-png? photo-path)
|
||||
(base64-jpeg? photo-path)))
|
||||
|
||||
(spec/def :profile/name correct-name?)
|
||||
(spec/def :profile/status (spec/nilable string?))
|
||||
|
|
Loading…
Reference in New Issue