use natal-shell in om template
This commit is contained in:
parent
d446960264
commit
3bb110e743
|
@ -2,29 +2,32 @@
|
||||||
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
|
(set! js/React (js/require "react-native/Libraries/react-native/react-native.js"))
|
||||||
|
|
||||||
(ns $PROJECT_NAME_HYPHENATED$.core
|
(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
|
;; 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! 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$"}))
|
(defonce app-state (atom {:text "Welcome to $PROJECT_NAME$"}))
|
||||||
|
|
||||||
(defn widget [data owner]
|
(defn widget [data owner]
|
||||||
(reify
|
(reify
|
||||||
om/IRender
|
om/IRender
|
||||||
(render [this]
|
(render [this]
|
||||||
(view {:style {:flexDirection "column" :margin 40}}
|
(view {:style {:flexDirection "column" :margin 40 :alignItems "center"}}
|
||||||
(text {:style {:fontSize 50 :fontWeight "100"}} (:text data))))))
|
(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})
|
(om/root widget app-state {:target 1})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue