2015-08-26 03:50:58 +00:00
|
|
|
;; Need to set js/React first so that Om can load
|
|
|
|
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
|
|
|
|
|
|
|
|
(ns $PROJECT_NAME_HYPHENATED$.core
|
|
|
|
(:require [om.core :as om]))
|
|
|
|
|
|
|
|
;; Reset js/React back as the form above loads in an different React
|
|
|
|
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
|
|
|
|
|
|
|
|
|
|
|
|
;; Setup some methods to help create React Native elements
|
|
|
|
(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))
|
|
|
|
|
|
|
|
|
|
|
|
;; Set up our Om UI
|
|
|
|
(defonce app-state (atom {:text "Welcome to $PROJECT_NAME$"}))
|
|
|
|
|
|
|
|
(defn widget [data owner]
|
|
|
|
(reify
|
|
|
|
om/IRender
|
|
|
|
(render [this]
|
2015-08-30 15:26:26 +00:00
|
|
|
(view {:style {:flexDirection "column" :margin 40}}
|
2015-08-26 03:50:58 +00:00
|
|
|
(text nil (:text data))))))
|
|
|
|
|
|
|
|
(om/root widget app-state {:target 1})
|
|
|
|
|
|
|
|
(defn ^:export init []
|
|
|
|
((fn render []
|
|
|
|
(.requestAnimationFrame js/window render))))
|