fix profile photo icon - no border in non-identicon photo

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
bitsikka 2019-09-04 22:05:15 +05:45 committed by Andrey Shovkoplyas
parent 66b982c3fb
commit 843de6aa90
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
2 changed files with 17 additions and 8 deletions

View File

@ -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]}]
(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)}]
[react/view {:style (style/photo-border size)}]])
(when identicon?
[react/view {:style (style/photo-border size)}])]))
(defview member-photo [from & [size]]
(letsubs [photo-path [:chats/photo-path from]]

View File

@ -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?))