Improve navigate-to-jump-to (#19434)

This commit is contained in:
Parvesh Monu 2024-04-04 22:07:11 +05:30 committed by GitHub
parent 0a6eaf1c12
commit e1177d20b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 29 deletions

View File

@ -169,10 +169,7 @@
:admin? admin?}
:render-fn contact-item-render}]
[quo/floating-shell-button
{:jump-to {:on-press (fn []
(rf/dispatch [:navigate-back])
(rf/dispatch [:shell/navigate-to-jump-to])
)
{:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color profile-color
:label (i18n/label :t/jump-to)}}
style/floating-shell-button]]))

View File

@ -39,8 +39,7 @@
(i18n/label :t/contact-request-chat-pending))]]
[quo/floating-shell-button
{:jump-to
{:on-press (fn []
(rf/dispatch [:shell/navigate-to-jump-to]))
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
{:position :absolute

View File

@ -80,9 +80,7 @@
[quo/floating-shell-button
{:key :shell
:jump-to
{:on-press (fn []
(rf/dispatch [:navigate-back])
(debounce/throttle-and-dispatch [:shell/navigate-to-jump-to] 500))
{:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
:customization-color customization-color
:label (i18n/label :t/jump-to)}}
(style/floating-shell-button-style insets)]]))

View File

@ -83,30 +83,37 @@
(rf/defn navigate-to-jump-to
{:events [:shell/navigate-to-jump-to]}
[{:keys [db]}]
(let [open-floating-screens (shell.utils/open-floating-screens)]
{:db
(cond-> db
(let [current-view-id (:view-id db)
open-floating-screens (shell.utils/open-floating-screens)
chat-screen-open? (get open-floating-screens shell.constants/chat-screen)
community-screen-open? (get open-floating-screens shell.constants/community-screen)
discover-communities-screen-open? (get open-floating-screens
shell.constants/discover-communities-screen)]
(assoc
(if (shell.utils/shell-navigation? current-view-id)
{:db
(cond-> db
(get open-floating-screens shell.constants/chat-screen)
(assoc-in [:shell/floating-screens shell.constants/chat-screen :animation]
shell.constants/close-screen-with-shell-animation)
chat-screen-open?
(assoc-in [:shell/floating-screens shell.constants/chat-screen :animation]
shell.constants/close-screen-with-shell-animation)
(and (get open-floating-screens shell.constants/chat-screen)
(get open-floating-screens shell.constants/community-screen))
(assoc-in [:shell/floating-screens shell.constants/community-screen :animation]
shell.constants/close-screen-without-animation)
(and chat-screen-open? community-screen-open?)
(assoc-in [:shell/floating-screens shell.constants/community-screen :animation]
shell.constants/close-screen-without-animation)
(and (not (get open-floating-screens shell.constants/chat-screen))
(get open-floating-screens shell.constants/community-screen))
(assoc-in [:shell/floating-screens shell.constants/community-screen :animation]
shell.constants/close-screen-with-shell-animation)
(and (not chat-screen-open?) community-screen-open?)
(assoc-in [:shell/floating-screens shell.constants/community-screen :animation]
shell.constants/close-screen-with-shell-animation)
(get open-floating-screens shell.constants/discover-communities-screen)
(assoc-in [:shell/floating-screens shell.constants/discover-communities-screen :animation]
shell.constants/close-screen-without-animation))
discover-communities-screen-open?
(assoc-in [:shell/floating-screens shell.constants/discover-communities-screen :animation]
shell.constants/close-screen-without-animation))
:dispatch [:set-view-id :shell]
:effects.shell/navigate-to-jump-to nil}))
:dispatch [:set-view-id :shell]}
{:dispatch [:pop-to-root :shell-stack]})
:effects.shell/navigate-to-jump-to
nil)))
(rf/defn shell-navigate-to
{:events [:shell/navigate-to]}

View File

@ -92,7 +92,7 @@
(doseq [screen-id (seq shell.constants/floating-screens)]
(reanimated/set-shared-value
(:screen-state (get @state/shared-values-atom screen-id))
shell.constants/close-screen-without-animation))))
shell.constants/close-screen-with-shell-animation))))
;;; Floating screen
(defn- screen-state-open?