-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9441b2
commit cdeefd5
Showing
32 changed files
with
683 additions
and
21 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
:ValueXY (fn []) | ||
:View {} | ||
:FlatList {} | ||
:Image {} | ||
:ScrollView {} | ||
:Text {}} | ||
:Easing {:bezier (fn []) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(ns status-im.navigation2 | ||
(:require [status-im.utils.fx :as fx] | ||
[status-im.utils.datetime :as datetime])) | ||
|
||
(def parent-stack (atom :home-stack)) | ||
|
||
(fx/defn init-root-nav2 | ||
{:events [:init-root-nav2]} | ||
[_ root-id] | ||
{:init-root-fx-nav2 root-id}) | ||
|
||
(fx/defn open-modal-nav2 | ||
{:events [:open-modal-nav2]} | ||
[_ modal] | ||
{:open-modal-fx-nav2 modal}) | ||
|
||
(fx/defn close-modal-nav2 | ||
{:events [:close-modal-nav2]} | ||
[_ modal] | ||
{:close-modal-fx-nav2 modal}) | ||
|
||
(defn navigate-from-home-stack [go-to-view-id id db] | ||
(reset! parent-stack go-to-view-id) | ||
{:navigate-to-fx-nav2 [go-to-view-id id] | ||
:db (assoc-in db [:navigation2/navigation2-stacks id] {:type go-to-view-id | ||
:id id | ||
:clock (datetime/timestamp)})}) | ||
|
||
(defn navigate-from-switcher [go-to-view-id id db from-home?] | ||
(reset! parent-stack go-to-view-id) | ||
{:navigate-from-switcher-fx [go-to-view-id id from-home?] | ||
:db (assoc-in db [:navigation2/navigation2-stacks id] {:type go-to-view-id | ||
:id id | ||
:clock (datetime/timestamp)})}) | ||
|
||
(fx/defn navigate-to-nav2 | ||
{:events [:navigate-to-nav2]} | ||
[{:keys [db] :as cofx} go-to-view-id id screen-params from-switcher?] | ||
(let [view-id (:view-id db) | ||
stacks (:navigation2/navigation2-stacks db) | ||
from-home? (= view-id :home-stack)] | ||
(if from-switcher? | ||
(navigate-from-switcher go-to-view-id id db from-home?) | ||
(if from-home? | ||
(navigate-from-home-stack go-to-view-id id db) | ||
;; TODO(parvesh) - new stacks created from other screens should be stacked on current stack, instead of creating new entry | ||
(navigate-from-home-stack go-to-view-id id db))))) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
(ns status-im.navigation2.core | ||
(:require [re-frame.core :as re-frame] | ||
[status-im.ui.screens.views :as views] | ||
[status-im.navigation2.utils :as nav2-utils] | ||
[status-im.navigation2.roots :as roots] | ||
[status-im.navigation.roots :as nav-roots] | ||
["react-native-navigation" :refer (Navigation)])) | ||
|
||
(def tab-key-idx {:home 0 | ||
:communities 1 | ||
:wallet 2 | ||
:browser 3}) | ||
|
||
(defonce set-navigation-default-options | ||
(.setDefaultOptions Navigation (clj->js {:options {:topBar {:visible false}}}))) | ||
|
||
;; TODO (parvesh) - improve open-modal and close-modal | ||
(defn open-modal [comp] | ||
(.showModal Navigation | ||
(clj->js {:stack {:children | ||
[{:component | ||
{:name comp | ||
:id comp | ||
:options {:topBar {:visible false}}}}]}}))) | ||
|
||
(defn close-modal [_]) | ||
|
||
(defn close-all-modals [] | ||
(.dismissAllModals Navigation)) | ||
|
||
(defn get-id [comp id] | ||
(str comp "-" id)) | ||
|
||
(defn get-options [show-topbar? options] | ||
(if show-topbar? | ||
(merge options | ||
(nav-roots/status-bar-options) | ||
(nav-roots/merge-top-bar (nav-roots/topbar-options) options)) | ||
{:topBar {:visible false}})) | ||
|
||
(defn change-stack-root [[comp _]] | ||
(let [{:keys [options]} (get views/screens comp)] | ||
(.setStackRoot Navigation | ||
(name comp) | ||
(clj->js {:stack {:id comp | ||
:children [{:component {:id comp | ||
:name comp | ||
:options (get-options false options)}}]}})))) | ||
|
||
(defn navigate [[comp _]] | ||
(let [{:keys [options]} (get views/screens comp)] | ||
(reset! nav2-utils/container-stack-view-id comp) | ||
(.push Navigation | ||
(name :home-stack) | ||
(clj->js {:stack {:id comp | ||
:children [{:component {:id comp | ||
:name comp | ||
:options (get-options false options)}}]}})))) | ||
|
||
(defn navigate-from-switcher [[comp id from-home?]] | ||
(if from-home? | ||
(navigate [comp id]) | ||
(change-stack-root [comp id]))) | ||
|
||
(re-frame/reg-fx | ||
:init-root-fx-nav2 | ||
(fn [new-root-id] | ||
(reset! nav2-utils/container-stack-view-id new-root-id) | ||
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id))))) | ||
|
||
(re-frame/reg-fx :open-modal-fx-nav2 open-modal) | ||
|
||
(re-frame/reg-fx :close-modal-fx-nav2 close-modal) | ||
|
||
(re-frame/reg-fx :navigate-to-fx-nav2 navigate) | ||
|
||
(re-frame/reg-fx :navigate-from-switcher-fx navigate-from-switcher) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns status-im.navigation2.home-stack | ||
(:require [quo.react-native :as rn] | ||
[quo2.screens.main :as quo2.preview] | ||
[status-im.switcher.switcher :as switcher] | ||
[status-im.ui.screens.home.views :as home] | ||
[status-im.switcher.constants :as switcher-constants] | ||
[status-im.ui.screens.browser.empty-tab.views :as empty-tab] | ||
[status-im.ui.screens.wallet.accounts.views :as wallet.accounts] | ||
[status-im.switcher.bottom-tabs :as bottom-tabs])) | ||
|
||
;; TODO(parvesh) - improve stack changing performance (load all stacks at once) | ||
(defn stack-view [] | ||
(let [{:keys [width height]} (switcher-constants/dimensions)] | ||
;; bottom-tabs-height (switcher-constants/bottom-tabs-height)] | ||
[rn/view {:style {:width width | ||
:height (- height 80)}} ;; TODO(parvesh) - add height for ios | ||
(case @bottom-tabs/selected-tab-id | ||
:chats-stack [home/home] | ||
:communities-stack [quo2.preview/main-screen] | ||
:wallet-stack [wallet.accounts/accounts-overview] | ||
:browser-stack [empty-tab/empty-tab])])) | ||
|
||
(defn home [] | ||
[:<> | ||
[stack-view] | ||
[bottom-tabs/bottom-tabs] | ||
[switcher/switcher :home-stack]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(ns status-im.navigation2.roots) | ||
|
||
(defn roots [] | ||
{:home-stack | ||
{:root | ||
{:stack {:id :home-stack | ||
:children [{:component {:name :home-stack | ||
:id :home-stack | ||
:options {:topBar {:visible false}}}}]}}}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(ns status-im.navigation2.screens | ||
(:require [status-im.navigation2.home-stack :as home-stack])) | ||
|
||
(def screens [{:name :home-stack | ||
:insets {:top false} | ||
:component home-stack/home}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(ns status-im.navigation2.stack-with-switcher | ||
(:require [status-im.switcher.switcher :as switcher])) | ||
|
||
(defn overlap-stack [comp view-id] | ||
[:<> | ||
[comp] | ||
[switcher/switcher view-id]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns status-im.navigation2.utils) | ||
|
||
(defonce container-stack-view-id (atom nil)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.