Skip to content

Instantly share code, notes, and snippets.

@sectore
Last active January 1, 2017 16:39
Show Gist options
  • Save sectore/7d84a46da731b3d630dd64904242efb9 to your computer and use it in GitHub Desktop.
Save sectore/7d84a46da731b3d630dd64904242efb9 to your computer and use it in GitHub Desktop.
--
-- Sample PureScript React Native App
-- https://github.com/doolse/purescript-reactnative
--
module Main where
import Prelude
import Control.Monad.Eff (Eff)
import React (ReactClass, createClass, spec)
import ReactNative.API (REGISTER, registerComponent)
import ReactNative.Components.Text (text)
import ReactNative.Components.View (view)
import ReactNative.PropTypes (center)
import ReactNative.PropTypes.Color (rgbi, white)
import ReactNative.Styles (Styles, backgroundColor, flex, margin, marginBottom, staticStyles)
import ReactNative.Styles.Flex (alignItems, justifyContent)
import ReactNative.Styles.Text (color, fontSize, textAlign)
app :: ReactClass Unit
app = createClass $ spec unit render
where
render ctx =
pure $ view styles.container [
text styles.welcome "Welcome to PureScript React Native!"
, text styles.instructions "To get started, edit index.ios.js"
, text styles.instructions "Press Cmd+R to reload, \n Cmd+D or shake for dev menu"
]
styles :: {
container :: Styles
, welcome :: Styles
, instructions :: Styles
}
styles = {
container: staticStyles [
flex 1
, justifyContent center
, alignItems center
, backgroundColor white
]
, welcome: staticStyles [
fontSize 20
, textAlign center
, margin 10
]
, instructions: staticStyles [
textAlign center
, color $ rgbi 0x333333
, marginBottom 5
]
}
main :: forall eff. Eff ( register :: REGISTER | eff) Unit
main = registerComponent "AwesomePureScriptProject" app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment