This file contains hidden or 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
uploadPicture = () => { | |
return fetch(SERVER_URL, { | |
body: JSON.stringify({ | |
image: this.state.photo.base64 | |
}), | |
headers: { | |
'content-type': 'application/json' | |
}, | |
method: 'POST' | |
}) |
This file contains hidden or 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
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
// If your phone has a modern camera (unlike my iPhone 4S) | |
// you might wanna make this bigger. | |
app.use(bodyParser.json({ limit: '10mb' })); | |
// TODO: handle requests |
This file contains hidden or 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
// View latest image | |
app.get('/', (req, res) => { | |
// Does this session have an image yet? | |
if(!latestPhoto) { | |
return res.status(404).send("Nothing here yet"); | |
} | |
console.log('sending photo'); | |
try { |
This file contains hidden or 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
takePicture = () => { | |
this.camera.takePictureAsync({ | |
quality: 0.1, | |
base64: true, | |
exif: false | |
}).then(photo => { | |
this.setState({ photo }); | |
// In 27 seconds, turn the camera back on | |
setTimeout(() => { |
This file contains hidden or 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
class Autoshoot extends React.Component { | |
state = { | |
photo: null | |
} | |
... | |
} |
This file contains hidden or 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
class Autoshoot extends React.Component { | |
render() { | |
return ( | |
<View style={{ flex: 1, width: '100%' }}> | |
<Camera | |
style={{ flex: 1 }} | |
type={Camera.Constants.Type.back} | |
ref={cam => this.camera = cam}> | |
</Camera> | |
</View> |
This file contains hidden or 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
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text>Open up App.js to start working on your app!</Text> | |
</View> | |
); |
This file contains hidden or 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
takePicture = () => { | |
this.camera.takePictureAsync({ | |
quality: 0.1, | |
base64: true, | |
exif: false | |
}).then(photo => { | |
this.setState({ photo }); | |
}) | |
} |
This file contains hidden or 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
// Here's the timer code, lifted from takePicture: | |
queuePhoto = () => { | |
// In 27 seconds, turn the camera back on | |
setTimeout(() => { | |
this.setState({ photo: null }); | |
}, PHOTO_INTERVAL - FOCUS_TIME); | |
// In 30 seconds, take the next picture | |
setTimeout(this.takePicture, PHOTO_INTERVAL); | |
} |
This file contains hidden or 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
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
// add this: | |
import { Camera, Permissions } from 'expo'; | |
export default class App extends React.Component { | |
// initialize state | |
state = { | |
cameraPermission: null |