-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task 8 #32
Open
bmind12
wants to merge
9
commits into
romabelka:master
Choose a base branch
from
bmind12:Task-8
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Task 8 #32
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
db93acb
set up firebase connection
bmind12 3af9e53
implement camera
bmind12 7a92133
HT8.1 implement camera
bmind12 2e8a8e9
add tsconfig to ignore mobx decorators warnings
bmind12 52f707e
add storage to firebase config
bmind12 8530518
add base64-arraybuffer package
bmind12 6496562
add additional parameter to custom navigate function
bmind12 c21a5b1
HT 8.2
bmind12 d4984af
implement goBack after avatar update
bmind12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react' | ||
import { Text, View, TouchableOpacity, StyleSheet } from 'react-native' | ||
import { Camera, Permissions } from 'expo' | ||
import {inject} from 'mobx-react' | ||
|
||
@inject('people') | ||
export default class CameraExample extends React.Component { | ||
state = { | ||
hasCameraPermission: null, | ||
type: Camera.Constants.Type.back, | ||
} | ||
|
||
async componentWillMount() { | ||
const { status } = await Permissions.askAsync(Permissions.CAMERA) | ||
this.setState({ hasCameraPermission: status === 'granted' }) | ||
} | ||
|
||
flipCamera = () => { | ||
this.setState({ | ||
type: this.state.type === Camera.Constants.Type.back | ||
? Camera.Constants.Type.front | ||
: Camera.Constants.Type.back, | ||
}) | ||
} | ||
|
||
takePicture = async () => { | ||
if (this.camera) { | ||
let photo = await this.camera.takePictureAsync({base64: true}) | ||
await this.props.people.updateAvatar(photo.base64, this.props.uid) | ||
|
||
this.props.goBack() | ||
} | ||
} | ||
|
||
render() { | ||
const { hasCameraPermission } = this.state | ||
|
||
if (hasCameraPermission === null) { | ||
return <View /> | ||
} else if (hasCameraPermission === false) { | ||
return <Text>No access to camera</Text> | ||
} else { | ||
return ( | ||
<View style={{ flex: 1 }}> | ||
<Camera style={styles.camera} type={this.state.type} ref={ref => { this.camera = ref }}> | ||
<View style={styles.textContainer}> | ||
<TouchableOpacity style={styles.flip} onPress={this.flipCamera}> | ||
<Text style={styles.flipText}> | ||
{' '}Flip{' '} | ||
</Text> | ||
</TouchableOpacity> | ||
<TouchableOpacity style={styles.button} onPress={this.takePicture} /> | ||
</View> | ||
</Camera> | ||
</View> | ||
) | ||
} | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
textContainer: { | ||
backgroundColor: 'rgba(255, 255, 255, 0.3)', | ||
flexDirection: 'row', | ||
height: 100, | ||
width: '100%', | ||
justifyContent: 'space-around', | ||
alignItems: 'center' | ||
}, | ||
flip: { | ||
flex: 0.1, | ||
alignItems: 'center' | ||
}, | ||
flipText: { | ||
fontSize: 18, | ||
marginBottom: 10, | ||
color: 'white' | ||
}, | ||
button: { | ||
height: 60, | ||
width: 60, | ||
borderRadius: 100, | ||
backgroundColor: 'red' | ||
}, | ||
camera: { | ||
flex: 1, | ||
alignItems: 'flex-end', | ||
justifyContent: 'flex-end' | ||
} | ||
}) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { Component } from 'react' | ||
import Camera from '../common/camera' | ||
|
||
class AuthScreen extends Component { | ||
static navigationOptions = { | ||
title: 'camera' | ||
} | ||
|
||
render() { | ||
return ( | ||
<Camera uid={this.props.navigation.state.params.uid} goBack={this.props.navigation.goBack} /> | ||
) | ||
} | ||
} | ||
|
||
export default AuthScreen |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { initializeApp } from 'firebase/app' | ||
import 'firebase/auth' | ||
import 'firebase/database' | ||
import 'firebase/storage' | ||
|
||
export const appName = 'adv-react-25-06' | ||
export const appName = 'advreact-25-06-c6bae' | ||
|
||
const config = { | ||
apiKey: 'AIzaSyDzqwnZ_39QyqhxYZVPjVH8eBww7DUBmVc', | ||
apiKey: "AIzaSyBM5eZETRfWWS9BoQ-8guawlYzeW7dDToE", | ||
authDomain: `${appName}.firebaseapp.com`, | ||
databaseURL: `https://${appName}.firebaseio.com`, | ||
projectId: appName, | ||
storageBucket: '', | ||
messagingSenderId: '874599443389' | ||
storageBucket: `gs://${appName}.appspot.com`, | ||
messagingSenderId: '985221034928' | ||
} | ||
|
||
initializeApp(config) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"experimentalDecorators": true, | ||
"allowJs": true | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Странно, похоже на вполне рабочий код, может что-то в апи поменяли. Но в остальном все ок