charafbou

gestion.js

Jan 15th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. POUR EN SAVOIR PLUS, CLIQUEZ SUR LE LIEN http://bit.ly/36Y5iDA
  2. https://gurl.pw/i3XI
  3. import * as React from 'react';
  4. import { Button, Image, View, Alert } from 'react-native';
  5. import * as ImagePicker from 'expo-image-picker';
  6. import Constants from 'expo-constants';
  7. import * as Permissions from 'expo-permissions';
  8. import { AntDesign, Ionicons, MaterialIcons } from '@expo/vector-icons';
  9.  
  10. import * as Print from 'expo-print';
  11.  
  12. export default class ImagePickerExample extends React.Component {
  13. state = {
  14. image: null,
  15. avatarSource: null,
  16. isUploading: false
  17. };
  18.  
  19.  
  20.  
  21. componentDidMount() {
  22. this.getPermissionAsync();
  23. console.log('Permisos Aceptados');
  24. }
  25.  
  26. getPermissionAsync = async () => {
  27. if (Constants.platform.ios) {
  28. const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
  29. if (status !== 'granted') {
  30. alert('Sorry, we need camera roll permissions to make this work!');
  31. }
  32. }
  33. }
  34.  
  35. _pickImagePDF = async () => {
  36.  
  37. let result = await ImagePicker.launchCameraAsync({
  38. mediaTypes: ImagePicker.MediaTypeOptions.All,
  39. allowsEditing: true,
  40. aspect: [4, 3],
  41. quality: 0.5,
  42. base64: true
  43. });
  44.  
  45. console.log(result);
  46.  
  47. Print.printToFileAsync({
  48. html: '<img src="data:image/jpeg;base64, '+result.base64+'" width="100%"/>',
  49. width : 612,
  50. height : 792,
  51. base64 : true
  52. });
  53.  
  54. if (!result.cancelled) {
  55. /**this.setState({ image: result.uri });
  56. this.uploadImage(result.uri);**/
  57. }
  58. }
Add Comment
Please, Sign In to add comment