|
19 | 19 | [status-im.ui.screens.chat.message.reactions :as reactions]
|
20 | 20 | [status-im.ui.screens.chat.image.preview.views :as preview]
|
21 | 21 | [quo.core :as quo]
|
| 22 | + [taoensso.timbre :as log] |
22 | 23 | [status-im.utils.config :as config]
|
23 | 24 | [reagent.core :as reagent]
|
24 | 25 | [status-im.ui.screens.chat.components.reply :as components.reply]
|
|
341 | 342 | (def image-max-height 192)
|
342 | 343 |
|
343 | 344 | (defn image-set-size [dimensions]
|
344 |
| - (fn [width height] |
345 |
| - (when (< width height) |
346 |
| - ;; if width less than the height we reduce width proportionally to height |
347 |
| - (let [k (/ height image-max-height)] |
348 |
| - (when (not= (/ width k) (first @dimensions)) |
349 |
| - (reset! dimensions [(/ width k) image-max-height])))))) |
| 345 | + (fn [evt] |
| 346 | + (let [width (.-width (.-nativeEvent evt)) |
| 347 | + height (.-height (.-nativeEvent evt))] |
| 348 | + (when (< width height) |
| 349 | + ;; if width less than the height we reduce width proportionally to height |
| 350 | + (let [k (/ height image-max-height)] |
| 351 | + (when (not= (/ width k) (first @dimensions)) |
| 352 | + (reset! dimensions [(/ width k) image-max-height]))))))) |
350 | 353 |
|
351 | 354 | (defn message-content-image
|
352 | 355 | [{:keys [content outgoing in-popover?] :as message}
|
353 | 356 | {:keys [on-long-press]}]
|
354 | 357 | (let [dimensions (reagent/atom [image-max-width image-max-height])
|
355 | 358 | visible (reagent/atom false)
|
356 | 359 | uri (:image content)]
|
357 |
| - (react/image-get-size uri (image-set-size dimensions)) |
358 | 360 | (fn []
|
359 | 361 | (let [style-opts {:outgoing outgoing
|
360 | 362 | :width (first @dimensions)
|
|
372 | 374 | [react/view {:style (style/image-message style-opts)
|
373 | 375 | :accessibility-label :image-message}
|
374 | 376 | [react/fast-image {:style (dissoc style-opts :outgoing)
|
| 377 | + :on-load (image-set-size dimensions) |
375 | 378 | :source {:uri uri}}
|
376 | 379 | [react/view {:style (style/image-message-border style-opts)}]]]]]))))
|
377 | 380 |
|
|
0 commit comments