-
Notifications
You must be signed in to change notification settings - Fork 9
#195 Add image from camera selection #304
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
base: master
Are you sure you want to change the base?
Changes from all commits
7c53c19
9ee81b4
8cae33e
0dde549
86cec13
e7d6d18
1fd19f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,10 +19,14 @@ | |
| }, | ||
| "dependencies": { | ||
| "@react-native-community/slider": "^2.0.8", | ||
| "@react-native-firebase/app": "^6.4.0", | ||
| "@react-native-firebase/storage": "^6.4.0", | ||
| "@types/lodash.every": "^4.6.6", | ||
| "@types/lodash.isempty": "^4.4.6", | ||
| "@types/lodash.noop": "^3.0.6", | ||
| "@types/lodash.sortby": "^4.7.6", | ||
| "@types/react-native-uuid": "^1.4.0", | ||
| "buffer": "^5.5.0", | ||
| "formik": "^1.5.7", | ||
| "i18next": "^18.0.0", | ||
| "lodash.every": "^4.6.0", | ||
|
|
@@ -40,10 +44,12 @@ | |
| "react-native-floating-action": "^1.19.1", | ||
| "react-native-gesture-handler": "^1.5.6", | ||
| "react-native-image-crop-picker": "^0.26.2", | ||
| "react-native-image-picker": "^2.3.1", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to use |
||
| "react-native-localize": "^1.3.1", | ||
| "react-native-reanimated": "^1.7.0", | ||
| "react-native-splash-screen": "^3.2.0", | ||
| "react-native-svg": "^9.13.3", | ||
| "react-native-uuid": "^1.4.9", | ||
| "react-native-vector-icons": "^6.6.0", | ||
| "react-navigation": "^3.11.0", | ||
| "yup": "^0.27.0" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import React from 'react'; | ||
| import { Image, StyleSheet, View } from 'react-native'; | ||
| import { palette } from '../../styles'; | ||
| import { StyledText } from '../StyledText'; | ||
|
|
||
| interface Props { | ||
| imageUri: string; | ||
| } | ||
|
|
||
| export class SlideImage extends React.PureComponent<Props> { | ||
| render() { | ||
| if (this.props.imageUri) { | ||
| return ( | ||
| <View style={styles.imageContainer}> | ||
| <Image resizeMode="contain" style={styles.image} source={{ uri: this.props.imageUri }} /> | ||
| </View> | ||
| ); | ||
| } | ||
| return <StyledText style={[styles.loadingText]}>Loading...</StyledText>; | ||
| } | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| imageContainer: { | ||
| flex: 1, | ||
| alignSelf: 'stretch', | ||
| marginBottom: 16, | ||
| }, | ||
| loadingText: { | ||
| fontSize: 24, | ||
| }, | ||
| image: { | ||
| flex: 1, | ||
| }, | ||
| nameTextColor: { | ||
| color: palette.textBlack, | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import uuid from 'react-native-uuid'; | ||
| import { getImagesStorage } from '../models/FirebaseRefProxy'; | ||
|
|
||
| export const uploadImage = async (imageUri: string, fileName: string | undefined): Promise<string> => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||
| const DEFAULT_EXTENSION = '.jpg'; | ||
| const fileExtension = fileName ? fileName.split('.').pop() : DEFAULT_EXTENSION; | ||
| const uploadedFileName = `${uuid.v1()}.${fileExtension}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Firebase would generate filename for us :) |
||
|
|
||
| await getImagesStorage() | ||
| .child(uploadedFileName) | ||
| .putFile(imageUri); | ||
| return uploadedFileName; | ||
| }; | ||
|
|
||
| export const loadImage = async (imageName: string): Promise<string> => { | ||
| return getImagesStorage() | ||
| .child(imageName) | ||
| .getDownloadURL(); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
We use v5 of firebase library already. We shouldn't mix it with v6
the best option would be to migrate to v6 ;) but that's a separate task