Skip to content

Commit 0eca710

Browse files
committed
Add permissions & imagepicker & loadingscreen
1 parent a4b3fa3 commit 0eca710

File tree

8 files changed

+98
-15
lines changed

8 files changed

+98
-15
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@
7070
17. Image from
7171

7272
- https://dribbble.com/search/red%20gif
73+
74+
18. Permissions
75+
76+
- https://github.com/react-native-community/react-native-permissions
77+
78+
19. Image Picker
79+
80+
- https://github.com/react-native-community/react-native-image-picker

ios/Podfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ target 'chnirtnavigation5' do
3434
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
3535
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
3636

37+
permissions_path = '../node_modules/react-native-permissions/ios'
38+
39+
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
40+
3741
target 'chnirtnavigation5Tests' do
3842
inherit! :search_paths
3943
# Pods for testing

ios/Podfile.lock

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ PODS:
1919
- DoubleConversion
2020
- glog
2121
- glog (0.3.5)
22+
- Permission-PhotoLibrary (2.0.9):
23+
- RNPermissions
2224
- RCTRequired (0.61.5)
2325
- RCTTypeSafety (0.61.5):
2426
- FBLazyVector (= 0.61.5)
@@ -182,6 +184,8 @@ PODS:
182184
- React-cxxreact (= 0.61.5)
183185
- React-jsi (= 0.61.5)
184186
- React-jsinspector (0.61.5)
187+
- react-native-image-picker (2.2.0):
188+
- React
185189
- react-native-safe-area-context (0.6.2):
186190
- React
187191
- React-RCTActionSheet (0.61.5):
@@ -225,6 +229,8 @@ PODS:
225229
- React
226230
- RNGestureHandler (1.5.3):
227231
- React
232+
- RNPermissions (2.0.9):
233+
- React
228234
- RNReanimated (1.4.0):
229235
- React
230236
- RNScreens (2.0.0-alpha.23):
@@ -239,6 +245,7 @@ DEPENDENCIES:
239245
- FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
240246
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
241247
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
248+
- Permission-PhotoLibrary (from `../node_modules/react-native-permissions/ios/PhotoLibrary.podspec`)
242249
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
243250
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
244251
- React (from `../node_modules/react-native/`)
@@ -250,6 +257,7 @@ DEPENDENCIES:
250257
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
251258
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
252259
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
260+
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
253261
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
254262
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
255263
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
@@ -265,6 +273,7 @@ DEPENDENCIES:
265273
- "RNCAsyncStorage (from `../node_modules/@react-native-community/async-storage`)"
266274
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
267275
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
276+
- RNPermissions (from `../node_modules/react-native-permissions`)
268277
- RNReanimated (from `../node_modules/react-native-reanimated`)
269278
- RNScreens (from `../node_modules/react-native-screens`)
270279
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
@@ -285,6 +294,8 @@ EXTERNAL SOURCES:
285294
:podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec"
286295
glog:
287296
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
297+
Permission-PhotoLibrary:
298+
:path: "../node_modules/react-native-permissions/ios/PhotoLibrary.podspec"
288299
RCTRequired:
289300
:path: "../node_modules/react-native/Libraries/RCTRequired"
290301
RCTTypeSafety:
@@ -303,6 +314,8 @@ EXTERNAL SOURCES:
303314
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
304315
React-jsinspector:
305316
:path: "../node_modules/react-native/ReactCommon/jsinspector"
317+
react-native-image-picker:
318+
:path: "../node_modules/react-native-image-picker"
306319
react-native-safe-area-context:
307320
:path: "../node_modules/react-native-safe-area-context"
308321
React-RCTActionSheet:
@@ -331,6 +344,8 @@ EXTERNAL SOURCES:
331344
:path: "../node_modules/@react-native-community/masked-view"
332345
RNGestureHandler:
333346
:path: "../node_modules/react-native-gesture-handler"
347+
RNPermissions:
348+
:path: "../node_modules/react-native-permissions"
334349
RNReanimated:
335350
:path: "../node_modules/react-native-reanimated"
336351
RNScreens:
@@ -347,6 +362,7 @@ SPEC CHECKSUMS:
347362
FBReactNativeSpec: 118d0d177724c2d67f08a59136eb29ef5943ec75
348363
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
349364
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
365+
Permission-PhotoLibrary: 42d41b53adefcfa94f42fb628f143d97136120bd
350366
RCTRequired: b153add4da6e7dbc44aebf93f3cf4fcae392ddf1
351367
RCTTypeSafety: 9aa1b91d7f9310fc6eadc3cf95126ffe818af320
352368
React: b6a59ef847b2b40bb6e0180a97d0ca716969ac78
@@ -356,6 +372,7 @@ SPEC CHECKSUMS:
356372
React-jsi: cb2cd74d7ccf4cffb071a46833613edc79cdf8f7
357373
React-jsiexecutor: d5525f9ed5f782fdbacb64b9b01a43a9323d2386
358374
React-jsinspector: fa0ecc501688c3c4c34f28834a76302233e29dc0
375+
react-native-image-picker: 5f9eabde109955b2faf6ef5d5114a49a8ff45ded
359376
react-native-safe-area-context: 25260c5d0b9c53fd7aa88e569e2edae72af1f6a3
360377
React-RCTActionSheet: 600b4d10e3aea0913b5a92256d2719c0cdd26d76
361378
React-RCTAnimation: 791a87558389c80908ed06cc5dfc5e7920dfa360
@@ -370,11 +387,12 @@ SPEC CHECKSUMS:
370387
RNCAsyncStorage: 44395cb9c7c1523104c2b499eb426ef7aff82bca
371388
RNCMaskedView: a88953beefbd347a29072d9eba90e42945fe291e
372389
RNGestureHandler: 02905abe54e1f6e59c081a10b4bd689721e17aa6
390+
RNPermissions: 2f74237e97b08beda01e914301e12524ddddf5b8
373391
RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c
374392
RNScreens: 55c735f525774e894be67848c250c95a9c3194c0
375393
RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4
376394
Yoga: f2a7cd4280bfe2cca5a7aed98ba0eb3d1310f18b
377395

