Skip to content

Instantly share code, notes, and snippets.

@anmonteiro
Last active November 4, 2015 20:11
Show Gist options
  • Save anmonteiro/dbb34debe608b4470cba to your computer and use it in GitHub Desktop.
Save anmonteiro/dbb34debe608b4470cba to your computer and use it in GitHub Desktop.
NavigatorIOS (Om Next) - No props. / Navigator (Om Next)
(defn view [opts & children]
(apply js/React.createElement js/React.View (clj->js opts) children))
(defn text [opts & children]
(apply js/React.createElement js/React.Text (clj->js opts) children))
(defn image [opts & children]
(apply js/React.createElement js/React.Image (clj->js opts) children))
(defn navigator [opts & children]
(apply js/React.createElement js/React.Navigator (clj->js opts) children))
(defn navigation-bar [opts & children]
(apply js/React.createElement js/React.Navigator.NavigationBar (clj->js opts) children))
(defn map-view [opts & children]
(apply js/React.createElement js/React.MapView (clj->js opts) children))
(defui WidgetComponent
Object
(render [this]
(map-view {:style (:map styles)
:showsUserLocation true})))
(def widget-component (om/factory WidgetComponent))
(def NavigationBarRouteMapper
{:LeftButton (fn [route navgtr idx navState]
nil)
:RightButton (fn [route navgtr idx navState]
nil)
:Title (fn [route navgtr idx navState]
(text {:style (:navBarText styles)} (.-title route)))})
(defui RootComponent
Object
(render [this]
(navigator {:initialRoute {:title "Around The Corner" :index 0}
:renderScene (fn [route navgtr]
(widget-component nil))
:navigationBar (navigation-bar {:routeMapper NavigationBarRouteMapper
:style (:navBar styles)})})))
(def reconciler
(om/reconciler
{:state (atom {:a 1})
:root-render #(.render js/React %1 %2)
:root-unmount #(.unmountComponentAtNode js/React %)}))
(om/add-root! reconciler RootComponent 1)
(defn navigator-ios [opts]
(js/React.createElement js/React.NavigatorIOS (clj->js opts)))
(defui S
Object
(render [this]
(nat/view {:style {:flex 1}}
(nat/text nil "Hello there :)"))))
(defui R
Object
(render [this]
(navigator-ios {:style {:flex 1}
:initialRoute {:component S :title "Search"}})))
(def reconciler
(om/reconciler
{:state (atom {:a 1})
:root-render #(.render js/React %1 %2)
:root-unmount #(.unmountComponentAtNode js/React %)}))
(om/add-root! reconciler R 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment