Navigator fixes (#343)
This commit is contained in:
parent
d188b59803
commit
96e8f32c37
|
@ -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]]
|
||||
|
|
|
@ -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]]))
|
||||
|
|
|
@ -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]))
|
||||
|
||||
|
|
|
@ -78,30 +78,30 @@
|
|||
(dispatch [:set :keyboard-height 0]))))
|
||||
:render
|
||||
(fn []
|
||||
(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
|
||||
:discovery-search-results discovery-search-results
|
||||
:add-participants new-participants
|
||||
:remove-participants remove-participants
|
||||
:chat-list main-tabs
|
||||
:new-group new-group
|
||||
:group-settings group-settings
|
||||
:contact-list main-tabs
|
||||
:group-contacts contact-list
|
||||
:new-contact new-contact
|
||||
:qr-scanner qr-scanner
|
||||
:chat chat
|
||||
:profile profile
|
||||
:profile-photo-capture profile-photo-capture
|
||||
:accounts accounts
|
||||
:login login
|
||||
:recover recover
|
||||
:confirm confirm
|
||||
:my-profile my-profile)]
|
||||
[component])))})))
|
||||
(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
|
||||
:add-participants new-participants
|
||||
:remove-participants remove-participants
|
||||
:chat-list main-tabs
|
||||
:new-group new-group
|
||||
:group-settings group-settings
|
||||
:contact-list main-tabs
|
||||
:group-contacts contact-list
|
||||
:new-contact new-contact
|
||||
:qr-scanner qr-scanner
|
||||
:chat chat
|
||||
:profile profile
|
||||
:profile-photo-capture profile-photo-capture
|
||||
:accounts accounts
|
||||
:login login
|
||||
:recover recover
|
||||
:confirm confirm
|
||||
:my-profile my-profile)]
|
||||
[component]))))})))
|
||||
|
||||
(defn init [& [env]]
|
||||
(dispatch-sync [:reset-app])
|
||||
|
|
|
@ -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])}]])
|
||||
|
|
|
@ -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?])
|
||||
contact (subscribe [:get-in [:contacts @chat-id]])
|
||||
sync-state (subscribe [:get :sync-state])]
|
||||
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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 _]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,34 +63,28 @@
|
|||
#(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)
|
||||
:discovery main-tabs
|
||||
:discovery-tag discovery-tag
|
||||
:discovery-search-results discovery-search-results
|
||||
:add-participants new-participants
|
||||
:remove-participants remove-participants
|
||||
:chat-list main-tabs
|
||||
:new-group new-group
|
||||
:group-settings group-settings
|
||||
:contact-list main-tabs
|
||||
:group-contacts contact-list
|
||||
:new-contact new-contact
|
||||
:qr-scanner qr-scanner
|
||||
:chat chat
|
||||
:profile profile
|
||||
:profile-photo-capture profile-photo-capture
|
||||
:accounts accounts
|
||||
:login login
|
||||
:my-profile my-profile)]
|
||||
[component])))})))
|
||||
(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
|
||||
:add-participants new-participants
|
||||
:remove-participants remove-participants
|
||||
:chat-list main-tabs
|
||||
:new-group new-group
|
||||
:group-settings group-settings
|
||||
:contact-list main-tabs
|
||||
:group-contacts contact-list
|
||||
:new-contact new-contact
|
||||
:qr-scanner qr-scanner
|
||||
:chat chat
|
||||
:profile profile
|
||||
:profile-photo-capture profile-photo-capture
|
||||
:accounts accounts
|
||||
:login login
|
||||
:my-profile my-profile)]
|
||||
[component]))))})))
|
||||
|
||||
(defn init []
|
||||
(dispatch-sync [:reset-app])
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue