Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-syan-image-picker
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenSource
react-native-syan-image-picker
Commits
be1ff343
Commit
be1ff343
authored
Oct 21, 2017
by
Syan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.0.4
parent
17a117e4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
5 deletions
+65
-5
README.md
README.md
+61
-1
index.js
index.js
+3
-3
package.json
package.json
+1
-1
No files found.
README.md
View file @
be1ff343
...
@@ -80,6 +80,66 @@
...
@@ -80,6 +80,66 @@
```
```
import ImagePicker from 'react-native-syan-image-picker'
import ImagePicker from 'react-native-syan-image-picker'
ImagePicker.showImagePicker(options, (err, photos) => {})
/
**
*
默认参数
*
/
const options = {
imageCount: 6, // 最大选择图片数目,默认6
isCamera: true, // 是否允许用户在内部拍照,默认true
isCrop: false, // 是否允许裁剪,默认false
CropW: ~~(width
*
0.6), // 裁剪宽度,默认屏幕宽度60%
CropH: ~~(width
*
0.6), // 裁剪高度,默认屏幕宽度60%
isGif: false, // 是否允许选择GIF,默认false,暂无回调GIF数据
showCropCircle: false, // 是否显示圆形裁剪区域,默认false
showCropFrame: true, // 是否显示裁剪区域,默认true
showCropGrid: false // 是否隐藏裁剪区域网格,默认false
};
/
**
*
以Callback形式调用
*
1、相册参数暂时只支持默认参数中罗列的属性;
*
2、回调形式:showImagePicker(options, (err, selectedPhotos) => {})
*
1)选择图片成功,err为null,selectedPhotos为选中的图片数组
*
2)取消时,err返回"取消",selectedPhotos将为undefined
*
按需判断各参数值,确保调用正常,示例使用方式:
*
showImagePicker(options, (err, selectedPhotos) => {
*
if (err) {
*
// 取消选择
*
return;
*
}
*
// 选择成功
*
})
*
*
@param {Object} options 相册参数
*
@param {Function} callback 成功,或失败回调
*
/
/**
* 以Promise形式调用
* 1、相册参数暂时只支持默认参数中罗列的属性;
* 2、使用方式
* 1)async/await
* handleSelectPhoto = async () => {
* try {
* const photos = await SYImagePicker.asyncShowImagePicker(options);
* // 选择成功
* } catch (err) {
* // 取消选择,err.message为"取消"
* }
* }
* 2)promise.then形式
* handleSelectPhoto = () => {
* SYImagePicker.asyncShowImagePicker(options)
* .then(photos => {
* // 选择成功
* })
* .catch(err => {
* // 取消选择,err.message为"取消"
* })
* }
* @param {Object} options 相册参数
* @return {Promise} 返回一个Promise对象
*/
```
```
\ No newline at end of file
index.js
View file @
be1ff343
...
@@ -10,15 +10,15 @@ const { width } = Dimensions.get('window');
...
@@ -10,15 +10,15 @@ const { width } = Dimensions.get('window');
* 默认参数
* 默认参数
*/
*/
const
defaultOptions
=
{
const
defaultOptions
=
{
imageCount
:
2
,
// 最大选择图片数目,默认1
imageCount
:
6
,
// 最大选择图片数目,默认6
isCamera
:
true
,
// 是否允许用户在内部拍照,默认true
isCamera
:
true
,
// 是否允许用户在内部拍照,默认true
isCrop
:
false
,
// 是否允许裁剪,默认false
isCrop
:
false
,
// 是否允许裁剪,默认false
CropW
:
~~
(
width
*
0.6
),
// 裁剪宽度,默认屏幕宽度60%
CropW
:
~~
(
width
*
0.6
),
// 裁剪宽度,默认屏幕宽度60%
CropH
:
~~
(
width
*
0.6
),
// 裁剪高度,默认屏幕宽度60%
CropH
:
~~
(
width
*
0.6
),
// 裁剪高度,默认屏幕宽度60%
isGif
:
false
,
// 是否允许选择GIF,默认false
isGif
:
false
,
// 是否允许选择GIF,默认false
,暂无回调GIF数据
showCropCircle
:
false
,
// 是否显示圆形裁剪区域,默认false
showCropCircle
:
false
,
// 是否显示圆形裁剪区域,默认false
showCropFrame
:
true
,
// 是否显示裁剪区域,默认true
showCropFrame
:
true
,
// 是否显示裁剪区域,默认true
showCropGrid
:
false
,
// 是否隐藏裁剪区域网格,默认false
showCropGrid
:
false
// 是否隐藏裁剪区域网格,默认false
};
};
export
default
{
export
default
{
...
...
package.json
View file @
be1ff343
{
{
"name"
:
"react-native-syan-image-picker"
,
"name"
:
"react-native-syan-image-picker"
,
"version"
:
"0.0.
3
"
,
"version"
:
"0.0.
4
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"index.js"
,
"main"
:
"index.js"
,
"scripts"
:
{
"scripts"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment