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

const HelloGL = require("./HelloGL");
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
const Saturation = require("./Saturation");
const HueRotate = require("./HueRotate");

class Simple extends React.Component {
  constructor (props) {
    super(props);
    this.state = {
      saturationFactor: 1,
      hue: 0,
      text: "and I will return leading the pack"
    };
  }

  render () {

    const {
      saturationFactor,
      hue,
      text
    } = this.state;
34 35 36 37 38 39

    return <ScrollView style={styles.container}>
      <Text style={styles.title}>
        Welcome to GL React Native!
      </Text>
      <View style={styles.demos}>
40

41 42
        <Text style={styles.demoTitle}>1. Hello GL</Text>
        <View style={styles.demo}>
43
          <HelloGL width={256} height={171} />
44 45
        </View>

46
        <Text style={styles.demoTitle}>2. Saturation on an Image</Text>
47
        <View style={styles.demo}>
48
          <Saturation
49
            width={256}
50 51 52 53 54 55 56 57 58
            height={171}
            factor={saturationFactor}
            image={{ uri: "http://i.imgur.com/iPKTONG.jpg" }}
          />
        <SliderIOS
          value={saturationFactor}
          maximumValue={8}
          onValueChange={saturationFactor => this.setState({ saturationFactor })}
        />
59
        </View>
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

        <Text style={styles.demoTitle}>3. Hue Rotation on Text + Image</Text>
        <View style={styles.demo}>
          <HueRotate
            width={256}
            height={180}
            hue={hue}>
            <Image style={{ width: 256, height: 244 }} source={{ uri: "http://i.imgur.com/qVxHrkY.jpg" }}/>
            <Text style={styles.demoText1}>Throw me to the wolves</Text>
            <Text style={styles.demoText2}>{text}</Text>
          </HueRotate>
          <SliderIOS
            value={hue}
            maximumValue={2 * Math.PI}
            onValueChange={hue => this.setState({ hue })}
          />
          <TextInput
            style={{ height: 30, borderColor: "#aaa", borderWidth: 1 }}
            onChangeText={text => this.setState({ text })}
            value={text}
          />
        </View>

83 84 85
      </View>
    </ScrollView>;
  }
86
}
87 88 89 90

const styles = StyleSheet.create({
  container: {
    flex: 1,
91
    backgroundColor: "#F9F9F9",
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
  },
  title: {
    fontSize: 20,
    textAlign: "center",
    margin: 5,
    marginBottom: 20,
    fontWeight: "bold"
  },
  demos: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
  },
  demoTitle: {
    fontSize: 20,
    margin: 5,
    fontStyle: "italic"
  },
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
  demoText1: {
    position: "absolute",
    top: 0,
    left: 0,
    width: 256,
    textAlign: "center",
    color: "#f16",
    backgroundColor: "transparent",
    fontWeight: "400",
    fontSize: 24,
    letterSpacing: 0
  },
  demoText2: {
    position: "absolute",
    bottom: 4,
    left: 0,
    width: 256,
    textAlign: "center",
    color: "#7bf",
    backgroundColor: "transparent",
    fontWeight: "300",
    fontSize: 32,
    letterSpacing: -1
  },
134 135 136
});

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