GithubHelp home page GithubHelp logo

squalvj / react-native-gallery-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pentarex/react-native-gallery-manager

0.0 1.0 0.0 358 KB

JavaScript 9.99% Python 4.12% Java 30.53% Objective-C 54.03% Ruby 1.32%

react-native-gallery-manager's Introduction

Gallery Manager

Gallery manager for iOS and Android

Installation

npm install --save react-native-gallery-manager

or

yarn add react-native-gallery-manager

and then

react-native link

NOTE: If you are using CameraRoll from react-native, you have to unlink it before using this library

Issues

  • If the image is not being shown in Android try the following
    • increase fresco memory
    • resizeMethod='resize' to the Image component
    • removeClippedSubviews={true} to ScrollView (FlatList, SectionList)
    • android:largeHeap="true" to the android manifest.xml in the application section (I dont recommend that but, you got to do, what you got to do....)

#10569 #13600 #10470

Usage

import GalleryManager from 'react-native-gallery-manager';

Methods and Responses

Get Assets

GalleryManager.getAssets({
    type: 'all',             
    startFrom: 0,
}).then((response) => {

}).catch((err) => {
    // no rejects are defined currently on iOS
})
Props Type Default Notes
type String 'all' Type of the asset returned, can be 'image', 'video', 'all'
limit Number 10 how many asset to return in one call
startFrom Number 0 From which index to start
albumName String Set the name of the album from which you want assets (Optional)
Response
{
   assets:[
      {
         type:'image',
         uri:'file:///storage/emulated/0/Download/ylo6z7D.jpg',
         id:38,
         filename:'ylo6z7D.jpg',
         width:3456,
         height:1944,
         creationDate:'1517064428',
         duration:0,
         mimeType:'image/jpeg'
      },
      ...
   ],
   totalAssets:7,
   next:7,
   hasMore:false
}

Get Albums

GalleryManager.getAlbums().then((response) => {

}).catch((err) => {
    // no rejects are defined currently on iOS
})
Response
{ 
    albums: 
        [ 
            { 
            	assetCount: 616, title: 'WhatsApp' 
            },
            { 
            	assetCount: 6, title: 'Instagram' 
            },
            { 
            	assetCount: 1, title: 'Twitter' 
            },
            ...
        ],
    totalAlbums: 24 
}

Check Permission

GalleryManager.requestAuthorization(title, message).then((response) => {
    // response.isAuthorized = true || false
}).catch((err) => {
    
})
Props Type Default Notes
title String (Android) title of the dialog
message String (Android) message in the dialog

Convert Video (iOS only)

GalleryManager.convertVideo({
	id: '98F14DF6-3BF9-4D1B-A6E0-0A36A25AE377/L0/001',
	convertTo: 'm4v',
	quality: 'low'
}).then((response) => {
	console.log(response);
}).catch((err) => {
   console.log(err)
});
Props Type Default Notes
id String The id of the video asset
convertTo String Can be mpeg4, m4v or mov
quality String original Can be original, high, medium, low
Response
{ 
  mimeType: 'video/x-m4v',
  path: 'file:///Users/pentarex/Library/Developer/CoreSimulator/Devices/81873DB4-A220-4F60-88B8-87521BB231E6/data/Containers/Data/Application/91EE6566-4D04-4E33-9608-EDB06DA6C6D2/Documents/8DAEDFBC-9E16-442D-A98F-E145F429DA0B.m4v',
  filename: '8DAEDFBC-9E16-442D-A98F-E145F429DA0B.m4v',
  type: 'video',
  duration: 19.185833333333335 
}

The reason the library is returning the path of the file in this format is that the video can be send later to server with fetch library. If the url starts with assets-library:// not with file:// react-native will not send it.

Roadmap

Suggestions and forks are welcome

react-native-gallery-manager's People

Contributors

pentarex avatar squalvj avatar robyweb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.