use natal-shell in om template

This commit is contained in:
Dan Motzenbecker 2015-11-15 23:56:45 -05:00
parent d446960264
commit 3bb110e743
1 changed files with 15 additions and 12 deletions

View File

@ -2,29 +2,32 @@
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
(ns $PROJECT_NAME_HYPHENATED$.core
(:require [om.core :as om]))
(:require [om.core :as om])
(:require-macros [natal-shell.components :refer [view text image touchable-highlight]]
[natal-shell.alert-ios :refer [alert]]))
;; Reset js/React back as the form above loads in a different React
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
;; Set up 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]
(view {:style {:flexDirection "column" :margin 40}}
(text {:style {:fontSize 50 :fontWeight "100"}} (:text data))))))
(view {:style {:flexDirection "column" :margin 40 :alignItems "center"}}
(text
{:style {:fontSize 50 :fontWeight "100" :marginBottom 20 :textAlign "center"}}
(:text data))
(image {:source {:uri "https://raw.githubusercontent.com/cljsinfo/logo.cljs/master/cljs.png"}
: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"))))))
(om/root widget app-state {:target 1})