-
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
a6920ac
commit 9b7cb23
Showing
21 changed files
with
383 additions
and
5 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
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,27 @@ | ||
(ns status-im.navigation2 | ||
(:require [status-im.utils.fx :as fx])) | ||
|
||
(fx/defn init-root-nav2 | ||
{:events [:init-root-nav2]} | ||
[_ root-id] | ||
{:init-root-fx-nav2 root-id}) | ||
|
||
(fx/defn change-tab-nav2 | ||
{:events [:navigate-change-tab-nav2]} | ||
[_ tab-id] | ||
{:change-tab-fx-nav2 tab-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}) | ||
|
||
(fx/defn navigate-to-nav2 | ||
{:events [:navigate-to-nav2]} | ||
[cofx go-to-view-id _] | ||
{:navigate-to-fx-nav2 go-to-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,45 @@ | ||
(ns status-im.navigation2.core | ||
(:require [re-frame.core :as re-frame] | ||
[status-im.navigation2.roots :as roots] | ||
["react-native-navigation" :refer (Navigation)])) | ||
|
||
(def tab-key-idx {:home 0 | ||
:communities 1 | ||
:wallet 2 | ||
:browser 3}) | ||
|
||
;; 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 navigate [comp] | ||
(.push Navigation | ||
(name :home-stack) | ||
(clj->js {:component {:id comp | ||
:name comp}}))) | ||
|
||
(re-frame/reg-fx | ||
:init-root-fx-nav2 | ||
(fn [new-root-id] | ||
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id))))) | ||
|
||
(re-frame/reg-fx | ||
:change-tab-fx-nav2 | ||
(fn [tab-id] | ||
(.mergeOptions Navigation "quo2-tabs-stack" (clj->js {:bottomTabs {:currentTabId tab-id}})))) | ||
|
||
(re-frame/reg-fx :open-modal-fx2 open-modal) | ||
|
||
(re-frame/reg-fx :close-modal-fx2 close-modal) | ||
|
||
(re-frame/reg-fx :navigate-to-fx-nav2 navigate) |
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 [quo2.preview/main-screen] | ||
:communities-stack [home/home] | ||
:wallet-stack [wallet.accounts/accounts-overview] | ||
:browser-stack [empty-tab/empty-tab])])) | ||
|
||
(defn home [] | ||
[:<> | ||
[stack-view] | ||
[bottom-tabs/bottom-tabs] | ||
[switcher/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,9 @@ | ||
(ns status-im.navigation2.roots) | ||
|
||
(defn roots [] | ||
{:quo2-tabs-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
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,45 @@ | ||
(ns status-im.switcher.animation | ||
(:require [quo.react-native :as rn] | ||
[reagent.core :as reagent] | ||
[status-im.switcher.constants :as constants] | ||
[status-im.ui.components.animation :as anim])) | ||
|
||
(def bottom-tabs-opacity (anim/create-value 1)) | ||
(def switcher-button-opacity (anim/create-value 1)) | ||
(def switcher-close-button-icon-opacity (anim/create-value 0)) | ||
(def switcher-close-button-background-opacity (anim/create-value 0)) | ||
(def bottom-tabs-position (anim/create-value 0)) | ||
(def switcher-screen-radius (reagent/atom 1)) | ||
(def layout-animation #js {:duration 300 | ||
:create #js {:type (:ease-in-ease-out rn/layout-animation-types) | ||
:property (:scale-xy rn/layout-animation-properties)} | ||
:update #js {:type (:ease-in-ease-out rn/layout-animation-types) | ||
:property (:scale-xy rn/layout-animation-properties)} | ||
:delete #js {:type (:ease-in-ease-out rn/layout-animation-types) | ||
:property (:scale-xy rn/layout-animation-properties)}}) | ||
|
||
(defn animate-layout [show?] | ||
(let [{:keys [width height]} (constants/dimensions) | ||
target-radius (- (max width height) | ||
constants/switcher-button-radius)] | ||
(rn/configure-next layout-animation) | ||
(reset! switcher-screen-radius (if show? target-radius 1)) | ||
(reagent/flush))) | ||
|
||
(defn timing-animation [property toValue] | ||
(anim/timing property {:toValue toValue | ||
:duration 300 | ||
:useNativeDriver true})) | ||
|
||
(defn animate-components [show?] | ||
(anim/start | ||
(anim/parallel | ||
[(timing-animation bottom-tabs-opacity (if show? 0 1)) | ||
(timing-animation switcher-button-opacity (if show? 0 1)) | ||
(timing-animation switcher-close-button-icon-opacity (if show? 1 0)) | ||
(timing-animation switcher-close-button-background-opacity (if show? 0.2 0)) | ||
(timing-animation bottom-tabs-position (if show? (constants/bottom-tabs-height) 0))]))) | ||
|
||
(defn animate [show?] | ||
(animate-layout show?) | ||
(animate-components show?)) |
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,31 @@ | ||
(ns status-im.switcher.bottom-tabs | ||
(:require [quo.react-native :as rn] | ||
[reagent.core :as reagent] | ||
[status-im.switcher.styles :as styles] | ||
[status-im.utils.handlers :refer [>evt]] | ||
[status-im.ui.components.icons.icons :as icons])) | ||
|
||
(def selected-tab-id (reagent/atom :chats-stack)) | ||
|
||
(defn bottom-tab-pressed [tab-id] | ||
(when-not (= tab-id @selected-tab-id) | ||
(reset! selected-tab-id tab-id) | ||
(>evt [:navigate-change-tab-nav2 tab-id]))) | ||
|
||
;; TODO(parvesh) - reimplement tab with counter, once design is complete | ||
(defn bottom-tab [icon tab-id] | ||
[rn/touchable-opacity {:style {:padding 15} | ||
:active-opacity 1 | ||
:on-press #(bottom-tab-pressed tab-id)} | ||
[icons/icon icon (styles/bottom-tab-icon | ||
(if (= tab-id @selected-tab-id) | ||
:bottom-tabs-selected-tab | ||
:bottom-tabs-non-selected-tab))]]) | ||
|
||
(defn bottom-tabs [] | ||
[rn/animated-view {:style (styles/bottom-tabs)} | ||
[bottom-tab :main-icons/messages-new :chats-stack] | ||
[bottom-tab :main-icons/communities :communities-stack] | ||
[rn/view {:width 10}] | ||
[bottom-tab :main-icons/wallet-new :wallet-stack] | ||
[bottom-tab :main-icons/browser :browser-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,21 @@ | ||
(ns status-im.switcher.constants | ||
(:require [status-im.utils.handlers :refer [<sub]] | ||
[status-im.utils.platform :as platform])) | ||
|
||
(def switcher-button-radius 24) | ||
|
||
(def switcher-button-size (* switcher-button-radius 2)) | ||
|
||
(defn switcher-bottom-position [] | ||
(if platform/android? 17 35)) | ||
|
||
(defn switcher-center-position [] | ||
(+ (switcher-bottom-position) (/ switcher-button-size 2))) | ||
|
||
;; TODO(parvesh) - use different height for android and ios(Confirm from Design) | ||
(defn bottom-tabs-height [] | ||
(if platform/android? 55 80)) | ||
|
||
;; TODO - move to switcher/utils.cljs | ||
(defn dimensions [] | ||
(<sub [:dimensions/window])) |
Oops, something went wrong.