|
66 | 66 | gradient-cover? customization-color hide-handle? blur-radius]
|
67 | 67 | :or {border-radius 12}}]
|
68 | 68 | (let [theme (quo.theme/use-theme-value)
|
69 |
| - sheet-height (rn/use-ref-atom 0) |
70 |
| - item-height (rn/use-ref-atom 0) |
71 |
| - set-sheet-height (rn/use-callback #(reset! sheet-height (get-layout-height %))) |
72 |
| - set-item-height (rn/use-callback #(reset! item-height (get-layout-height %))) |
| 69 | + [sheet-height set-sheet-height] (rn/use-state 0) |
| 70 | + handle-sheet-height (rn/use-callback (fn [e] |
| 71 | + (when (= sheet-height 0) |
| 72 | + (set-sheet-height |
| 73 | + (get-layout-height e)))) |
| 74 | + [sheet-height]) |
| 75 | + [item-height set-item-height] (rn/use-state 0) |
| 76 | + handle-item-height (rn/use-callback (fn [e] |
| 77 | + (when (= item-height 0) |
| 78 | + (set-item-height |
| 79 | + (get-layout-height e)))) |
| 80 | + [item-height]) |
73 | 81 | {window-height :height} (rn/get-window)
|
74 | 82 | bg-opacity (reanimated/use-shared-value 0)
|
75 | 83 | translate-y (reanimated/use-shared-value window-height)
|
76 |
| - sheet-gesture (get-sheet-gesture translate-y |
77 |
| - bg-opacity |
78 |
| - window-height |
79 |
| - on-close) |
80 |
| - selected-item-smaller-than-sheet? (< @item-height |
| 84 | + sheet-gesture (rn/use-memo #(get-sheet-gesture translate-y |
| 85 | + bg-opacity |
| 86 | + window-height |
| 87 | + on-close) |
| 88 | + [window-height on-close]) |
| 89 | + selected-item-smaller-than-sheet? (< item-height |
81 | 90 | (- window-height
|
82 |
| - @sheet-height |
| 91 | + sheet-height |
83 | 92 | (:top insets)
|
84 | 93 | (:bottom insets)
|
85 | 94 | bottom-margin))
|
86 |
| - top (- window-height (:top insets) @sheet-height) |
| 95 | + top (- window-height (:top insets) sheet-height) |
87 | 96 | bottom (if selected-item-smaller-than-sheet?
|
88 |
| - (+ @sheet-height bottom-margin) |
| 97 | + (+ sheet-height bottom-margin) |
89 | 98 | (:bottom insets))
|
90 | 99 | sheet-max-height (- window-height (:top insets))
|
91 | 100 | content-padding-bottom (or padding-bottom-override
|
|
123 | 132 | :overlay-color :transparent}])
|
124 | 133 | (when selected-item
|
125 | 134 | [rn/view
|
126 |
| - {:on-layout set-item-height |
127 |
| - :style (style/selected-item theme top bottom selected-item-smaller-than-sheet? border-radius)} |
| 135 | + {:on-layout handle-item-height |
| 136 | + :style |
| 137 | + (style/selected-item theme top bottom selected-item-smaller-than-sheet? border-radius)} |
128 | 138 | [selected-item]])
|
129 | 139 | [rn/view
|
130 |
| - {:on-layout set-sheet-height |
| 140 | + {:on-layout handle-sheet-height |
131 | 141 | :style (style/sheet-content {:theme theme
|
132 | 142 | :shell? shell?
|
133 | 143 | :padding-bottom content-padding-bottom})}
|
|
0 commit comments