fix first tap doesn't work when selecting a photo in the gallery (#18885)

This commit is contained in:
Parvesh Monu 2024-02-19 19:05:31 +05:30 committed by GitHub
parent ed427cf485
commit 8f85e3c726
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 28 additions and 23 deletions

View File

@ -87,7 +87,7 @@
[content [content
{:insets insets {:insets insets
:close close :close close
:scroll-enabled? @scroll-enabled? :scroll-enabled? scroll-enabled?
:current-scroll curr-scroll :current-scroll curr-scroll
:on-scroll #(on-scroll % curr-scroll) :on-scroll #(on-scroll % curr-scroll)
:sheet-animating? animating?}]]]])))) :sheet-animating? animating?}]]]]))))

View File

@ -98,7 +98,7 @@
on-select set-scroll-ref close sheet-animating?]}] on-select set-scroll-ref close sheet-animating?]}]
[gesture/flat-list [gesture/flat-list
{:ref set-scroll-ref {:ref set-scroll-ref
:scroll-enabled scroll-enabled? :scroll-enabled @scroll-enabled?
:data (or filtered-data emoji-picker.data/flatten-data) :data (or filtered-data emoji-picker.data/flatten-data)
:initial-num-to-render 14 :initial-num-to-render 14
:max-to-render-per-batch 10 :max-to-render-per-batch 10

View File

@ -105,7 +105,7 @@
:render-section-header-fn contact-list/contacts-section-header :render-section-header-fn contact-list/contacts-section-header
:content-container-style {:padding-bottom 70} :content-container-style {:padding-bottom 70}
:render-fn contact-item-render :render-fn contact-item-render
:scroll-enabled scroll-enabled? :scroll-enabled @scroll-enabled?
:on-scroll on-scroll}]) :on-scroll on-scroll}])
(when contacts-selected? (when contacts-selected?
[quo/button [quo/button

View File

@ -182,8 +182,7 @@
(defn open-photo-selector (defn open-photo-selector
[{:keys [input-ref]} [{:keys [input-ref]}
{:keys [height]} {:keys [height]}]
insets]
(permissions/request-permissions (permissions/request-permissions
{:permissions [(if platform/is-below-android-13? :read-external-storage :read-media-images) {:permissions [(if platform/is-below-android-13? :read-external-storage :read-media-images)
:write-external-storage] :write-external-storage]
@ -192,18 +191,18 @@
(.blur ^js @input-ref)) (.blur ^js @input-ref))
(rf/dispatch [:chat.ui/set-input-content-height (rf/dispatch [:chat.ui/set-input-content-height
(reanimated/get-shared-value height)]) (reanimated/get-shared-value height)])
(rf/dispatch [:open-modal :photo-selector {:insets insets}])) (rf/dispatch [:photo-selector/navigate-to-photo-selector]))
:on-denied (fn [] :on-denied (fn []
(alert.effects/show-popup (i18n/label :t/error) (alert.effects/show-popup (i18n/label :t/error)
(i18n/label (i18n/label
:t/external-storage-denied)))})) :t/external-storage-denied)))}))
(defn image-button (defn image-button
[props animations insets edit] [props animations edit]
[quo/composer-button [quo/composer-button
{:on-press (if edit {:on-press (if edit
#(js/alert "This feature is temporarily unavailable in edit mode.") #(js/alert "This feature is temporarily unavailable in edit mode.")
#(open-photo-selector props animations insets)) #(open-photo-selector props animations))
:accessibility-label :open-images-button :accessibility-label :open-images-button
:container-style {:margin-right 12} :container-style {:margin-right 12}
:icon :i/image}]) :icon :i/image}])
@ -228,7 +227,7 @@
:icon :i/format}]) :icon :i/format}])
(defn view (defn view
[props state animations window-height insets {:keys [edit images]}] [props state animations window-height {:keys [edit images]}]
(let [send-btn-opacity (reanimated/use-shared-value 0) (let [send-btn-opacity (reanimated/use-shared-value 0)
audio-btn-opacity (reanimated/interpolate send-btn-opacity [0 1] [1 0])] audio-btn-opacity (reanimated/interpolate send-btn-opacity [0 1] [1 0])]
[rn/view {:style style/actions-container} [rn/view {:style style/actions-container}
@ -236,7 +235,7 @@
{:style {:flex-direction :row {:style {:flex-direction :row
:display (if @(:recording? state) :none :flex)}} :display (if @(:recording? state) :none :flex)}}
[camera-button edit] [camera-button edit]
[image-button props animations insets edit] [image-button props animations edit]
[reaction-button] [reaction-button]
[format-button]] [format-button]]
[:f> send-button props state animations window-height images edit send-btn-opacity] [:f> send-button props state animations window-height images edit send-btn-opacity]

View File

@ -142,7 +142,7 @@
[gradients/view props state animations show-bottom-gradient?] [gradients/view props state animations show-bottom-gradient?]
[link-preview/view] [link-preview/view]
[images/images-list]] [images/images-list]]
[:f> actions/view props state animations window-height insets subscriptions]]]]])) [:f> actions/view props state animations window-height subscriptions]]]]]))
(defn f-composer (defn f-composer
[props] [props]

View File

@ -87,7 +87,7 @@
:content-container-style {:padding-top 64 :content-container-style {:padding-top 64
:padding-bottom 40} :padding-bottom 40}
:key-fn key-fn :key-fn key-fn
:scroll-enabled scroll-enabled? :scroll-enabled @scroll-enabled?
:on-scroll on-scroll :on-scroll on-scroll
:style {:height window-height}}]])) :style {:height window-height}}]]))

