2016-02-07 18:43:43 +00:00
|
|
|
(ns $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core
|
2016-02-10 21:14:05 +00:00
|
|
|
(:require [om.next :as om :refer-macros [defui]]
|
2016-02-10 23:24:17 +00:00
|
|
|
[re-natal.support :as sup]
|
|
|
|
[$PROJECT_NAME_HYPHENATED$.state :as state]))
|
2016-02-07 18:43:43 +00:00
|
|
|
|
2016-05-13 21:57:39 +00:00
|
|
|
(set! js/window.React (js/require "react"))
|
|
|
|
(def ReactNative (js/require "react-native"))
|
|
|
|
|
|
|
|
(defn create-element [rn-comp opts & children]
|
|
|
|
(apply js/React.createElement rn-comp (clj->js opts) children))
|
|
|
|
|
|
|
|
(def app-registry (.-AppRegistry ReactNative))
|
|
|
|
(def view (partial create-element (.-View ReactNative)))
|
|
|
|
(def text (partial create-element (.-Text ReactNative)))
|
|
|
|
(def image (partial create-element (.-Image ReactNative)))
|
|
|
|
(def touchable-highlight (partial create-element (.-TouchableHighlight ReactNative)))
|
2016-02-07 18:43:43 +00:00
|
|
|
|
|
|
|
(def logo-img (js/require "./images/cljs.png"))
|
|
|
|
|
2016-05-13 21:57:39 +00:00
|
|
|
(defn alert [title]
|
|
|
|
(.alert (.-Alert ReactNative) title))
|
|
|
|
|
2016-02-07 18:43:43 +00:00
|
|
|
(defui AppRoot
|
2016-02-10 21:14:05 +00:00
|
|
|
static om/IQuery
|
|
|
|
(query [this]
|
|
|
|
'[:app/msg])
|
2016-02-07 18:43:43 +00:00
|
|
|
Object
|
|
|
|
(render [this]
|
2016-02-10 21:14:05 +00:00
|
|
|
(let [{:keys [app/msg]} (om/props this)]
|
|
|
|
(view {:style {:flexDirection "column" :margin 40 :alignItems "center"}}
|
|
|
|
(text {:style {:fontSize 30 :fontWeight "100" :marginBottom 20 :textAlign "center"}} msg)
|
|
|
|
(image {:source logo-img
|
|
|
|
:style {:width 80 :height 80 :marginBottom 30}})
|
|
|
|
(touchable-highlight {:style {:backgroundColor "#999" :padding 10 :borderRadius 5}
|
|
|
|
:onPress #(alert "HELLO!")}
|
|
|
|
(text {:style {:color "white" :textAlign "center" :fontWeight "bold"}} "press me"))))))
|
|
|
|
|
2016-02-11 20:42:59 +00:00
|
|
|
(defonce RootNode (sup/root-node! 1))
|
2016-02-10 21:14:05 +00:00
|
|
|
(defonce app-root (om/factory RootNode))
|
2016-02-07 18:43:43 +00:00
|
|
|
|
|
|
|
(defn init []
|
2016-02-10 23:24:17 +00:00
|
|
|
(om/add-root! state/reconciler AppRoot 1)
|
2016-02-10 21:14:05 +00:00
|
|
|
(.registerComponent app-registry "$PROJECT_NAME$" (fn [] app-root)))
|