@@ -90,7 +90,7 @@ class LoginTab extends Component {
90
90
/>
91
91
}
92
92
buttonStyle = { { backgroundColor : '#512da8' } }
93
- containerStyle = { { margin : 40 } }
93
+ containerStyle = { { margin : 5 } }
94
94
/>
95
95
96
96
< Button
@@ -106,7 +106,7 @@ class LoginTab extends Component {
106
106
/>
107
107
}
108
108
titleStyle = { { color : 'blue' , fontSize : 20 } }
109
- containerStyle = { { margin : 40 } }
109
+ containerStyle = { { margin : 5 } }
110
110
/>
111
111
112
112
</ View >
@@ -154,19 +154,33 @@ class RegisterTab extends Component {
154
154
}
155
155
156
156
processImage = async ( imageUri ) => {
157
- let processedImage = await ImageManipulator . manipulate (
157
+ let processedImage = await ImageManipulator . manipulateAsync (
158
158
imageUri ,
159
159
[
160
160
{ resize : { width : 400 } }
161
161
] ,
162
162
{ format : 'png' }
163
163
) ;
164
164
console . log ( processedImage ) ;
165
- this . setState ( { imageUrl : processedImage . uri } ) ;
165
+ this . setState ( { imageUrl : processedImage . uri } ) ;
166
166
167
167
}
168
168
169
-
169
+ getImageFromGallery = async ( ) => {
170
+ const cameraPermission = await Permissions . askAsync ( Permissions . CAMERA ) ;
171
+ const cameraRollPermission = await Permissions . askAsync ( Permissions . CAMERA_ROLL ) ;
172
+
173
+ if ( cameraPermission . status === 'granted' && cameraRollPermission . status === 'granted' ) {
174
+ let capturedImage = await ImagePicker . launchImageLibraryAsync ( {
175
+ allowsEditing : true ,
176
+ aspect : [ 4 , 3 ] ,
177
+ } ) ;
178
+ if ( ! capturedImage . cancelled ) {
179
+ console . log ( capturedImage ) ;
180
+ this . processImage ( capturedImage . uri ) ;
181
+ }
182
+ }
183
+ }
170
184
171
185
handleRegister = ( ) => {
172
186
console . log ( JSON . stringify ( this . state ) )
@@ -189,7 +203,12 @@ class RegisterTab extends Component {
189
203
title = 'Camera'
190
204
onPress = { this . getImageFromCamera }
191
205
containerStyle = { { paddingTop : 10 } }
192
- />
206
+ />
207
+ < Button
208
+ title = 'Gallery'
209
+ onPress = { this . getImageFromGallery }
210
+ containerStyle = { { paddingTop : 10 } }
211
+ />
193
212
</ View >
194
213
195
214
< Input
@@ -251,7 +270,7 @@ class RegisterTab extends Component {
251
270
/>
252
271
}
253
272
buttonStyle = { { backgroundColor : '#512da8' } }
254
- containerStyle = { { margin : 40 } }
273
+ containerStyle = { { margin : 5 } }
255
274
/>
256
275
257
276
</ View >
@@ -309,23 +328,23 @@ function Login() {
309
328
const styles = StyleSheet . create ( {
310
329
container : {
311
330
justifyContent : 'center' ,
312
- margin : 20
331
+ margin : 5
313
332
} ,
314
333
imageContainer : {
315
334
flex : 1 ,
316
335
flexDirection : 'row' ,
317
- margin : 20 ,
336
+ margin : 5 ,
318
337
justifyContent : 'center'
319
338
} ,
320
339
image : {
321
340
width : 80 ,
322
341
height : 60
323
342
} ,
324
343
formInput : {
325
- margin : 20
344
+ margin : 5
326
345
} ,
327
346
formCheck : {
328
- margin : 20 ,
347
+ margin : 5 ,
329
348
backgroundColor : null
330
349
}
331
350
} )
0 commit comments