index.ios.js 2.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
const React = require("react-native");
const {
  AppRegistry,
  Text,
  View,
} = React;

const Blur = require("./Blur");
const Add = require("./Add");
const Multiply = require("./Multiply");
const Layer = require("./Layer");
const HelloGL = require("./HelloGL");
const Display2 = require("./Display2");
const { width: viewportW, height: viewportH } = require("Dimensions").get("window");

16 17 18 19 20 21 22 23 24 25 26 27 28 29
class Tests extends React.Component {

  constructor (props) {
    super(props);
    this.onLoad = this.onLoad.bind(this);
    this.onProgress = this.onProgress.bind(this);
  }
  onLoad () {
    console.log("LOADED");
  }
  onProgress ({nativeEvent: { progress, loaded, total }}) {
    console.log("PROGRESS", progress, loaded, total);
  }
  render () {
30 31 32 33
    const helloGL =
      <HelloGL width={64} height={64} />;

    const txt =
Gaëtan Renaudeau's avatar
Gaëtan Renaudeau committed
34
      <View style={{ width: 800, height: 800, position: "relative", backgroundColor: "transparent" }}>
35 36 37 38 39 40 41 42 43 44 45 46 47 48
        {[0,1,2,3].map(i => <Text style={{
          position: "absolute",
          top: 40+200*i,
          left: 0,
          width: 800,
          height: 200,
          textAlign: "center",
          color: ["#f00", "#0f0", "#00f", "#fff"][i],
          fontSize: 80
        }}>
          Hello World {i}
        </Text>)}
      </View>;

49
    const img = "http://i.imgur.com/zJIxPEo.jpg?t="+Date.now();
50 51 52 53 54 55 56 57 58 59 60 61 62

    const blurredImage =
      <Blur factor={4} passes={6} width={200} height={200}>
        {img}
      </Blur>;

    const blurredImageOverText =
      <Layer>
        {blurredImage}
        {txt}
      </Layer>;

    return <View style={{ backgroundColor: "#000" }}>
63
      <Display2 width={viewportW} height={viewportH} vertical preload onLoad={this.onLoad} onProgress={this.onProgress}>
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
        <Display2 width={viewportW} height={viewportH/2}>
          <Add width={viewportW/2} height={viewportH/2}>
            {txt}
            {helloGL}
          </Add>
          <Display2 width={viewportW/2} height={viewportH/2} vertical>
            <Blur factor={1} passes={4} width={viewportW/2} height={viewportH/4}>
              <Multiply>
                {blurredImageOverText}
                {helloGL}
              </Multiply>
            </Blur>
            {blurredImage}
          </Display2>
        </Display2>
        {txt}
      </Display2>
    </View>;
  }
83
}
84 85

AppRegistry.registerComponent("Tests", () => Tests);