mirror of
https://github.com/status-im/status-react.git
synced 2025-01-27 03:06:39 +00:00
Detect image dimensions correctly
This commit is contained in:
parent
dbc8df251a
commit
671aa67002
@ -8,6 +8,10 @@
|
|||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.url :as url]))
|
[utils.url :as url]))
|
||||||
|
|
||||||
|
;; these constants are used when there is no width or height defined for a specific image
|
||||||
|
(def ^:const fallback-image-width 1000)
|
||||||
|
(def ^:const fallback-image-height 1000)
|
||||||
|
|
||||||
(defn calculate-dimensions
|
(defn calculate-dimensions
|
||||||
[width height max-container-width max-container-height]
|
[width height max-container-width max-container-height]
|
||||||
(let [max-width (if (> width height) max-container-width (* 1.5 constants/image-size))
|
(let [max-width (if (> width height) max-container-width (* 1.5 constants/image-size))
|
||||||
@ -15,7 +19,12 @@
|
|||||||
{:width (min width max-width) :height (min height max-height)}))
|
{:width (min width max-width) :height (min height max-height)}))
|
||||||
|
|
||||||
(defn image-message
|
(defn image-message
|
||||||
[index {:keys [content image-width image-height message-id] :as message} {:keys [on-long-press]}
|
[index
|
||||||
|
{:keys [content image-width image-height message-id]
|
||||||
|
:as message
|
||||||
|
:or {image-width fallback-image-width
|
||||||
|
image-height fallback-image-height}}
|
||||||
|
{:keys [on-long-press]}
|
||||||
message-container-data]
|
message-container-data]
|
||||||
(let [insets (safe-area/get-insets)
|
(let [insets (safe-area/get-insets)
|
||||||
{:keys [window-width padding-left padding-right avatar-container-width
|
{:keys [window-width padding-left padding-right avatar-container-width
|
||||||
|
Loading…
x
Reference in New Issue
Block a user