Last active
January 1, 2017 16:39
-
-
Save sectore/7d84a46da731b3d630dd64904242efb9 to your computer and use it in GitHub Desktop.
PureScript port of official React Native template `index.ios.js` (https://github.com/facebook/react-native/blob/a477aec10d29b4651944cb4292daf06dfa953ea3/local-cli/templates/HelloWorld/index.ios.js) for using `purescript-reactnative` (https://github.com/doolse/purescript-reactnative)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- 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