navigation listener
This commit is contained in:
parent
cd68187bcb
commit
5bf546c992
|
@ -5,6 +5,7 @@
|
|||
[oops.core :as oops]
|
||||
[promesa.core :as promesa]
|
||||
[react-native.flat-list :as flat-list]
|
||||
[react-native.navigation :as navigation]
|
||||
[react-native.platform :as platform]
|
||||
[react-native.section-list :as section-list]
|
||||
[react-native.utils :as utils]
|
||||
|
@ -189,6 +190,15 @@
|
|||
[handler]
|
||||
(use-mount (fn [] handler)))
|
||||
|
||||
(defn use-nav-unmount
|
||||
[handler view-id]
|
||||
(use-effect
|
||||
(fn []
|
||||
(let [listener {:componentDidDisappear handler}
|
||||
unsubscribe (navigation/reg-comp-listener listener view-id)]
|
||||
#(.remove unsubscribe)))
|
||||
[]))
|
||||
|
||||
(defn use-callback
|
||||
([handler]
|
||||
(use-callback handler []))
|
||||
|
|
|
@ -79,6 +79,17 @@
|
|||
(fn [^js evn]
|
||||
(handler (.-componentName evn)))))
|
||||
|
||||
(defn- view-id->comp-id
|
||||
[view-id]
|
||||
(subs (str view-id) 8))
|
||||
|
||||
(defn reg-comp-listener
|
||||
[listener view-id]
|
||||
(.registerComponentListener
|
||||
^js (.events ^js Navigation)
|
||||
(clj->js listener)
|
||||
(view-id->comp-id view-id)))
|
||||
|
||||
(defn merge-options
|
||||
[id opts]
|
||||
(.mergeOptions Navigation id (clj->js opts)))
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
[react-native.navigation :as navigation]
|
||||
=======
|
||||
>>>>>>> def673650 (navigation listener)
|
||||
[reagent.core :as reagent]
|
||||
>>>>>>> 9caa503ec (lint)
|
||||
[status-im.contexts.wallet.account.style :as style]
|
||||
|
@ -13,8 +16,7 @@
|
|||
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]
|
||||
["react-native-navigation" :refer (Navigation)]))
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def first-tab-id :assets)
|
||||
|
||||
|
@ -29,6 +31,7 @@
|
|||
(defn- change-tab [id] (rf/dispatch [:wallet/select-account-tab id]))
|
||||
|
||||
(defn view
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
[]
|
||||
<<<<<<< HEAD
|
||||
|
@ -90,15 +93,16 @@
|
|||
=======
|
||||
[{:keys [component-id]}]
|
||||
>>>>>>> 9caa503ec (lint)
|
||||
=======
|
||||
[]
|
||||
>>>>>>> def673650 (navigation listener)
|
||||
(let [selected-tab (reagent/atom first-tab-id)]
|
||||
(fn []
|
||||
(let [{:keys [name color formatted-balance
|
||||
watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
||||
customization-color (rf/sub [:profile/customization-color])]
|
||||
(println "ddd" component-id)
|
||||
;(rn/use-mount (fn []
|
||||
; (navigation/reg-component-did-disappear-listener (fn [param1] (println "ppp" param1)))))
|
||||
;(rn/use-unmount #(rf/dispatch [:wallet/close-account-page]))
|
||||
customization-color (rf/sub [:profile/customization-color])
|
||||
view-id (rf/sub [:view-id])]
|
||||
(rn/use-nav-unmount #(rf/dispatch [:wallet/close-account-page]) view-id)
|
||||
[rn/view {:style {:flex 1}}
|
||||
[account-switcher/view
|
||||
{:type :wallet-networks
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
(defn view
|
||||
[]
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])
|
||||
network-details (rf/sub [:wallet/network-details])]
|
||||
|
@ -67,6 +68,11 @@
|
|||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])]
|
||||
(rn/use-unmount on-close)
|
||||
>>>>>>> c3f098e6c (lint)
|
||||
=======
|
||||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])
|
||||
view-id (rf/sub [:view-id])]
|
||||
(rn/use-nav-unmount on-close view-id)
|
||||
>>>>>>> def673650 (navigation listener)
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:header [account-switcher/view
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
current-limit)
|
||||
should-try-again? (and (not limit-insufficient?) no-routes-found?)
|
||||
current-address (rf/sub [:wallet/current-viewing-account-address])
|
||||
<<<<<<< HEAD
|
||||
owned-eth-token (rf/sub [:wallet/token-by-symbol
|
||||
(string/upper-case
|
||||
constants/mainnet-short-name)
|
||||
|
@ -294,12 +295,15 @@
|
|||
(or no-routes-found? limit-insufficient?)
|
||||
(not-empty sender-network-values)
|
||||
(not not-enough-asset?))]
|
||||
=======
|
||||
view-id (rf/sub [:view-id])]
|
||||
>>>>>>> def673650 (navigation listener)
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
|
||||
app-keyboard-listener (.addEventListener rn/app-state "change" dismiss-keyboard-fn)]
|
||||
#(.remove app-keyboard-listener))))
|
||||
(rn/use-unmount on-navigate-back)
|
||||
(rn/use-nav-unmount on-navigate-back view-id)
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||
|
|
|
@ -152,8 +152,9 @@
|
|||
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
|
||||
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))
|
||||
local-suggestion-address (rf/sub [:wallet/local-suggestions->full-address])
|
||||
color (rf/sub [:wallet/current-viewing-account-color])]
|
||||
(rn/use-unmount on-close)
|
||||
color (rf/sub [:wallet/current-viewing-account-color])
|
||||
view-id (rf/sub [:view-id])]
|
||||
(rn/use-nav-unmount on-close view-id)
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:keyboard-should-persist-taps true
|
||||
|
|
|
@ -64,8 +64,9 @@
|
|||
on-change-tab #(set-selected-tab %)
|
||||
on-close (fn []
|
||||
(rf/dispatch [:wallet/clean-selected-token])
|
||||
(rf/dispatch [:wallet/clean-selected-collectible]))]
|
||||
(rn/use-unmount on-close)
|
||||
(rf/dispatch [:wallet/clean-selected-collectible]))
|
||||
view-id (rf/sub [:view-id])]
|
||||
(rn/use-nav-unmount on-close view-id)
|
||||
[rn/safe-area-view {:style style/container}
|
||||
[account-switcher/view
|
||||
{:icon-name :i/arrow-left
|
||||
|
|
Loading…
Reference in New Issue