feat: allow navigation inside different stacks (#16419)
Signed-off-by: Brian Sztamfater <brian@status.im>
This commit is contained in:
parent
186ac482ee
commit
2d860c363a
|
@ -33,6 +33,10 @@
|
|||
[comp]
|
||||
(.showOverlay Navigation (clj->js comp)))
|
||||
|
||||
(defn pop-to
|
||||
[comp]
|
||||
(.popTo Navigation (clj->js comp)))
|
||||
|
||||
(defn pop-to-root
|
||||
[tab]
|
||||
(.popToRoot Navigation (clj->js tab)))
|
||||
|
|
|
@ -54,9 +54,10 @@
|
|||
(reset! state/pushed-screen-id view-id)))))
|
||||
|
||||
(defn dissmissModal
|
||||
[]
|
||||
([] (dissmissModal nil))
|
||||
([comp-id]
|
||||
(reset! state/dissmissing true)
|
||||
(navigation/dismiss-modal (name (last @state/modals))))
|
||||
(navigation/dismiss-modal (name (or comp-id (last @state/modals))))))
|
||||
|
||||
(defn dismiss-all-modals
|
||||
[]
|
||||
|
@ -95,8 +96,24 @@
|
|||
(options/merge-top-bar (options/topbar-options) options)
|
||||
{:topBar {:visible false}}))}})))
|
||||
|
||||
;; NAVIGATE-TO-WITHIN-STACK
|
||||
(defn navigate-to-within-stack
|
||||
[[comp comp-id]]
|
||||
(let [{:keys [options]} (get views/screens comp)]
|
||||
(navigation/push
|
||||
(name comp-id)
|
||||
{:component {:id comp
|
||||
:name comp
|
||||
:options (merge (options/statusbar-and-navbar)
|
||||
options
|
||||
(if (:topBar options)
|
||||
(options/merge-top-bar (options/topbar-options) options)
|
||||
{:topBar {:visible false}}))}})))
|
||||
|
||||
(re-frame/reg-fx :navigate-to navigate)
|
||||
|
||||
(re-frame/reg-fx :navigate-to-within-stack navigate-to-within-stack)
|
||||
|
||||
(re-frame/reg-fx :navigate-replace-fx
|
||||
(fn [view-id]
|
||||
(navigation/pop (name @state/root-id))
|
||||
|
@ -108,6 +125,14 @@
|
|||
(dissmissModal)
|
||||
(navigation/pop (name @state/root-id)))))
|
||||
|
||||
(re-frame/reg-fx :navigate-back-within-stack
|
||||
(fn [comp-id]
|
||||
(navigation/pop (name comp-id))))
|
||||
|
||||
(re-frame/reg-fx :navigate-back-to
|
||||
(fn [comp-id]
|
||||
(navigation/pop-to (name comp-id))))
|
||||
|
||||
(defn pop-to-root
|
||||
[root-id]
|
||||
(navigation/pop-to-root root-id)
|
||||
|
@ -126,14 +151,14 @@
|
|||
(reset! state/curr-modal true)
|
||||
(swap! state/modals conj comp)
|
||||
(navigation/show-modal
|
||||
{:component
|
||||
{:stack {:children [{:component
|
||||
{:name comp
|
||||
:id comp
|
||||
:options (merge (options/default-root)
|
||||
(options/statusbar-and-navbar)
|
||||
options
|
||||
(when sheet?
|
||||
options/sheet-options))}})))))
|
||||
options/sheet-options))}}]}})))))
|
||||
|
||||
(re-frame/reg-fx :open-modal-fx open-modal)
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
:dispatch-n [[:hide-bottom-sheet]]}
|
||||
(shell.events/shell-navigate-to go-to-view-id screen-params nil nil)))
|
||||
|
||||
(rf/defn navigate-to-within-stack
|
||||
{:events [:navigate-to-within-stack]}
|
||||
[_ comp-id]
|
||||
{:navigate-to-within-stack comp-id})
|
||||
|
||||
(rf/defn open-modal
|
||||
{:events [:open-modal]}
|
||||
[{:keys [db]} comp screen-params]
|
||||
|
@ -29,11 +34,26 @@
|
|||
:dispatch [:hide-bottom-sheet]
|
||||
:open-modal-fx comp})
|
||||
|
||||
(rf/defn dismiss-modal
|
||||
{:events [:dismiss-modal]}
|
||||
[_ comp-id]
|
||||
{:dismiss-modal comp-id})
|
||||
|
||||
(rf/defn navigate-back
|
||||
{:events [:navigate-back]}
|
||||
[cofx]
|
||||
(shell.events/shell-navigate-back cofx))
|
||||
|
||||
(rf/defn navigate-back-within-stack
|
||||
{:events [:navigate-back-within-stack]}
|
||||
[_ comp-id]
|
||||
{:navigate-back-within-stack comp-id})
|
||||
|
||||
(rf/defn navigate-back-to
|
||||
{:events [:navigate-back-to]}
|
||||
[_ comp-id]
|
||||
{:navigate-back-to comp-id})
|
||||
|
||||
(rf/defn pop-to-root
|
||||
{:events [:pop-to-root]}
|
||||
[{:keys [db]} tab]
|
||||
|
|
Loading…
Reference in New Issue