mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-28 01:16:50 +00:00
[Fix #2987] Improve screen navigation
Signed-off-by: Goran Jovic <goranjovic@gmail.com>
This commit is contained in:
parent
cbc61500f7
commit
90863f1670
@ -54,7 +54,7 @@
|
|||||||
:url dapp-url
|
:url dapp-url
|
||||||
:contact (:whisper-identity contact)}]
|
:contact (:whisper-identity contact)}]
|
||||||
(merge (add-browser-fx cofx browser)
|
(merge (add-browser-fx cofx browser)
|
||||||
{:dispatch [:navigate-to :browser (:browser-id browser)]}))))
|
{:dispatch [:navigate-to :browser {:browser/browser-id (:browser-id browser)}]}))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:open-browser
|
:open-browser
|
||||||
@ -62,7 +62,7 @@
|
|||||||
(fn [{:keys [now] :as cofx} [browser]]
|
(fn [{:keys [now] :as cofx} [browser]]
|
||||||
(let [new-browser (get-new-browser browser now)]
|
(let [new-browser (get-new-browser browser now)]
|
||||||
(merge (add-browser-fx cofx new-browser)
|
(merge (add-browser-fx cofx new-browser)
|
||||||
{:dispatch [:navigate-to :browser (:browser-id new-browser)]}))))
|
{:dispatch [:navigate-to :browser {:browser/browser-id (:browser-id new-browser)}]}))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:update-browser
|
:update-browser
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
(:require [status-im.ui.screens.navigation :as navigation]))
|
(:require [status-im.ui.screens.navigation :as navigation]))
|
||||||
|
|
||||||
(defmethod navigation/preload-data! :browser
|
(defmethod navigation/preload-data! :browser
|
||||||
[db [_ _ browser-id]]
|
[db [_ _ {:keys [browser/browser-id]}]]
|
||||||
(assoc db :browser/options {:browser-id browser-id}))
|
(assoc db :browser/options {:browser-id browser-id}))
|
@ -26,7 +26,8 @@
|
|||||||
{:text (label :t/reorder-groups) :value #(dispatch [:navigate-to :reorder-groups])}])
|
{:text (label :t/reorder-groups) :value #(dispatch [:navigate-to :reorder-groups])}])
|
||||||
|
|
||||||
(defn toolbar-actions []
|
(defn toolbar-actions []
|
||||||
[(act/search #(dispatch [:navigate-to :group-contacts nil :show-search]))
|
[(act/search #(dispatch [:navigate-to :group-contacts {:group/contact-group-id nil
|
||||||
|
:show-search? :show-search}]))
|
||||||
(act/opts (if ios? toolbar-options (rest toolbar-options)))])
|
(act/opts (if ios? toolbar-options (rest toolbar-options)))])
|
||||||
|
|
||||||
(defn toolbar-view []
|
(defn toolbar-view []
|
||||||
@ -63,7 +64,8 @@
|
|||||||
[common/form-title subtitle
|
[common/form-title subtitle
|
||||||
{:count-value contacts-count
|
{:count-value contacts-count
|
||||||
:extended? edit?
|
:extended? edit?
|
||||||
:options [{:action #(dispatch [:navigate-to :edit-contact-group group :contact-group])
|
:options [{:action #(dispatch [:navigate-to :edit-contact-group {:group group
|
||||||
|
:group-type :contact-group}])
|
||||||
:label (label :t/edit-group)}]}])
|
:label (label :t/edit-group)}]}])
|
||||||
[view st/contacts-list
|
[view st/contacts-list
|
||||||
[common/list-footer]
|
[common/list-footer]
|
||||||
@ -86,7 +88,7 @@
|
|||||||
[touchable-highlight {:on-press #(do
|
[touchable-highlight {:on-press #(do
|
||||||
(when edit?
|
(when edit?
|
||||||
(dispatch [:set-in [:contacts/list-ui-props :edit?] true]))
|
(dispatch [:set-in [:contacts/list-ui-props :edit?] true]))
|
||||||
(dispatch [:navigate-to :group-contacts (:group-id group)]))}
|
(dispatch [:navigate-to :group-contacts {:group/contact-group-id (:group-id group)}]))}
|
||||||
[view
|
[view
|
||||||
[text {:style st/show-all-text
|
[text {:style st/show-all-text
|
||||||
:uppercase? (get-in platform-specific [:uppercase?])
|
:uppercase? (get-in platform-specific [:uppercase?])
|
||||||
|
@ -92,6 +92,30 @@
|
|||||||
(spec/def :navigation/navigation-stack (spec/nilable seq?))
|
(spec/def :navigation/navigation-stack (spec/nilable seq?))
|
||||||
(spec/def :navigation/prev-tab-view-id (spec/nilable keyword?))
|
(spec/def :navigation/prev-tab-view-id (spec/nilable keyword?))
|
||||||
(spec/def :navigation/prev-view-id (spec/nilable keyword?))
|
(spec/def :navigation/prev-view-id (spec/nilable keyword?))
|
||||||
|
;; navigation screen params
|
||||||
|
(spec/def :navigation.screen-params/network-details (allowed-keys :req [:networks/selected-network]))
|
||||||
|
(spec/def :navigation.screen-params/browser (allowed-keys :req [:browser/browser-id]))
|
||||||
|
(spec/def :navigation.screen-params/contact (spec/nilable map?))
|
||||||
|
(spec/def :navigation.screen-params/qr-source (spec/nilable keyword?))
|
||||||
|
(spec/def :navigation.screen-params/qr-value (spec/nilable string?))
|
||||||
|
(spec/def :navigation.screen-params/qr-viewer (allowed-keys :opt-un [:navigation.screen-params/contact
|
||||||
|
:navigation.screen-params/qr-source
|
||||||
|
:navigation.screen-params/qr-value]))
|
||||||
|
(spec/def :navigation.screen-params/current-qr-context (spec/nilable any?))
|
||||||
|
(spec/def :navigation.screen-params/qr-scanner (allowed-keys :opt-un [:navigation.screen-params/current-qr-context]))
|
||||||
|
(spec/def :navigation.screen-params/show-search? (spec/nilable any?))
|
||||||
|
(spec/def :navigation.screen-params/group-contacts (allowed-keys :opt [:group/contact-group-id]
|
||||||
|
:opt-un [:navigation.screen-params/show-search?]))
|
||||||
|
(spec/def :navigation.screen-params/group (spec/nilable any?))
|
||||||
|
(spec/def :navigation.screen-params/group-type (spec/nilable any?))
|
||||||
|
(spec/def :navigation.screen-params/edit-contact-group (allowed-keys :opt-un [:navigation.screen-params/group
|
||||||
|
:navigation.screen-params/group-type]))
|
||||||
|
(spec/def :navigation/screen-params (spec/nilable (allowed-keys :opt-un [:navigation.screen-params/network-details
|
||||||
|
:navigation.screen-params/browser
|
||||||
|
:navigation.screen-params/qr-viewer
|
||||||
|
:navigation.screen-params/qr-scanner
|
||||||
|
:navigation.screen-params/group-contacts
|
||||||
|
:navigation.screen-params/edit-contact-group])))
|
||||||
|
|
||||||
;;;;NETWORK
|
;;;;NETWORK
|
||||||
|
|
||||||
@ -138,7 +162,8 @@
|
|||||||
:inbox/password
|
:inbox/password
|
||||||
:browser/browsers
|
:browser/browsers
|
||||||
:browser/options
|
:browser/options
|
||||||
:new/open-dapp]
|
:new/open-dapp
|
||||||
|
:navigation/screen-params]
|
||||||
:opt-un
|
:opt-un
|
||||||
[::current-public-key
|
[::current-public-key
|
||||||
::modal
|
::modal
|
||||||
|
@ -24,22 +24,13 @@
|
|||||||
(dissoc db :public-group-topic))
|
(dissoc db :public-group-topic))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :group-contacts
|
(defmethod nav/preload-data! :group-contacts
|
||||||
[db [_ _ group-id show-search?]]
|
[db [_ _ {:keys [show-search?]}]]
|
||||||
(-> db
|
(-> db
|
||||||
(assoc :group/contact-group-id group-id)
|
|
||||||
(update :toolbar-search
|
(update :toolbar-search
|
||||||
assoc
|
assoc
|
||||||
:show (when show-search? :contact-list)
|
:show (when show-search? :contact-list)
|
||||||
:text "")))
|
:text "")))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :edit-contact-group
|
|
||||||
[db [_ _ group group-type]]
|
|
||||||
(if group
|
|
||||||
(assoc db :group/contact-group-id (:group-id group)
|
|
||||||
:group/group-type group-type
|
|
||||||
:new-chat-name (:name group))
|
|
||||||
db))
|
|
||||||
|
|
||||||
(defmethod nav/preload-data! :reorder-groups
|
(defmethod nav/preload-data! :reorder-groups
|
||||||
[db [_ _]]
|
[db [_ _]]
|
||||||
(assoc db :group/groups-order (->> (vals (:group/contact-groups db))
|
(assoc db :group/groups-order (->> (vals (:group/contact-groups db))
|
||||||
|
@ -118,13 +118,12 @@
|
|||||||
[more-btn contacts-limit contacts-count #(dispatch [:navigate-to :edit-group-contact-list])])]))
|
[more-btn contacts-limit contacts-count #(dispatch [:navigate-to :edit-group-contact-list])])]))
|
||||||
|
|
||||||
(defview edit-contact-group []
|
(defview edit-contact-group []
|
||||||
(letsubs [group-name [:get :new-chat-name]
|
(letsubs [{:keys [group group-type]} [:get-screen-params]]
|
||||||
group [:get-contact-group]
|
(let [group-name (:name group)
|
||||||
type [:get-group-type]]
|
save-btn-enabled? (and (spec/valid? ::v/name group-name)
|
||||||
(let [save-btn-enabled? (and (spec/valid? ::v/name group-name)
|
|
||||||
(not= group-name (:name group)))]
|
(not= group-name (:name group)))]
|
||||||
[keyboard-avoiding-view {:style styles/group-container}
|
[keyboard-avoiding-view {:style styles/group-container}
|
||||||
[group-toolbar type true]
|
[group-toolbar group-type true]
|
||||||
[group-name-view]
|
[group-name-view]
|
||||||
[view styles/list-view-container
|
[view styles/list-view-container
|
||||||
[add-btn #(dispatch [:navigate-to :add-contacts-toggle-list])]
|
[add-btn #(dispatch [:navigate-to :add-contacts-toggle-list])]
|
||||||
|
@ -43,10 +43,15 @@
|
|||||||
|
|
||||||
(defn navigate-to
|
(defn navigate-to
|
||||||
"Navigates to particular view"
|
"Navigates to particular view"
|
||||||
[{:keys [view-id] :as db} go-to-view-id]
|
([db go-to-view-id]
|
||||||
|
(navigate-to db go-to-view-id nil))
|
||||||
|
([{:keys [view-id] :as db} go-to-view-id screen-params]
|
||||||
|
(let [db (cond-> db
|
||||||
|
(seq screen-params)
|
||||||
|
(assoc-in [:navigation/screen-params go-to-view-id] screen-params))]
|
||||||
(if (= view-id go-to-view-id)
|
(if (= view-id go-to-view-id)
|
||||||
db
|
db
|
||||||
(push-view db go-to-view-id)))
|
(push-view db go-to-view-id)))))
|
||||||
|
|
||||||
;; event handlers
|
;; event handlers
|
||||||
|
|
||||||
@ -59,8 +64,8 @@
|
|||||||
(register-handler-db
|
(register-handler-db
|
||||||
:navigate-to
|
:navigate-to
|
||||||
(re-frame/enrich preload-data!)
|
(re-frame/enrich preload-data!)
|
||||||
(fn [db [_ new-view-id]]
|
(fn [db [_ & params]]
|
||||||
(navigate-to db new-view-id)))
|
(apply navigate-to db params)))
|
||||||
|
|
||||||
(register-handler-db
|
(register-handler-db
|
||||||
:navigate-to-modal
|
:navigate-to-modal
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
(:require [re-frame.core :refer [dispatch dispatch-sync after] :as re-frame]
|
(:require [re-frame.core :refer [dispatch dispatch-sync after] :as re-frame]
|
||||||
[status-im.utils.handlers :refer [register-handler] :as handlers]
|
[status-im.utils.handlers :refer [register-handler] :as handlers]
|
||||||
[status-im.data-store.networks :as networks]
|
[status-im.data-store.networks :as networks]
|
||||||
[status-im.ui.screens.network-settings.navigation]
|
|
||||||
[status-im.ui.screens.accounts.events :as accounts-events]
|
[status-im.ui.screens.accounts.events :as accounts-events]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.utils.ethereum.core :as utils]))
|
[status-im.utils.ethereum.core :as utils]))
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
(ns status-im.ui.screens.network-settings.navigation
|
|
||||||
(:require [status-im.ui.screens.navigation :as navigation]))
|
|
||||||
|
|
||||||
(defmethod navigation/preload-data! :network-details
|
|
||||||
[db [_ _ network]]
|
|
||||||
(assoc db :networks/selected-network network))
|
|
@ -22,9 +22,10 @@
|
|||||||
:value #(rf/dispatch [:network-remove])}])
|
:value #(rf/dispatch [:network-remove])}])
|
||||||
|
|
||||||
(views/defview network-details []
|
(views/defview network-details []
|
||||||
(views/letsubs [{:keys [id name config]} [:get :networks/selected-network]
|
(views/letsubs [{:keys [networks/selected-network]} [:get-screen-params]
|
||||||
{:keys [network]} [:get-current-account]]
|
{:keys [network]} [:get-current-account]]
|
||||||
(let [connected? (= id network)]
|
(let [{:keys [id name config]} selected-network
|
||||||
|
connected? (= id network)]
|
||||||
[react/view {:flex 1}
|
[react/view {:flex 1}
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
[toolbar/simple-toolbar]
|
[toolbar/simple-toolbar]
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
(fn [{:keys [id name config] :as network}]
|
(fn [{:keys [id name config] :as network}]
|
||||||
(let [connected? (= id current-network)]
|
(let [connected? (= id current-network)]
|
||||||
[react/touchable-highlight
|
[react/touchable-highlight
|
||||||
{:on-press #(re-frame/dispatch [:navigate-to :network-details network])}
|
{:on-press #(re-frame/dispatch [:navigate-to :network-details {:networks/selected-network network}])}
|
||||||
[react/view styles/network-item
|
[react/view styles/network-item
|
||||||
[network-icon connected? 40]
|
[network-icon connected? 40]
|
||||||
[react/view {:padding-horizontal 16}
|
[react/view {:padding-horizontal 16}
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
(ns status-im.ui.screens.qr-scanner.events
|
(ns status-im.ui.screens.qr-scanner.events
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[status-im.ui.components.camera :as camera]
|
[status-im.ui.components.camera :as camera]
|
||||||
[status-im.ui.screens.navigation :as nav]
|
|
||||||
[status-im.utils.handlers :as u :refer [register-handler]]
|
[status-im.utils.handlers :as u :refer [register-handler]]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
[status-im.i18n :as i18n]))
|
[status-im.i18n :as i18n]))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :qr-scanner
|
|
||||||
[db [_ _ identifier]]
|
|
||||||
(assoc db :current-qr-context identifier))
|
|
||||||
|
|
||||||
(defn set-current-identifier [db [_ identifier handler]]
|
(defn set-current-identifier [db [_ identifier handler]]
|
||||||
(assoc-in db [:qr-codes identifier] handler))
|
(assoc-in db [:qr-codes identifier] handler))
|
||||||
|
|
||||||
@ -17,7 +12,7 @@
|
|||||||
[_ [_ identifier]]
|
[_ [_ identifier]]
|
||||||
(re-frame/dispatch [:request-permissions
|
(re-frame/dispatch [:request-permissions
|
||||||
[:camera]
|
[:camera]
|
||||||
#(re-frame/dispatch [:navigate-to :qr-scanner identifier])
|
#(re-frame/dispatch [:navigate-to :qr-scanner {:current-qr-context identifier}])
|
||||||
#(utils/show-popup (i18n/label :t/error)
|
#(utils/show-popup (i18n/label :t/error)
|
||||||
(i18n/label :t/camera-access-error))]))
|
(i18n/label :t/camera-access-error))]))
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
[toolbar/simple-toolbar title]]))
|
[toolbar/simple-toolbar title]]))
|
||||||
|
|
||||||
(defview qr-scanner []
|
(defview qr-scanner []
|
||||||
(letsubs [identifier [:get :current-qr-context]
|
(letsubs [{identifier :current-qr-context} [:get-screen-params]
|
||||||
camera-initialized? (reagent/atom false)]
|
camera-initialized? (reagent/atom false)]
|
||||||
|
|
||||||
[react/view styles/barcode-scanner-container
|
[react/view styles/barcode-scanner-container
|
||||||
|
@ -54,3 +54,7 @@
|
|||||||
:<- [:sync-state]
|
:<- [:sync-state]
|
||||||
(fn [sync-state]
|
(fn [sync-state]
|
||||||
(#{:pending :in-progress} sync-state)))
|
(#{:pending :in-progress} sync-state)))
|
||||||
|
|
||||||
|
(reg-sub :get-screen-params
|
||||||
|
(fn [db [_ view-id]]
|
||||||
|
(get-in db [:navigation/screen-params (or view-id (:view-id db))])))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user