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?} :admin? admin?}
:render-fn contact-item-render}] :render-fn contact-item-render}]
[quo/floating-shell-button [quo/floating-shell-button
{:jump-to {:on-press (fn [] {:jump-to {:on-press #(rf/dispatch [:shell/navigate-to-jump-to])
(rf/dispatch [:navigate-back])
(rf/dispatch [:shell/navigate-to-jump-to])
)
:customization-color profile-color :customization-color profile-color
:label (i18n/label :t/jump-to)}} :label (i18n/label :t/jump-to)}}
style/floating-shell-button]])) style/floating-shell-button]]))

View File

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

View File

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

View File

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

View File

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