mirror of
https://github.com/status-im/re-natal.git
synced 2025-01-28 13:24:54 +00:00
a1d875ffbd
- do not use AppRegistry.registerRunnable for mounting component to id 1, this prevents warning to be shown in yellow box. Instead use AppRegistry.registerComponent - shim some document functions so that enabled figwheel heads-up-display works without errors and logs warnings to console (that will be shown on screen in yellow box) - figwheel splash component now loads real app and renders root component. That has to be done to avoid using AppRegistry.registerRunnable to render real app
35 lines
1.5 KiB
Clojure
35 lines
1.5 KiB
Clojure
(ns ^:figwheel-load $PROJECT_NAME_HYPHENATED$.$PLATFORM$.core
|
|
(:require-macros [env.require-img :refer [require-img]])
|
|
(:require [reagent.core :as r :refer [atom]]
|
|
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
|
|
[$PROJECT_NAME_HYPHENATED$.handlers]
|
|
[$PROJECT_NAME_HYPHENATED$.subs]))
|
|
|
|
(set! js/React (js/require "react-native"))
|
|
|
|
(def app-registry (.-AppRegistry js/React))
|
|
(def text (r/adapt-react-class (.-Text js/React)))
|
|
(def view (r/adapt-react-class (.-View js/React)))
|
|
(def image (r/adapt-react-class (.-Image js/React)))
|
|
(def touchable-highlight (r/adapt-react-class (.-TouchableHighlight js/React)))
|
|
|
|
(def logo-img (require-img "./images/cljs.png"))
|
|
|
|
(defn alert [title]
|
|
(.alert (.-Alert js/React) title))
|
|
|
|
(defn app-root []
|
|
(let [greeting (subscribe [:get-greeting])]
|
|
(fn []
|
|
[view {:style {:flex-direction "column" :margin 40 :align-items "center"}}
|
|
[text {:style {:font-size 30 :font-weight "100" :margin-bottom 20 :text-align "center"}} @greeting]
|
|
[image {:source logo-img
|
|
:style {:width 80 :height 80 :margin-bottom 30}}]
|
|
[touchable-highlight {:style {:background-color "#999" :padding 10 :border-radius 5}
|
|
:on-press #(alert "HELLO!")}
|
|
[text {:style {:color "white" :text-align "center" :font-weight "bold"}} "press me"]]])))
|
|
|
|
(defn init []
|
|
(dispatch-sync [:initialize-db])
|
|
(.registerComponent app-registry "$PROJECT_NAME$" #(r/reactify-component app-root)))
|