View File

@ -1,5 +1,6 @@
(ns status-im.contexts.chat.messenger.photo-selector.events (ns status-im.contexts.chat.messenger.photo-selector.events
(:require (:require
[re-frame.core :as re-frame]
[status-im.constants :as constants] [status-im.constants :as constants]
status-im.contexts.chat.messenger.photo-selector.effects status-im.contexts.chat.messenger.photo-selector.effects
[utils.i18n :as i18n] [utils.i18n :as i18n]
@ -74,3 +75,9 @@
(when (and (< (count images) constants/max-album-photos) (when (and (< (count images) constants/max-album-photos)
(not (some #(= (:uri image) (:uri %)) images))) (not (some #(= (:uri image) (:uri %)) images)))
{:effects.camera-roll/image-selected [image current-chat-id]}))) {:effects.camera-roll/image-selected [image current-chat-id]})))
(re-frame/reg-event-fx :photo-selector/navigate-to-photo-selector
(fn []
{:fx [[:dispatch [:open-modal :photo-selector]]
[:dispatch [:photo-selector/get-photos-for-selected-album]]
[:dispatch [:photo-selector/camera-roll-get-albums]]]}))

View File

@ -70,13 +70,14 @@
(let [customization-color (rf/sub [:profile/customization-color]) (let [customization-color (rf/sub [:profile/customization-color])
item-selected? (some #(= (:uri item) (:uri %)) @selected)] item-selected? (some #(= (:uri item) (:uri %)) @selected)]
[rn/touchable-opacity [rn/touchable-opacity
{:on-press (fn [] {:on-press (fn []
(if item-selected? (if item-selected?
(swap! selected remove-selected item) (swap! selected remove-selected item)
(if (>= (count @selected) constants/max-album-photos) (if (>= (count @selected) constants/max-album-photos)
(show-photo-limit-toast) (show-photo-limit-toast)
(swap! selected conj item)))) (swap! selected conj item))))
:accessibility-label (str "image-" index)} :allow-multiple-presses? true
:accessibility-label (str "image-" index)}
[rn/image [rn/image
{:source {:uri (:uri item)} {:source {:uri (:uri item)}
:style (style/image window-width index)}] :style (style/image window-width index)}]
@ -91,8 +92,6 @@
(defn photo-selector (defn photo-selector
[{:keys [scroll-enabled? on-scroll current-scroll close] :as sheet}] [{:keys [scroll-enabled? on-scroll current-scroll close] :as sheet}]
(rf/dispatch [:photo-selector/get-photos-for-selected-album])
(rf/dispatch [:photo-selector/camera-roll-get-albums])
(let [album? (reagent/atom false) (let [album? (reagent/atom false)
customization-color (rf/sub [:profile/customization-color]) customization-color (rf/sub [:profile/customization-color])
sending-image (into [] (vals (rf/sub [:chats/sending-image]))) sending-image (into [] (vals (rf/sub [:chats/sending-image])))
@ -134,7 +133,7 @@
:padding-bottom (+ (safe-area/get-bottom) 100) :padding-bottom (+ (safe-area/get-bottom) 100)
:padding-top 64} :padding-top 64}
:on-scroll on-scroll :on-scroll on-scroll
:scroll-enabled scroll-enabled? :scroll-enabled @scroll-enabled?
:on-end-reached (fn [] :on-end-reached (fn []
(when (and (not loading?) has-next-page?) (when (and (not loading?) has-next-page?)
(rf/dispatch [:photo-selector/camera-roll-loading-more true]) (rf/dispatch [:photo-selector/camera-roll-loading-more true])

View File

@ -92,7 +92,7 @@
:share-all-addresses? share-all-addresses? :share-all-addresses? share-all-addresses?
:community-color color} :community-color color}
:content-container-style {:padding-horizontal 20} :content-container-style {:padding-horizontal 20}
:scroll-enabled scroll-enabled? :scroll-enabled @scroll-enabled?
:on-scroll on-scroll :on-scroll on-scroll
:key-fn :address :key-fn :address
:data accounts}] :data accounts}]