diff --git a/src/status_im/ui/screens/bottom_sheets/views.cljs b/src/status_im/ui/screens/bottom_sheets/views.cljs index 1a9e01ef74..923e3a17fd 100644 --- a/src/status_im/ui/screens/bottom_sheets/views.cljs +++ b/src/status_im/ui/screens/bottom_sheets/views.cljs @@ -7,7 +7,8 @@ [status-im.ui.screens.multiaccounts.key-storage.views :as key-storage] [status-im.ui.screens.multiaccounts.recover.views :as recover.views] [status-im2.common.bottom-sheet.view :as bottom-sheet] - [status-im2.contexts.chat.messages.pin.list.view :as pin.list])) + [status-im2.contexts.chat.messages.pin.list.view :as pin.list] + [reagent.core :as reagent])) (defn bottom-sheet [] @@ -47,6 +48,10 @@ (= view :pinned-messages-list) (merge {:content pin.list/pinned-messages-list}))] - [bottom-sheet/bottom-sheet opts - (when content - [content (when options options)])])) + (reagent/create-class {:reagent-render (fn [] + [bottom-sheet/bottom-sheet opts + (when content + [content (when options options)])]) + :component-will-unmount (fn [] + (when @bottom-sheet/show-bottom-sheet? + (bottom-sheet/reset-atoms)))}))) diff --git a/src/status_im/ui2/screens/chat/components/new_chat/view.cljs b/src/status_im/ui2/screens/chat/components/new_chat/view.cljs index c2809f3d0d..b7bacf33be 100644 --- a/src/status_im/ui2/screens/chat/components/new_chat/view.cljs +++ b/src/status_im/ui2/screens/chat/components/new_chat/view.cljs @@ -13,7 +13,8 @@ [status-im.ui2.screens.common.contact-list.view :as contact-list] [quo2.components.markdown.text :as text] [status-im.ui.components.invite.events :as invite.events] - [status-im.ui2.screens.chat.components.new-chat.styles :as style])) + [status-im.ui2.screens.chat.components.new-chat.styles :as style] + [status-im2.common.bottom-sheet.view :as bottom-sheet])) (defn- on-toggle [allow-new-users? checked? public-key] @@ -71,8 +72,8 @@ [quo2/button {:type :grey :icon true - :on-press #(rf/dispatch [:bottom-sheet/hide]) - :style style/contact-selection-close + :on-press #(bottom-sheet/close-bottom-sheet-fn nil) + :style style/contact-selection-close :override-background-color (quo2.colors/theme-colors quo2.colors/neutral-10 quo2.colors/neutral-90)} :i/close] diff --git a/src/status_im2/common/bottom_sheet/view.cljs b/src/status_im2/common/bottom_sheet/view.cljs index 857be3f22e..707115ec42 100644 --- a/src/status_im2/common/bottom_sheet/view.cljs +++ b/src/status_im2/common/bottom_sheet/view.cljs @@ -83,6 +83,15 @@ (and @expanded? (< end-pan-y collapse-threshold)) (reset! expanded? false)))))))) +(defn close-bottom-sheet-fn [on-cancel] + (reset! show-bottom-sheet? false) + (when (fn? on-cancel) (on-cancel)) + (timer/set-timeout + #(do + (re-frame/dispatch [:bottom-sheet/hide-navigation-overlay]) + (reset-atoms)) + animation-delay)) + (defn bottom-sheet [props children] (let [{on-cancel :on-cancel @@ -96,14 +105,7 @@ backdrop-dismiss? true expandable? false}} props - close-bottom-sheet (fn [] - (reset! show-bottom-sheet? false) - (when (fn? on-cancel) (on-cancel)) - (timer/set-timeout - #(do - (re-frame/dispatch [:bottom-sheet/hide-navigation-overlay]) - (reset-atoms)) - animation-delay))] + close-bottom-sheet #(close-bottom-sheet-fn on-cancel)] [safe-area/consumer (fn [insets] [:f> @@ -114,7 +116,7 @@ window-height (if selected-item (- height 72) height) {:keys [keyboard-shown]} (hooks/use-keyboard) bg-height-expanded (- window-height (:top insets)) - bg-height (max (min @content-height bg-height-expanded) 200) + bg-height (max (min @content-height bg-height-expanded) 150) bottom-sheet-dy (reanimated/use-shared-value 0) pan-y (reanimated/use-shared-value 0) translate-y (.useTranslateY ^js bottom-sheet-js window-height bottom-sheet-dy pan-y)