378-
PODFILE CHECKSUM: 89eab00f14ecbc2fe6c3883932117ffc6cc8a088
396+
PODFILE CHECKSUM: 8eddafaa2ad7f01d5c0f27e859fd96fd9963bd73
379397

380398
COCOAPODS: 1.8.4

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"react-native": "0.61.5",
3333
"react-native-app-intro-slider": "^3.0.0",
3434
"react-native-gesture-handler": "^1.5.3",
35+
"react-native-image-picker": "^2.2.0",
36+
"react-native-permissions": "^2.0.9",
3537
"react-native-reanimated": "^1.4.0",
3638
"react-native-safe-area-context": "^0.6.2",
3739
"react-native-screens": "^2.0.0-alpha.23",

src/navigation/ContentDrawer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {useContext} from 'react';
22
import Animated from 'react-native-reanimated';
33
import {Text, Image, TouchableOpacity} from 'react-native';
44
import {useNavigation} from '@react-navigation/native';
5-
import SafeAreaView from 'react-native-safe-area-view';
5+
// import SafeAreaView from 'react-native-safe-area-view';
66
import * as firebase from 'firebase';
77

88
import {CTX} from '../tools/context';

src/screens/Post.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,45 @@ import {
1010
import {useNavigation} from '@react-navigation/native';
1111
import SafeAreaView from 'react-native-safe-area-view';
1212
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
13+
import ImagePicker from 'react-native-image-picker';
14+
15+
// More info on all the options is below in the API Reference... just some common use cases shown here
16+
const options = {
17+
title: 'Select Avatar',
18+
customButtons: [{name: 'fb', title: 'Choose Photo from Facebook'}],
19+
storageOptions: {
20+
skipBackup: true,
21+
path: 'images',
22+
},
23+
};
1324

1425
export default function PostScreen(props) {
1526
const navigation = useNavigation();
1627
const {navigate} = navigation;
1728

1829
const [text, setText] = useState('');
19-
const [image, setImage] = useState('xxxx');
30+
const [image, setImage] = useState(null);
31+
32+
function _openLibrary() {
33+
ImagePicker.launchImageLibrary(options, response => {
34+
// console.log('Response = ', response);
35+
// Same code as in above section!
36+
if (response.didCancel) {
37+
console.log('User cancelled image picker');
38+
} else if (response.error) {
39+
console.log('ImagePicker Error: ', response.error);
40+
} else if (response.customButton) {
41+
console.log('User tapped custom button: ', response.customButton);
42+
} else {
43+
const source = {uri: response.uri};
44+
45+
// You can also display the image using data:
46+
// const source = { uri: 'data:image/jpeg;base64,' + response.data };
47+
48+
setImage(source);
49+
}
50+
});
51+
}
2052

2153
function pickImage() {}
2254

@@ -47,14 +79,12 @@ export default function PostScreen(props) {
4779
value={text}></TextInput>
4880
</View>
4981

50-
<TouchableOpacity style={styles.photo} onPress={pickImage}>
82+
<TouchableOpacity style={styles.photo} onPress={_openLibrary}>
5183
<FontAwesome5 name="camera" size={32} color="#D8D9DB"></FontAwesome5>
5284
</TouchableOpacity>
5385

5486
<View style={{marginHorizontal: 32, marginTop: 32, height: 150}}>
55-
{/* <Image
56-
source={{uri: image}}
57-
style={{width: '100%', height: '100%'}}></Image> */}
87+
<Image source={image} style={{width: '100%', height: '100%'}}></Image>
5888
</View>
5989
</SafeAreaView>
6090
);

src/screens/Profile.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
import React, {Component} from 'react';
2-
import {Text, StyleSheet, View} from 'react-native';
2+
import {Text, StyleSheet, View, TouchableOpacity} from 'react-native';
3+
import * as firebase from 'firebase';
4+
import {useNavigation} from '@react-navigation/native';
35

4-
export default class BirthdayScreen extends Component {
5-
render() {
6-
return (
7-
<View style={styles.container}>
8-
<Text> Profile </Text>
9-
</View>
10-
);
6+
export default function ProfileScreen() {
7+
const navigation = useNavigation();
8+
const {navigate} = navigation;
9+
10+
function _onLogout() {
11+
firebase.auth().signOut();
12+
// _logout();
1113
}
14+
15+
return (
16+
<View style={styles.container}>
17+
<Text> Profile </Text>
18+
<TouchableOpacity onPress={_onLogout}>
19+
<Text>Log out</Text>
20+
</TouchableOpacity>
21+
</View>
22+
);
1223
}
1324

1425
const styles = StyleSheet.create({

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6052,11 +6052,21 @@ react-native-gesture-handler@^1.5.3:
60526052
invariant "^2.2.4"
60536053
prop-types "^15.7.2"
60546054

6055+
react-native-image-picker@^2.2.0:
6056+
version "2.2.0"
6057+
resolved "https://registry.yarnpkg.com/react-native-image-picker/-/react-native-image-picker-2.2.0.tgz#12b5a29f5f21f4f7868e2a1e551b5528733f2d3e"
6058+
integrity sha512-G0wNa92J6ADLrAraLfhl+AoaLDP0FE4YpYlSh6sguLTCTUzNDi0xfpEvpxxZgZ6Wl0anuRrCkcWm7LmJNLHI2Q==
6059+
60556060
react-native-iphone-x-helper@^1.2.1:
60566061
version "1.2.1"
60576062
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.2.1.tgz#645e2ffbbb49e80844bb4cbbe34a126fda1e6772"
60586063
integrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ==
60596064

6065+
react-native-permissions@^2.0.9:
6066+
version "2.0.9"
6067+
resolved "https://registry.yarnpkg.com/react-native-permissions/-/react-native-permissions-2.0.9.tgz#5eabdaa952dd099d14e3790af691f49ff2de0895"
6068+
integrity sha512-64F95x4Y1RqsQiPco+Qs+OAm3rKUTRfWDMpp1f0If9YfRXOxxVFJqf7mSlVvlSY4pZAhZgLVydOmA7aTTduPUw==
6069+
60606070
react-native-reanimated@^1.4.0:
60616071
version "1.4.0"
60626072
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.4.0.tgz#7f1acbf9be08492d834f512700570978052be2f9"

0 commit comments

Comments
 (0)