Skip to content

Commit b11de81

Browse files
committed
tweak: use on-layout for measuring sheet max-height
1 parent be9fca2 commit b11de81

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/status_im/common/bottom_sheet/view.cljs

+9-8
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,22 @@
6464
(oops/oget event "nativeEvent.layout.height"))
6565

6666
(defn view
67-
[{:keys [hide? insets keyboard-vertical-offset]}
67+
[{:keys [hide? insets]}
6868
{:keys [content selected-item padding-bottom-override border-radius on-close shell?
6969
gradient-cover? customization-color hide-handle? blur-radius]
7070
:or {border-radius 12}}]
7171
(let [theme (quo.theme/use-theme-value)
7272
[sheet-height set-sheet-height] (rn/use-state 0)
73+
[layout-height set-layout-height] (rn/use-state 0)
7374
handle-sheet-height (rn/use-callback (fn [e]
7475
(when (= sheet-height 0)
7576
(set-sheet-height
7677
(get-layout-height e))))
7778
[sheet-height])
79+
handle-layout-height (rn/use-callback (fn [e]
80+
(-> (get-layout-height e)
81+
(set-layout-height))))
7882
[item-height set-item-height] (rn/use-state 0)
79-
{:keys [keyboard-height]} (hooks/use-keyboard)
8083
handle-item-height (rn/use-callback (fn [e]
8184
(when (= item-height 0)
8285
(set-item-height
@@ -100,11 +103,8 @@
100103
bottom (if selected-item-smaller-than-sheet?
101104
(+ sheet-height bottom-margin)
102105
(:bottom insets))
103-
sheet-max-height (- window-height
104-
(:top insets)
105-
keyboard-height
106-
(when platform/ios?
107-
keyboard-vertical-offset))
106+
sheet-max-height (- layout-height
107+
(:top insets))
108108
content-padding-bottom (or padding-bottom-override
109109
(+ (:bottom insets) bottom-margin))]
110110
(rn/use-effect
@@ -117,7 +117,8 @@
117117
(on-close))
118118
(rf/dispatch [:hide-bottom-sheet])
119119
true))
120-
[rn/view {:style {:flex 1}}
120+
[rn/view {:style {:flex 1}
121+
:on-layout handle-layout-height}
121122
;; backdrop
122123
[rn/pressable
123124
{:on-press #(rf/dispatch [:hide-bottom-sheet])

src/status_im/navigation/view.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
:keyboard-vertical-offset keyboard-vertical-offset}
107107
(when sheet
108108
[bottom-sheet/view
109-
{:insets insets :hide? hide? :keyboard-vertical-offset keyboard-vertical-offset}
109+
{:insets insets :hide? hide?}
110110
sheet])]]))
111111
functional-compiler))
112112

0 commit comments

Comments
 (0)