require("gl-react/react-native");
const React = require("react-native");
const {
StyleSheet,
Text,
View,
Image,
TextInput,
Component,
TouchableOpacity
} = React;
const { Surface } = require("gl-react-native");
const {
mdl: {
Progress,
Slider,
Switch
},
MKButton,
} = require("react-native-material-kit");
const HelloGL = require("./HelloGL");
const Saturation = require("./Saturation");
const HueRotate = require("./HueRotate");
const PieProgress = require("./PieProgress");
const OneFingerResponse = require("./OneFingerResponse");
const AnimatedHelloGL = require("./AnimatedHelloGL");
const Blur = require("./Blur");
const Button = require("./Button");
class Demo extends Component {
render () {
const { title, children } = this.props;
return
{title}
{children}
;
}
}
class Demos extends Component {
render () {
const { children, onChange, value } = this.props;
return
{React.Children.map(children, (demo, i) =>
onChange(i)}>
{""+(i+1)}
)}
{children[value]}
;
}
}
class Simple extends Component {
constructor (props) {
super(props);
this.state = {
current: 0,
saturationFactor: 1,
hue: 0,
progress: 0,
factor: 0,
text: "and I will return leading the pack",
switch1: false,
switch2: false,
switch3: false,
captured: null
};
this.onCapture1 = this.onCapture1.bind(this);
/*
// Crazy stress mode
const self = this;
setTimeout(function loop () {
setTimeout(loop, 100 * Math.random());
self.setState({ current: Math.floor(8 * Math.random()) });
}, 100);
*/
}
onCapture1 () {
this.refs.helloGL.captureFrame().then(data64 => {
this.setState({ captured: data64 });
});
}
render () {
const {
current,
saturationFactor,
hue,
text,
progress,
factor,
switch1,
switch2,
switch3,
captured
} = this.state;
return
gl-react-native > Simple
this.setState({ current })} value={current}>
{captured && }
{captured && {captured.slice(0, 100)}}
this.setState({ saturationFactor })}
/>
Throw me to the wolves
{text}
this.setState({ hue })}
/>
this.setState({ text })}
value={text}
/>
this.setState({ progress })}
/>
http://i.imgur.com/3On9QEu.jpg
this.setState({ factor })} />
this.setState({ factor })}
/>
this.setState({ switch1 })} />
this.setState({ switch2 })} />
this.setState({ switch3 })} />
Note: This is highly experimental and not yet performant enough.
Not Supported Yet
;
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#F9F9F9",
},
title: {
fontSize: 20,
textAlign: "center",
margin: 5,
marginBottom: 20,
fontWeight: "bold"
},
nav: {
flexDirection: "row",
marginBottom: 20
},
demos: {
flex: 1,
justifyContent: "center",
marginLeft: 40,
width: 276,
marginBottom: 40,
},
demoTitle: {
marginBottom: 16,
fontStyle: "italic",
alignSelf: "flex-start",
color: "#999",
fontWeight: "300",
fontSize: 20,
},
demo: {
marginBottom: 64,
marginLeft: 20,
},
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
},
});
module.exports = Simple;