React-Native multi-image selection supports crop compression

react-native-syan-image-picker

Features

Multi-image selection component encapsulated based on the existing native third-party framework, suitable for React Native App.

Native framework dependency

Features

  • Support both iOS and Android
  • Support single selection, multiple selection
  • Customizable crop area size, support circular crop
  • Compression quality can be set
  • Can set whether to return image base64 encoding
  • Support recording the currently selected picture
  • Support deleting pictures with specified subscripts

Live

Install and use

installation

// Step 1 基于 npm
npm install react-native-syan-image-picker --save

// 或是 yarn
yarn add react-native-syan-image-picker

// Step 2 执行 link
react-native link react-native-syan-image-picker

Other configuration

iOS
1, add the desired native framework bundledocument:
  • TARGETS -> Build Phases -> Copy Bundle Resources Click the “+” button, click the “Add Other” button in the pop-up window, select
node_modules/react-native-syan-image-picker/ios/TZImagePickerController/TZImagePickerController.bundle
2. Add album related permissions:
  • Project Directory->Info.plist->Add
 Privacy - Camera Usage Description 是否允许此App使用你的相机进行拍照?
 Privacy - Photo Library Usage Description 请允许访问相册以选取照片
 Privacy - Photo Library Additions Usage Description 请允许访问相册以选取照片
 Privacy - Location When In Use Usage Description 我们需要通过您的地理位置信息获取您周边的相关数据
3. Chinese adaptation:
  • Add Chinese PROJECT -> Info -> Localizations Click the “+” button, select Chinese(Simplified)
Android
1, AndroidManifest.xmladding permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
2. To update to PictureSelector, you need to modify the minSdkVersion:
// app/build.gradle

