parent
b69ddbe651
commit
fb4e8e0bdd
|
@ -1,9 +1,9 @@
|
||||||
(ns messenger.android.core
|
(ns messenger.android.core
|
||||||
(:require-macros
|
(:require-macros
|
||||||
[natal-shell.components :refer [navigator view text image touchable-highlight list-view
|
[natal-shell.components :refer [navigator view text image touchable-highlight
|
||||||
toolbar-android]]
|
list-view toolbar-android]]
|
||||||
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
[natal-shell.data-source :refer [data-source clone-with-rows]]
|
||||||
[natal-shell.back-android :refer [add-event-listener]]
|
[natal-shell.back-android :refer [add-event-listener remove-event-listener]]
|
||||||
[natal-shell.core :refer [with-error-view]]
|
[natal-shell.core :refer [with-error-view]]
|
||||||
[natal-shell.alert :refer [alert]])
|
[natal-shell.alert :refer [alert]])
|
||||||
(:require [om.next :as om :refer-macros [defui]]
|
(:require [om.next :as om :refer-macros [defui]]
|
||||||
|
@ -21,19 +21,21 @@
|
||||||
|
|
||||||
(def app-registry (.-AppRegistry js/React))
|
(def app-registry (.-AppRegistry js/React))
|
||||||
|
|
||||||
(def initialized-atom (atom false))
|
(def back-button-handler-atom (atom {:nav nil
|
||||||
|
:handler nil}))
|
||||||
|
|
||||||
(defn init-back-button-handler! [nav]
|
(defn init-back-button-handler! [nav]
|
||||||
(if (not @initialized-atom)
|
(let [back-button-handler @back-button-handler-atom]
|
||||||
(swap! initialized-atom
|
(when (not= (:nav back-button-handler) nav)
|
||||||
(fn [initialized]
|
(remove-event-listener "hardwareBackPress" (:handler back-button-handler))
|
||||||
(when (not initialized)
|
(let [new-listener (fn []
|
||||||
(add-event-listener "hardwareBackPress"
|
(binding [state/*nav-render* false]
|
||||||
(fn []
|
(when (< 1 (.-length (.getCurrentRoutes nav)))
|
||||||
(binding [state/*nav-render* false]
|
(.pop nav)
|
||||||
(when (< 1 (.-length (.getCurrentRoutes nav)))
|
true)))]
|
||||||
(.pop nav)
|
(reset! back-button-handler-atom {:nav nav
|
||||||
true)))))
|
:handler new-listener})
|
||||||
true))))
|
(add-event-listener "hardwareBackPress" new-listener)))))
|
||||||
|
|
||||||
(defui AppRoot
|
(defui AppRoot
|
||||||
static om/IQuery
|
static om/IQuery
|
||||||
|
|
Loading…
Reference in New Issue