diff --git a/src/status_im/contexts/onboarding/common/background/view.cljs b/src/status_im/contexts/onboarding/common/background/view.cljs index 0e6a8064c299..2a9041581d45 100644 --- a/src/status_im/contexts/onboarding/common/background/view.cljs +++ b/src/status_im/contexts/onboarding/common/background/view.cljs @@ -37,26 +37,28 @@ (defonce is-dragging? (atom nil)) (defonce drag-amount (atom nil)) +;; Layout height calculation +;; 1. Ensure that the height is greater than the width and that on-layout is not triggered while the +;; screen is horizontal. +;; 2. Initialize values to 0 in case they are nil. +;; 3. Always prefer on-layout height over window height, as some devices include status bar height in +;; the window while others do not. +;; https://github.com/status-im/status-mobile/issues/14633#issuecomment-1366191478 +;; 4. This preference is unless on-layout is triggered with a random value. +;; https://github.com/status-im/status-mobile/issues/14849 +;; To ensure that on-layout height falls within the actual height range, a difference between window +;; height and the maximum possible status bar height is allowed (assumed to be 60, as the Pixel emulator +;; has a height of 52). (defn store-screen-height [evt] - (let [window-height (:height (rn/get-window)) + (let [window-height (or (:height (rn/get-window)) 0) height (or (oget evt "nativeEvent" "layout" "height") 0) width (or (oget evt "nativeEvent" "layout" "width") 0)] - ;; Layout height calculation - ;; 1. Make sure height is more than width, and on-layout is not fired while the - ;; screen is horizontal - ;; 2. Initialize values with 0 in case of nil - ;; 3. In the case of notch devices, the dimensions height will be smaller than - ;; on-layout, - ;; (without status bar height included) - ;; https://github.com/status-im/status-mobile/issues/14633 - ;; 4. In the case of devices without a notch, both heights should be the same, - ;; but actual values differ in some pixels, so arbitrary 5 pixels is allowed (when (and (> height width) - (>= (+ height 5) (or window-height 0)) + (<= (Math/abs (- window-height height)) 60) (not= height @shell.state/screen-height)) - (reset! shell.state/screen-height height) - (async-storage/set-item! :screen-height height)))) + (reset! shell.state/screen-height height) + (async-storage/set-item! :screen-height height)))) (defn view [dark-overlay?]