Merge pull request #360 from status-im/bug/#343

Navigator fixes (#343)

Former-commit-id: 8b0058aa94
This commit is contained in:
Roman Volosovskyi 2016-10-18 14:17:55 +03:00 committed by GitHub
commit d5e044baa6
11 changed files with 74 additions and 70 deletions

View File

@ -6,7 +6,6 @@
[status-im.components.status :as status]
[status-im.utils.types :refer [json->clj]]
[status-im.utils.identicon :refer [identicon]]
[status-im.db :refer [default-view]]
[status-im.utils.random :as random]
[status-im.i18n :refer [label]]
[status-im.constants :refer [content-type-command-request]]

View File

@ -3,7 +3,6 @@
[status-im.utils.handlers :refer [register-handler] :as u]
[taoensso.timbre :as log]
[status-im.utils.types :refer [json->clj]]
[status-im.db :refer [default-view]]
[status-im.data-store.core :as data-store]
[status-im.components.status :as status]
[status-im.constants :refer [console-chat-id]]))

View File

@ -12,6 +12,7 @@
[status-im.accounts.styles :as st]))
(defn on-press [address]
(dispatch [:navigate-to-clean :accounts])
(dispatch [:navigate-to :login address])
(dispatch [:set-in [:login :address] address]))

View File

@ -78,8 +78,8 @@
(dispatch [:set :keyboard-height 0]))))
:render
(fn []
(when @view-id
(let [current-view (validate-current-view @view-id @signed-up?)]
(log/debug current-view)
(let [component (case current-view
:discovery main-tabs
:discovery-tag discovery-tag
@ -101,7 +101,7 @@
:recover recover
:confirm confirm
:my-profile my-profile)]
[component])))})))
[component]))))})))
(defn init [& [env]]
(dispatch-sync [:reset-app])

View File

@ -97,10 +97,11 @@
[chat-icon]]]))))
(defview chat-toolbar []
[show-actions [:chat-ui-props :show-actions?]]
[show-actions? [:chat-ui-props :show-actions?]
accounts [:get :accounts]]
[view
[status-bar]
[toolbar {:hide-nav? show-actions
[toolbar {:hide-nav? (or (empty? accounts) show-actions?)
:custom-content [toolbar-content-view]
:custom-action [toolbar-action]
:style (get-in platform-specific [:component-styles :toolbar])}]])

View File

@ -50,11 +50,13 @@
name
contacts
chat-id]} (subscribe [:chat-properties [:group-chat :name :contacts :chat-id]])
show-actions (subscribe [:chat-ui-props :show-actions?])
show-actions? (subscribe [:chat-ui-props :show-actions?])
accounts (subscribe [:get :accounts])
contact (subscribe [:get-in [:contacts @chat-id]])
sync-state (subscribe [:get :sync-state])]
(fn []
[view (st/chat-name-view @show-actions)
[view (st/chat-name-view (or (empty? @accounts)
@show-actions?))
[text {:style st/chat-name-text
:number-of-lines 1
:font :toolbar-title}

View File

@ -36,7 +36,7 @@
new-chat?
(into [{:image {:source {:uri :icon_add}
:style st/toolbar-icon}
:handler #(dispatch [:navigate-forget :group-contacts :people])}]))]
:handler #(dispatch [:navigate-to :group-contacts :people])}]))]
[toolbar {:nav-action {:image {:source {:uri :icon_hamburger}
:style st/hamburger-icon}
:handler open-drawer}
@ -56,7 +56,7 @@
[action-button-item
{:title (label :t/new-chat)
:buttonColor :#9b59b6
:onPress #(dispatch [:navigate-forget :group-contacts :people])}
:onPress #(dispatch [:navigate-to :group-contacts :people])}
[ion-icon {:name :md-create
:style st/create-icon}]]
[action-button-item

View File

@ -16,7 +16,9 @@
(defmethod nav/preload-data! :group-contacts
[db [_ _ group]]
(assoc db :contacts-group group))
(if group
(assoc db :contacts-group group)
db))
(defmethod nav/preload-data! :new-group
[db _]

View File

@ -7,8 +7,6 @@
;; schema of app-db
(def schema {:greeting s/Str})
(def default-view :chat)
;; initial state of app-db
(def app-db {:identity-password "replace-me-with-user-entered-password"
:identity "me"
@ -40,8 +38,8 @@
:chat-ui-props {:show-actions? false
:show-bottom-info? false}
:selected-participants #{}
:view-id default-view
:navigation-stack (list default-view)
:view-id nil
:navigation-stack '()
:current-tag nil
:qr-codes {}
:keyboard-height 0

View File

@ -28,9 +28,16 @@
(defn orientation->keyword [o]
(keyword (.toLowerCase o)))
(defn validate-current-view
[current-view signed-up?]
(if (or (contains? #{:login :chat :recover :accounts} current-view)
signed-up?)
current-view
:chat))
(defn app-root []
(let [signed-up (subscribe [:signed-up?])
_ (log/debug "signed up: " @signed-up)
(let [signed-up? (subscribe [:signed-up?])
_ (log/debug "signed up: " @signed-up?)
view-id (subscribe [:get :view-id])
account-id (subscribe [:get :current-account-id])
keyboard-height (subscribe [:get :keyboard-height])]
@ -56,15 +63,9 @@
#(dispatch [:set :keyboard-height 0]))))
:render
(fn []
(let [startup-view (if @account-id
(if @signed-up
@view-id
:chat)
(if (contains? #{:login :chat} @view-id)
@view-id
:accounts))]
(log/debug startup-view)
(let [component (case (if true startup-view :chat)
(when @view-id
(let [current-view (validate-current-view @view-id @signed-up?)]
(let [component (case current-view
:discovery main-tabs
:discovery-tag discovery-tag
:discovery-search-results discovery-search-results
@ -83,7 +84,7 @@
:accounts accounts
:login login
:my-profile my-profile)]
[component])))})))
[component]))))})))
(defn init []
(dispatch-sync [:reset-app])

View File

@ -1,6 +1,7 @@
(ns status-im.navigation.handlers
(:require [re-frame.core :refer [dispatch debug enrich after]]
[status-im.utils.handlers :refer [register-handler]]))
[status-im.utils.handlers :refer [register-handler]]
[taoensso.timbre :as log]))
(defn push-view [db view-id]
(-> db