fix image long press issue and cropping (#16571)

This commit is contained in:
Parvesh Monu 2023-07-13 14:07:42 +05:30 committed by GitHub
parent 88c4521321
commit a340e2a55c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

View File

@ -205,7 +205,8 @@
(anim/animate-decay pan-y-start velocity [lower-bound upper-bound]))))))))
(defn- f-zoomable-image
[dimensions animations state rescale curr-orientation content focused? index render-data]
[dimensions animations state rescale curr-orientation content focused? index render-data
image-dimensions-nil?]
(let [{:keys [transparent? set-full-height?]} render-data
portrait? (= curr-orientation orientation/portrait)
on-tap #(utils/toggle-opacity index render-data portrait?)
@ -225,9 +226,12 @@
@set-full-height?
(= curr-orientation orientation/portrait))}
[reanimated/fast-image
(merge
{:source {:uri (http/replace-port (:image content) (rf/sub [:mediaserver/port]))}
:native-ID (when focused? :shared-element)
:style (style/image dimensions animations render-data index)}]]]))
:style (style/image dimensions animations render-data index)}
(when image-dimensions-nil?
{:resize-mode :contain}))]]]))
(defn zoomable-image
[]
@ -238,9 +242,12 @@
zoom-out-signal (rf/sub [:lightbox/zoom-out-signal])
{:keys [set-full-height? curr-orientation]} render-data
focused? (= shared-element-id message-id)
;; TODO - remove `image-dimensions` check,
;; once https://github.com/status-im/status-desktop/issues/10944 is fixed
image-dimensions-nil? (not (and image-width image-height))
dimensions (utils/get-dimensions
(or image-width c/default-dimension)
(or image-height c/default-duration)
(or image-width (:screen-width render-data))
(or image-height (:screen-height render-data))
curr-orientation
render-data)
animations (utils/init-animations)
@ -261,4 +268,4 @@
set-full-height?))
(utils/handle-zoom-out-signal zoom-out-signal index (anim/get-val (:scale animations)) rescale)
[:f> f-zoomable-image dimensions animations state rescale curr-orientation content focused?
index render-data]))))
index render-data image-dimensions-nil?]))))

View File

@ -74,5 +74,5 @@
(map-indexed
(fn [index item]
[:<> {:key (:message-id item)}
[image/image-message index item #(on-long-press message context)]])
[image/image-message index item {:on-long-press #(on-long-press message context)}]])
(:album message))])))

View File

@ -15,7 +15,7 @@
{:width (min width max-width) :height (min height max-height)}))
(defn image-message
[index {:keys [content image-width image-height message-id] :as message} on-long-press]
[index {:keys [content image-width image-height message-id] :as message} {:keys [on-long-press]}]
(let [insets (safe-area/get-insets)
dimensions (calculate-dimensions (or image-width 1000) (or image-height 1000))
shared-element-id (rf/sub [:shared-element-id])

View File

@ -154,7 +154,7 @@
[audio/audio-message message-data context]
constants/content-type-image
[image/image-message 0 message-data context on-long-press]
[image/image-message 0 message-data context]
constants/content-type-album
[album/album-message message-data context on-long-press]