navigation refactoring #1609

This commit is contained in:
Andrey Shovkoplyas 2017-08-15 11:05:20 +03:00 committed by Roman Volosovskyi
parent 9bacc65c8d
commit 7506689fe5
4 changed files with 64 additions and 53 deletions

View File

@ -9,4 +9,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: b75d6ec95102ddea68ad1e171f7f8f974533bac7
COCOAPODS: 1.2.1
COCOAPODS: 1.3.1

View File

@ -1621,13 +1621,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-StatusIm-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
49A69B853BD9751F84878340 /* [CP] Check Pods Manifest.lock */ = {
@ -1636,13 +1639,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-StatusImTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
967469AF8BA27D5CEC47B13C /* [CP] Copy Pods Resources */ = {
@ -1666,9 +1672,14 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-StatusIm/Pods-StatusIm-frameworks.sh",
"${PODS_ROOT}/Instabug/Instabug.framework",
"${PODS_ROOT}/Instabug/Instabug.framework.dSYM",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Instabug.framework",
"${DWARF_DSYM_FOLDER_PATH}/Instabug.framework.dSYM",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@ -1708,9 +1719,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-StatusIm/Pods-StatusIm-resources.sh",
"${PODS_ROOT}/Instabug/Instabug.framework/Instabug.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;

View File

@ -633,4 +633,10 @@
(select-keys db [:web3 :current-public-key]))
:dispatch (if exists?
[:update-chat! chat]
[:add-chat group-id chat])})))))
[:add-chat group-id chat])})))))
(register-handler-fx
:show-profile
(fn [{db :db} [_ identity]]
{:db (assoc db :contacts/identity identity)
:dispatch [:navigate-forget :profile]}))

View File

@ -1,24 +1,8 @@
(ns status-im.ui.screens.navigation
(:require [re-frame.core :refer [dispatch subscribe debug enrich after]]
[status-im.utils.handlers :refer [register-handler] :as u]
(:require [re-frame.core :refer [enrich]]
[status-im.utils.handlers :refer [register-handler-db]]
[status-im.constants :refer [console-chat-id]]))
(defn push-view [db view-id]
(-> db
(update :navigation-stack conj view-id)
(assoc :view-id view-id)))
(defn replace-top-element [stack view-id]
(let [stack' (if (> 2 (count stack))
(list :chat-list)
(pop stack))]
(conj stack' view-id)))
(defn replace-view [db view-id]
(-> db
(update :navigation-stack replace-top-element view-id)
(assoc :view-id view-id)))
(defmulti preload-data!
(fn [db [_ view-id]] (or view-id (:view-id db))))
@ -29,24 +13,44 @@
(dissoc db :was-modal?) ;;TODO check how it worked with this bug
(apply preload-data! db args)))
(register-handler :navigate-forget
(register-handler-db
:navigate-forget
(enrich preload-data!)
(fn [db [_ new-view-id]]
(assoc db :view-id new-view-id)))
(register-handler :navigate-to
(defn push-view [db view-id]
(-> db
(update :navigation-stack conj view-id)
(assoc :view-id view-id)))
(register-handler-db
:navigate-to
(enrich preload-data!)
(fn [{:keys [view-id] :as db} [_ new-view-id]]
(if (= view-id new-view-id)
db
(push-view db new-view-id))))
(register-handler :navigate-to-modal
(register-handler-db
:navigate-to-modal
(enrich preload-data!)
(fn [db [_ modal-view]]
(assoc db :modal modal-view)))
(register-handler :navigation-replace
(defn replace-top-element [stack view-id]
(let [stack' (if (> 2 (count stack))
(list :chat-list)
(pop stack))]
(conj stack' view-id)))
(defn replace-view [db view-id]
(-> db
(update :navigation-stack replace-top-element view-id)
(assoc :view-id view-id)))
(register-handler-db
:navigation-replace
(enrich preload-data!)
(fn [db [_ view-id]]
(replace-view db view-id)))
@ -54,7 +58,8 @@
(defn- can-navigate-back? [db]
(and (not (db :creating-account?))))
(register-handler :navigate-back
(register-handler-db
:navigate-back
(enrich -preload-data!)
(fn [{:keys [navigation-stack view-id modal] :as db} _]
(cond
@ -73,35 +78,21 @@
(assoc db :view-id first-in-stack)))
db))))
(defn navigate-to-clean
[db [_ view-id]]
(defn navigate-to-clean [db view-id]
(-> db
(assoc :navigation-stack (list))
(push-view view-id)))
(register-handler :navigate-to-clean navigate-to-clean)
(register-handler-db
:navigate-to-clean
(fn [db [_ view-id]]
(navigate-to-clean db view-id)))
(defn store-prev-tab
[db [_ view-id]]
(-> db
(assoc :prev-tab-view-id (:view-id db))
(assoc :prev-view-id (:view-id db))))
(register-handler :navigate-to-tab
(u/handlers->
store-prev-tab
navigate-to-clean
preload-data!))
(register-handler :on-navigated-to-tab
(register-handler-db
:navigate-to-tab
(enrich preload-data!)
(fn [db [_]]
(assoc db :prev-tab-view-id nil)))
(defn show-profile
[db [_ identity]]
(dispatch [:navigate-forget :profile])
(assoc db :contacts/identity identity))
(register-handler :show-profile show-profile)
(fn [db [_ view-id]]
(-> db
(assoc :prev-tab-view-id (:view-id db))
(assoc :prev-view-id (:view-id db))
(navigate-to-clean view-id))))