android {
    minSdkVersion =  19 
    .. .
}
3. Dynamically obtain permissions before taking pictures
requestPermission  =  async  ( )  =>  { 
        try  { 
            const  granted  =  await  PermissionsAndroid . request ( 
                PermissionsAndroid . PERMISSIONS . WRITE_EXTERNAL_STORAGE , 
                { 
                    title : 'Apply for read and write mobile phone storage permissions' , 
                    message :
                         'A very awesome application wants to borrow your camera , '  + 
                        ' Then you can make cool soap tablets .' , 
                    buttonNeutral : 'Ask me again later ' , 
                    buttonNegative : 'No' , 
                    buttonPositive :'OK' , 
                } , 
            ) ; 
            if  ( granted  ===  PermissionsAndroid . RESULTS . GRANTED )  { 
                console . Log ( 'Now you have the camera permission' ) ; 
            }  else  { 
                console . Log ( 'Users didn't give it to you' ) ; 
            } 
        }  catch  ( err )  { 
            console . warn ( err ) ; 
        } 
    } ;
4. To use fast-image at the same time, you need to use the glide version

Add glideVersion to specify the same version as fast-image in build.gradle’s buildscript and ext. Add pictureVersion to customize picture_library version

Pay attention to the installation and operation error

  1. Check whether the automatic link is successful
  2. Use Android Studio to see MainApplication.javaif the file is addednew RNSyanImagePickerPackage()
  3. Use Android Studio to open the project to check whether Gradle is synchronized
  4. You can run the ImagePickerExample demo, test Android 7.0, 6.0 and take pictures and select pictures are normal

link failed to add manually

iOS

  1. In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
  2. Go to node_modules ➜ react-native-syan-image-picker and add RNSyanImagePicker.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNSyanImagePicker.a to your project’s Build Phases ➜ Link Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.reactlibrary.RNSyanImagePickerPackage; to the imports at the top of the file
  • Add new RNSyanImagePickerPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
include ':react-native-syan-image-picker'
project(':react-native-syan-image-picker').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-syan-image-picker/android')
  1. Insert the following lines inside the dependencies block in android/app/build.gradle:
  compile project(':react-native-syan-image-picker')

Run example

For related Demo, see ImagePickerExample .

Configuration parameter description

When component calls, a support incoming optionsobjects, properties that can be set as follows:

Property name Type Optional Default value Description
imageCount int Yes 6 Maximum number of selected images
isRecordSelected bool Yes false Record the currently selected picture
isCamera bool Yes true Whether to allow users to take pictures inside
isCrop bool Yes false Whether to allow cropping, imageCount is 1 to take effect
CropW int Yes screenW * 0.6 Crop width, the default screen width is 60%
CropH int Yes screenW * 0.6 Cropping height, default screen width 60%
isGif bool Yes false Whether to allow GIF selection, no callback GIF data yet
showCropCircle bool Yes false Whether to show circular cropping area
circleCropRadius float Yes screenW * 0.5 Circular cropping radius, the default screen width is half
showCropFrame bool Yes true Whether to display the cropped area
showCropGrid bool Yes false Whether to hide the crop area grid
quality int Yes 90 Compression quality (Android invalid, fixed Luban compression)
minimumCompressSize int Yes 100 Pictures smaller than 100kb are not compressed (Android)
enableBase64 bool Yes false Whether to return base64 encoding, default does not return
freeStyleCropEnabled bool Yes false Whether the crop box can be dragged (Android)
rotateEnabled bool Yes true Whether the crop can rotate the picture (Android)
scaleEnabled bool Yes true Whether the crop can zoom in or out the picture (Android)
showSelectedIndex bool Yes false Whether to display the serial number

Return result description

At Callbackthe time in the form of calls, the first parameter is returned as error object, and the second is an array of pictures:

Attribute nameTypes ofdescriptionerrorobjectIt is not null when canceling the photo, at this time error.message=='Cancel’photosarraySelected image array

And at Promisethe time in the form of calls, simply return an array of pictures, in catchthe case of cancellation chosen to deal with.

The following are the attributes contained in each image object:

Attribute nameTypes ofdescriptionwidthintPicture widthheightintPicture heighthatestringPicture pathoriginal_uristringOriginal image path, Android onlytypestringFile type, only Android, currently only returns imagesizeintPicture size, in bytes bbase64stringBase64-encoded picture, if enableBase64set false, this property does not return

Method call

Callback

Callback form to be called showImagePickermethod:

import SyanImagePicker from 'react-native-syan-image-picker';

SyanImagePicker . ShowImagePicker ( options ,  ( err ,  selectedPhotos )  =>  { 
  if  ( err )  { 
    // Deselect 
    return ; 
  } 
  // The selection is successful and the picture is rendered 
  // ... 
} )

Promise

Non-use form callback asyncShowImagePickermethod:

import SyanImagePicker from 'react-native-syan-image-picker';

// promise-then 
SYImagePicker . asyncShowImagePicker ( options ) 
  . then ( photos  =>  { 
    // Selection is successful 
  } ) 
  . catch ( err  =>  { 
    // Cancel selection, err.message is "Cancel" 
  } )

// async/await 
handleSelectPhoto  =  async  ( )  =>  { 
  try  { 
    const  photos  =  await  SYImagePicker . asyncShowImagePicker ( options ) ; 
    // selection is successful 
  }  catch  ( err )  { 
    // Cancel the selection, err.message is "Cancel" 
  } 
}

Remove selected picture

After React Native page to remove the selected images to be invoked removePhotoAtIndexmethod to delete a saved array of original pictures, make sure that the next time you enter the picture selection, selected the picture is consistent:

handleDeletePhoto  =  index  =>  { 
  const  {  selectedPhotos : oldPhotos  }  =  this . state ; 
  const  selectedPhotos  =  oldPhotos . filter ( ( photo ,  photoIndex )  =>  photoIndex !== index ) ; 
  // Update the original picture array 
  SYImagePicker . removePhotoAtIndex ( index ) ; 
  // Update the RN page 
  this . SetState ( { selectedPhotos });
}

Remove all selected pictures

STImagePicke.removeAllPhoto()

Call camera

The camera function call method also supports the two forms of Callback and Promise, and the result parameters are also consistent.

 //Callback method 
SyanImagePicker . OpenCamera ( options ,  ( err ,  photos )  =>  { 
  if  ( err )  { 
    // deselect 
    return ; 
  } 
  // the selection is successful, the picture is rendered 
  // ... 
} )

//Promise方式
 SYImagePicker.asyncOpenCamera(options)
 .then(()=>{
   ...
 })
 .catch(()=>{
   ...
 })

Select video

SyanImagePicker . OpenVideoPicker ( options ,  ( err ,  videos )  =>  { 
  if  ( err )  { 
    // Deselect 
    return ; 
  } 
  // The selection is successful and the video is processed 
  //... 
} )

options Optional configuration:

{
  MaxSecond: 60,
  MinSecond: 0,
  recordVideoSecond: 60,
  videoCount: 1
}

Return result:

type value iOS Android
uri string
fileName string
size string
duration number
width number
height number
type string
mime string
coverUri string
favorite string
mediaType string
Android return result:
{
  mime: "video/mp4",
  type: "video",
  height: 1080,
  width: 1920,
  duration: 30.22,
  size: 63876724,
  fileName: "VID_20200409_11492864.mp4",
  uri: "file:///storage/emulated/0/DCIM/Camera/VID_20200409_11492864.mp4",
  coverUri: "file:///storage/emulated/0/Android/data/package_id/cache/thumb-c3c99b6a.jpg"
}

Note: uri contains the protocol “file://”

Delete cache

SYImagePicker.deleteCache();

Version record

  • 0.4.10 Added the showSelectedIndex parameter, whether to display the selected serial number

help

Join the React-Native QQ group 397885169

Download Details:

Author: syanbo

Source Code: https://github.com/syanbo/react-native-syan-image-picker

#react-native #react #mobile-apps

What is GEEK

Buddha Community

React-Native multi-image selection supports crop compression
Autumn  Blick

Autumn Blick

1598839687

How native is React Native? | React Native vs Native App Development

If you are undertaking a mobile app development for your start-up or enterprise, you are likely wondering whether to use React Native. As a popular development framework, React Native helps you to develop near-native mobile apps. However, you are probably also wondering how close you can get to a native app by using React Native. How native is React Native?

In the article, we discuss the similarities between native mobile development and development using React Native. We also touch upon where they differ and how to bridge the gaps. Read on.

A brief introduction to React Native

Let’s briefly set the context first. We will briefly touch upon what React Native is and how it differs from earlier hybrid frameworks.

React Native is a popular JavaScript framework that Facebook has created. You can use this open-source framework to code natively rendering Android and iOS mobile apps. You can use it to develop web apps too.

Facebook has developed React Native based on React, its JavaScript library. The first release of React Native came in March 2015. At the time of writing this article, the latest stable release of React Native is 0.62.0, and it was released in March 2020.

Although relatively new, React Native has acquired a high degree of popularity. The “Stack Overflow Developer Survey 2019” report identifies it as the 8th most loved framework. Facebook, Walmart, and Bloomberg are some of the top companies that use React Native.

The popularity of React Native comes from its advantages. Some of its advantages are as follows:

  • Performance: It delivers optimal performance.
  • Cross-platform development: You can develop both Android and iOS apps with it. The reuse of code expedites development and reduces costs.
  • UI design: React Native enables you to design simple and responsive UI for your mobile app.
  • 3rd party plugins: This framework supports 3rd party plugins.
  • Developer community: A vibrant community of developers support React Native.

Why React Native is fundamentally different from earlier hybrid frameworks

Are you wondering whether React Native is just another of those hybrid frameworks like Ionic or Cordova? It’s not! React Native is fundamentally different from these earlier hybrid frameworks.

React Native is very close to native. Consider the following aspects as described on the React Native website:

  • Access to many native platforms features: The primitives of React Native render to native platform UI. This means that your React Native app will use many native platform APIs as native apps would do.
  • Near-native user experience: React Native provides several native components, and these are platform agnostic.
  • The ease of accessing native APIs: React Native uses a declarative UI paradigm. This enables React Native to interact easily with native platform APIs since React Native wraps existing native code.

Due to these factors, React Native offers many more advantages compared to those earlier hybrid frameworks. We now review them.

#android app #frontend #ios app #mobile app development #benefits of react native #is react native good for mobile app development #native vs #pros and cons of react native #react mobile development #react native development #react native experience #react native framework #react native ios vs android #react native pros and cons #react native vs android #react native vs native #react native vs native performance #react vs native #why react native #why use react native

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms?

React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. Hire Dedicated React Native Developer from top React Native development company, HourlyDeveloper.io to design a spectacular React Native application for your business.

Consult with experts:- https://bit.ly/2A8L4vz

#hire dedicated react native developer #react native development company #react native development services #react native development #react native developer #react native

Juned Ghanchi

1621573085

React Native App Developers India, React Native App Development Company

Expand your user base by using react-native apps developed by our expert team for various platforms like Android, Android TV, iOS, macOS, tvOS, the Web, Windows, and UWP.

We help businesses to scale up the process and achieve greater performance by providing the best react native app development services. Our skilled and experienced team’s apps have delivered all the expected results for our clients across the world.

To achieve growth for your business, hire react native app developers in India. You can count on us for all the technical services and support.

#react native app development company india #react native app developers india #hire react native developers india #react native app development company #react native app developers #hire react native developers

Hire Dedicated React Native Developers - WebClues Infotech

Being one of the emerging frameworks for app development the need to develop react native apps has increased over the years.

Looking for a react native developer?

Worry not! WebClues infotech offers services to Hire React Native Developers for your app development needs. We at WebClues Infotech offer a wide range of Web & Mobile App Development services based o your business or Startup requirement for Android and iOS apps.

WebClues Infotech also has a flexible method of cost calculation for hiring react native developers such as Hourly, Weekly, or Project Basis.

Want to get your app idea into reality with a react native framework?

Get in touch with us.

Hire React Native Developer Now: https://www.webcluesinfotech.com/hire-react-native-app-developer/

For inquiry: https://www.webcluesinfotech.com/contact-us/

Email: sales@webcluesinfotech.com

#hire react native developers #hire dedicated react native developers #hire react native developer #hiring a react native developer #hire freelance react native developers #hire react native developers in 1 hour

Factors affecting the cost of hiring a React Native developer in USA - TopDevelopers.co

Want to develop app using React Native? Here are the tips that will help to reduce the cost of react native app development for you.
Cost is a major factor in helping entrepreneurs take decisions about investing in developing an app and the decision to hire react native app developers in USA can prove to be fruitful in the long run. Using react native for app development ensures a wide range of benefits to your business. Understanding your business and working on the aspects to strengthen business processes through a cost-efficient mobile app will be the key to success.

#best react native development companies from the us #top react native app development companies in usa #cost of hiring a react native developer in usa #top-notch react native developer in usa #best react native developers usa #react native