add PoC of om-next interface

Now it is just static ui which works with figwheel-bridge. Could not implement :jsload-callback tom make figwheel work correctly yet.
State has to be introduced next.
This commit is contained in:
Artur Girenko 2016-02-07 19:43:43 +01:00
parent d55d9d987c
commit 6328174554
4 changed files with 64 additions and 2 deletions

View File

@ -42,6 +42,17 @@ interfaceConf =
'[prismatic/schema "1.0.4"]']
shims: ["cljsjs.react"]
sampleCommand: '(dispatch [:set-greeting "Hello Native World!"])'
'om-next':
cljsDir: "cljs-om-next"
sources:
ios: ["core.cljs"]
android: ["core.cljs"]
common: []
deps: ['[org.omcljs/om "1.0.0-alpha28" :exclusions [cljsjs/react cljsjs/react-dom]]'
'[natal-shell "0.1.6"]']
shims: ["cljsjs.react", "cljsjs.react.dom"]
sampleCommand: '(swap! app-state assoc :app/msg "Hello Native World")'
interfaceNames = Object.keys interfaceConf
log = (s, color = 'green') ->
console.log chalk[color] s
@ -476,7 +487,8 @@ cli.version pkgJson.version
cli.command 'init <name>'
.description 'create a new ClojureScript React Native project'
.action (name) ->
.option "-i, --interface [#{interfaceNames.join ' '}]", 'specify React interface', 'reagent'
.action (name, cmd) ->
if typeof name isnt 'string'
logErr '''
re-natal init requires a project name as the first argument.
@ -484,7 +496,7 @@ cli.command 'init <name>'
re-natal init HelloWorld
'''
ensureFreePort -> init('reagent', name)
ensureFreePort -> init(cmd.interface, name)
cli.command 'upgrade'
.description 'upgrades project files to current installed version of re-natal (the upgrade of re-natal itself is done via npm)'

View File

@ -0,0 +1,25 @@
(ns $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core
(:require-macros [natal-shell.components :refer [view text image touchable-highlight]]
[natal-shell.alert :refer [alert]])
(:require [om.next :as om :refer-macros [defui]]))
(set! js/React (js/require "react-native"))
(def app-registry (.-AppRegistry js/React))
(def logo-img (js/require "./images/cljs.png"))
(defui AppRoot
Object
(render [this]
(view {:style {:flexDirection "column" :margin 40 :alignItems "center"}}
(text {:style {:fontSize 30 :fontWeight "100" :marginBottom 20 :textAlign "center"}} "Hello World!")
(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")))))
(def app-root (om/factory AppRoot))
(defn init []
(.registerComponent app-registry "ReagentApp" #(app-root)))

View File

@ -0,0 +1,21 @@
(ns ^:figwheel-no-load env.$PLATFORM$.main
(:require [om.next :as om :refer-macros [defui]]
[$PROJECT_NAME_HYPHENATED$.$PLATFORM$.core :as core]
[figwheel.client :as figwheel :include-macros true]))
(enable-console-print!)
(defui Reloader
Object
(render [_] (core/app-root)))
(def reloader (om/factory Reloader))
(def root-el (reloader))
(figwheel/watch-and-reload
:websocket-url "ws://localhost:3449/figwheel-ws"
:heads-up-display true
;; :jsload-callback #(.forceUpdate Reloader)
)
(core/init)

View File

@ -0,0 +1,4 @@
(ns env.$PLATFORM$.main
(:require [$PROJECT_NAME_HYPHENATED$.$PLATFORM$.core :as core]))
(core/init)