import React, {
StyleSheet,
Text,
View,
Image,
TextInput,
Component,
TouchableOpacity,
} from "react-native";
import { Surface } from "gl-react-native";
const {
mdl: {
Progress,
Slider,
Switch
},
MKButton,
} = require("react-native-material-kit");
import RNFS from "react-native-fs";
import HelloGL from "./HelloGL";
import Saturation from "./Saturation";
import HueRotate from "./HueRotate";
import PieProgress from "./PieProgress";
import OneFingerResponse from "./OneFingerResponse";
import AnimatedHelloGL from "./AnimatedHelloGL";
import {Blur} from "gl-react-blur";
import Button from "./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,
captureConfig: 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 () {
const captureConfig = {
quality: Math.round((Math.random() * 100))/100,
type: Math.random() < 0.5 ? "jpg": "png",
format: Math.random() < 0.5 ? "base64" : "file"
};
if (captureConfig.format === "file") {
captureConfig.filePath = RNFS.DocumentDirectoryPath+"/hellogl_capture.png";
}
this.refs.helloGL
.captureFrame(captureConfig)
.then(captured => this.setState({ captured, captureConfig }));
}
render () {
const {
current,
saturationFactor,
hue,
text,
progress,
factor,
switch1,
switch2,
switch3,
captured,
captureConfig
} = this.state;
return
this.setState({ current })} value={current}>
{captured &&
}
{captureConfig &&
format={captureConfig.format}
type={captureConfig.type}
quality={captureConfig.quality+""}
}
{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",
paddingTop: 50,
},
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;