fix: image desktop (#15562)

* fix: image desktop not opening
This commit is contained in:
Omar Basem
2023-04-03 20:20:16 +05:30
committed by Parvesh Monu
parent 5e9ceec65f
commit 5ca5c5f2bb
5 changed files with 23 additions and 21 deletions
@@ -13,3 +13,5 @@
(def ^:const velocity-factor 0.5)
(def ^:const default-duration 300)
(def ^:const default-dimension 1000)
@@ -216,10 +216,11 @@
curr-orientation (or (rf/sub [:lightbox/orientation])
orientation/portrait)
portrait? (= curr-orientation orientation/portrait)
dimensions (utils/get-dimensions image-width
image-height
curr-orientation
args)
dimensions (utils/get-dimensions
(or image-width c/default-dimension)
(or image-height c/default-duration)
curr-orientation
args)
animations {:scale (anim/use-val c/min-scale)
:saved-scale (anim/use-val c/min-scale)
:pan-x-start (anim/use-val c/init-offset)
@@ -41,13 +41,12 @@
:size 32} :i/reaction]])
(defn image-button
[insets]
[bottom-inset]
[quo/button
{:on-press (fn []
(permissions/request-permissions
{:permissions [:read-external-storage :write-external-storage]
:on-allowed #(rf/dispatch
[:open-modal :photo-selector {:insets insets}])
:on-allowed #(rf/dispatch [:open-modal :photo-selector {:bottom-inset bottom-inset}])
:on-denied (fn []
(background-timer/set-timeout
#(utils-old/show-popup (i18n/label :t/error)
@@ -3,10 +3,10 @@
[react-native.platform :as platform]))
(defn gradient-container
[insets]
[bottom-inset]
{:left 0
:right 0
:height (+ (:bottom insets) (if platform/ios? 65 85))
:height (+ bottom-inset (if platform/ios? 65 85))
:position :absolute
:bottom 0})
@@ -13,7 +13,6 @@
[status-im2.contexts.chat.photo-selector.style :as style]
[status-im.utils.core :as utils]
[quo.react]
[status-im2.common.bottom-sheet-screen.view :as bottom-sheet-screen]
[utils.re-frame :as rf]))
(defn on-press-confirm-selection
@@ -25,13 +24,13 @@
(rf/dispatch [:navigate-back]))
(defn bottom-gradient
[selected-images insets selected]
[selected-images bottom-inset selected]
(when (or (seq @selected) (seq selected-images))
[linear-gradient/linear-gradient
{:colors [:black :transparent]
:start {:x 0 :y 1}
:end {:x 0 :y 0}
:style (style/gradient-container insets)}
:style (style/gradient-container bottom-inset)}
[quo/button
{:style {:align-self :stretch
:margin-horizontal 20
@@ -109,12 +108,13 @@
(defn photo-selector
[]
[{:keys [scroll-enabled on-scroll]}]
[:f>
(let [{:keys [insets]} (rf/sub [:get-screen-params])
temporary-selected (reagent/atom [])] ; used when switching albums
(let [{:keys [bottom-inset]} (rf/sub [:screen-params]) ; TODO:
; https://github.com/status-im/status-mobile/issues/15535
temporary-selected (reagent/atom [])] ; used when switching albums
(fn []
(let [selected (reagent/atom []) ; currently selected
(let [selected (reagent/atom []) ; currently selected
selected-images (rf/sub [:chats/sending-image]) ; already selected and dispatched
selected-album (or (rf/sub [:camera-roll/selected-album]) (i18n/label :t/recent))]
(rn/use-effect
@@ -124,8 +124,8 @@
(reset! selected (vec (vals selected-images)))
(reset! selected @temporary-selected)))
[selected-album])
[bottom-sheet-screen/view
(fn [{:keys [scroll-enabled on-scroll]}]
[:f>
(fn []
(let [window-width (:width (rn/get-window))
camera-roll-photos (rf/sub [:camera-roll/photos])
end-cursor (rf/sub [:camera-roll/end-cursor])
@@ -134,7 +134,7 @@
[:<>
[rn/view
{:style style/buttons-container}
[album-title true selected-album selected temporary-selected insets]
[album-title true selected-album selected temporary-selected]
[clear-button selected]]
[gesture/flat-list
{:key-fn identity
@@ -143,11 +143,11 @@
:data camera-roll-photos
:num-columns 3
:content-container-style {:width "100%"
:padding-bottom (+ (:bottom insets) 100)
:padding-bottom (+ (:bottom bottom-inset) 100)
:padding-top 64}
:on-scroll on-scroll
:scroll-enabled scroll-enabled
:on-end-reached #(rf/dispatch [:camera-roll/on-end-reached end-cursor
selected-album loading?
has-next-page?])}]
[bottom-gradient selected-images insets selected]]))])))])
[bottom-gradient selected-images bottom-inset selected]]))])))])