Skip to content

Instantly share code, notes, and snippets.

@escherize
Created March 16, 2016 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save escherize/86e7da7984dca037a930 to your computer and use it in GitHub Desktop.
Save escherize/86e7da7984dca037a930 to your computer and use it in GitHub Desktop.
(ns coffee-app.ios.core
(:require [reagent.core :as r :refer [atom]]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[coffee-app.handlers]
[coffee-app.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 slider (r/adapt-react-class (.-SliderIOS js/React)))
(def picker (r/adapt-react-class (.-PickerIOS js/React)))
(def picker-item (.-Item (.-PickerIOS js/React)))
(def touchable-highlight (r/adapt-react-class (.-TouchableHighlight js/React)))
(def logo-img (js/require "./images/cljs.png"))
(defn alert [title]
(.alert (.-Alert js/React) title))
(defn styles [k]
(get
{:view {:style {:flex-direction "column" :margin 50 :align-items "center"}}
:text {:style {:font-size 30 :font-weight "100" :margin-bottom 20 :text-align "center"}}
:cljs-image {:source logo-img :style {:width 80 :height 80 :margin-bottom 30}}
:touch-highlight {:background-color "#44e" :padding 10 :border-radius 5}}
k {:style {:margin 10}}))
(defn app-root []
(let [greeting (subscribe [:get-greeting])]
(fn []
[view (styles :view)
[text (styles :text) @greeting]
;;[text (:text styles) @greeting]
[image (styles :cljs-image)]
;;[slider {:style {:margin 20 :width 300}}]
[text "Meow"]
[picker {:style {:width 350 :height 100 :margin 100}
:selected-value "Hi!"
:key "heh wat"
:on-value-change #(alert "???")}
[picker-item {:key "ok"
:value "Lemons!"
:label "Hahah wat"}]]
[touchable-highlight {:on-press #(alert "HELLO!")
:style (styles :touch-highlight)}
[text {:style
{:color "white"
:text-align "center"
:font-weight "bold"}} "Pop!"]]])))
(defn init []
(dispatch-sync [:initialize-db])
(.registerComponent app-registry "CoffeeApp" #(r/reactify-component app-root)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment