Skip to content

Commit

Permalink
Fix calculations on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
ulisesmac committed Nov 6, 2023
1 parent d0890af commit 7197996
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/status_im2/common/floating_button_page/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
(defn- show-background-android
[{:keys [window-height keyboard-height floating-container-height content-scroll-y
content-container-height header-height keyboard-did-show?]}]
(let [available-space (- window-height
keyboard-height
floating-container-height
header-height)
content-height (+ content-container-height
content-scroll-y)]
(and keyboard-did-show? (< available-space content-height))))
(let [available-space (- window-height
(safe-area/get-top)
(safe-area/get-bottom)
;;
header-height
keyboard-height)
space-for-scroll-view (- available-space floating-container-height)
;;
overlap? (< space-for-scroll-view content-container-height)]
(and keyboard-did-show? overlap?)))

(defn- show-background-ios
[{:keys [window-height keyboard-height floating-container-height content-scroll-y
Expand Down Expand Up @@ -45,7 +48,7 @@
(show-background-ios props)))

(defn view
[{:keys [header footer]} page-content]
[{:keys [header footer]} & children]
(reagent/with-let [window-height (:height (rn/get-window))
floating-container-height (reagent/atom 0)
header-height (reagent/atom 0)
Expand Down Expand Up @@ -78,11 +81,12 @@
set-content-container-height (set-height-on-layout content-container-height)
set-floating-container-height (set-height-on-layout floating-container-height)
set-content-y-scroll (fn [event]
(let [y (oops/oget
event
"nativeEvent.contentOffset.y")]
(reset! content-scroll-y y)))]
(let [show-background? (show-background {:window-height window-height
(reset! content-scroll-y
(oops/oget event "nativeEvent.contentOffset.y")))]
(let [
_ (println ":content-scroll-y " @content-scroll-y)
;;
show-background? (show-background {:window-height window-height
:floating-container-height @floating-container-height
:keyboard-height @keyboard-height
:content-scroll-y @content-scroll-y
Expand All @@ -96,19 +100,21 @@
{:on-scroll set-content-y-scroll
:scroll-event-throttle 64
:content-container-style {:flex-grow 1}}
[rn/view {:on-layout set-content-container-height}
page-content]]
(into [rn/view {:on-layout set-content-container-height}]
children)]

[rn/keyboard-avoiding-view
{:style style/keyboard-avoiding-view
{:style style/keyboard-avoiding-view
:keyboard-vertical-offset (if platform/ios?
(safe-area/get-top)
0)
:pointer-events :box-none}
:pointer-events :box-none}
[floating-container/view
{:on-layout set-floating-container-height
:keyboard-will-show? @keyboard-will-show?
:blur? show-background?}
footer]]])
footer]]
])
(finally
(doseq [listener [will-show-listener will-hide-listener did-show-listener did-hide-listener]]
(oops/ocall listener "remove")))))

0 comments on commit 7197996

Please sign in to comment.