@devloops/react-native-variant
Version:
react-native material ui library
2 lines • 1.61 kB
JavaScript
import _regeneratorRuntime from"@babel/runtime/regenerator";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useState}from'react';import{CameraRoll}from'react-native';var initialState={edges:[],page_info:{end_cursor:'',has_next_page:false,start_cursor:''}};var defaultConfig={first:20,groupTypes:'All'};export default function useCameraRoll(){var _useState=useState(initialState),_useState2=_slicedToArray(_useState,2),photos=_useState2[0],setPhotos=_useState2[1];function getPhotos(){var config,_photos,_args=arguments;return _regeneratorRuntime.async(function getPhotos$(_context){while(1){switch(_context.prev=_context.next){case 0:config=_args.length>0&&_args[0]!==undefined?_args[0]:defaultConfig;_context.prev=1;_context.next=4;return _regeneratorRuntime.awrap(CameraRoll.getPhotos(config));case 4:_photos=_context.sent;setPhotos(_photos);_context.next=11;break;case 8:_context.prev=8;_context.t0=_context["catch"](1);console.log('error: ',_context.t0);case 11:case"end":return _context.stop();}}},null,null,[[1,8]]);}function saveToCameraRoll(tag,type){return _regeneratorRuntime.async(function saveToCameraRoll$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.prev=0;_context2.next=3;return _regeneratorRuntime.awrap(CameraRoll.saveToCameraRoll(tag,type));case 3:_context2.next=8;break;case 5:_context2.prev=5;_context2.t0=_context2["catch"](0);console.log('error saving to camera roll: ',_context2.t0);case 8:case"end":return _context2.stop();}}},null,null,[[0,5]]);}return[photos,getPhotos,saveToCameraRoll];}
//# sourceMappingURL=useCameraRoll.js.map