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
d1ba0ba6
Unverified
Commit
d1ba0ba6
authored
Jul 13, 2019
by
少言
Committed by
GitHub
Jul 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #121 from Koppel-Zhou/master
feature: 补充遗漏的asyncOpenCamera方法
parents
1add21ce
bb8f4eca
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
2 deletions
+49
-2
README.md
README.md
+21
-1
RNSyanImagePickerModule.java
...src/main/java/com/syanpicker/RNSyanImagePickerModule.java
+8
-0
index.js
index.js
+8
-0
RNSyanImagePicker.m
ios/RNSyanImagePicker.m
+12
-1
No files found.
README.md
View file @
d1ba0ba6
...
@@ -284,7 +284,27 @@ STImagePicke.removeAllPhoto()
...
@@ -284,7 +284,27 @@ STImagePicke.removeAllPhoto()
```
```
### 调用相机
### 调用相机
相机功能调用 `openCamera` 方法,一样支持 Callback 和 Promise 两种形式,结果参数也保持一致。
相机功能调用方法,一样支持 Callback 和 Promise 两种形式,结果参数也保持一致。
```
javascript
//Callback方式
SyanImagePicker.openCamera(options, (err, photos) => {
if (err) {
// 取消选择
return;
}
// 选择成功,渲染图片
// ...
})
//Promise方式
SYImagePicker.asyncOpenCamera(options)
.then(()=>{
...
})
.catch(()=>{
...
})
```
### 删除缓存
### 删除缓存
```
javascript
```
javascript
...
...
android/src/main/java/com/syanpicker/RNSyanImagePickerModule.java
View file @
d1ba0ba6
...
@@ -84,6 +84,14 @@ public class RNSyanImagePickerModule extends ReactContextBaseJavaModule {
...
@@ -84,6 +84,14 @@ public class RNSyanImagePickerModule extends ReactContextBaseJavaModule {
this
.
openCamera
();
this
.
openCamera
();
}
}
@ReactMethod
public
void
asyncOpenCamera
(
ReadableMap
options
,
Promise
promise
)
{
this
.
cameraOptions
=
options
;
this
.
mPickerCallback
=
null
;
this
.
mPickerPromise
=
promise
;
this
.
openCamera
();
}
/**
/**
* 缓存清除
* 缓存清除
* 包括裁剪和压缩后的缓存,要在上传成功后调用,注意:需要系统sd卡权限
* 包括裁剪和压缩后的缓存,要在上传成功后调用,注意:需要系统sd卡权限
...
...
index.js
View file @
d1ba0ba6
...
@@ -104,6 +104,14 @@ export default {
...
@@ -104,6 +104,14 @@ export default {
RNSyanImagePicker
.
openCamera
(
optionObj
,
callback
)
RNSyanImagePicker
.
openCamera
(
optionObj
,
callback
)
},
},
asyncOpenCamera
(
options
)
{
const
optionObj
=
{
...
defaultOptions
,
...
options
,
};
return
RNSyanImagePicker
.
asyncOpenCamera
(
optionObj
);
},
/**
/**
* 清除缓存
* 清除缓存
*/
*/
...
...
ios/RNSyanImagePicker.m
View file @
d1ba0ba6
...
@@ -55,7 +55,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options
...
@@ -55,7 +55,7 @@ RCT_EXPORT_METHOD(showImagePicker:(NSDictionary *)options
RCT_REMAP_METHOD
(
asyncShowImagePicker
,
RCT_REMAP_METHOD
(
asyncShowImagePicker
,
options
:
(
NSDictionary
*
)
options
options
:
(
NSDictionary
*
)
options
r
esolver
:
(
RCTPromiseResolveBlock
)
resolve
showImagePickerR
esolver
:
(
RCTPromiseResolveBlock
)
resolve
rejecter
:
(
RCTPromiseRejectBlock
)
reject
)
{
rejecter
:
(
RCTPromiseRejectBlock
)
reject
)
{
self
.
cameraOptions
=
options
;
self
.
cameraOptions
=
options
;
self
.
resolveBlock
=
resolve
;
self
.
resolveBlock
=
resolve
;
...
@@ -72,6 +72,17 @@ RCT_EXPORT_METHOD(openCamera:(NSDictionary *)options callback:(RCTResponseSender
...
@@ -72,6 +72,17 @@ RCT_EXPORT_METHOD(openCamera:(NSDictionary *)options callback:(RCTResponseSender
[
self
takePhoto
];
[
self
takePhoto
];
}
}
RCT_REMAP_METHOD
(
asyncOpenCamera
,
options
:
(
NSDictionary
*
)
options
openCameraResolver
:
(
RCTPromiseResolveBlock
)
resolve
rejecter
:
(
RCTPromiseRejectBlock
)
reject
)
{
self
.
cameraOptions
=
options
;
self
.
resolveBlock
=
resolve
;
self
.
rejectBlock
=
reject
;
self
.
callback
=
nil
;
[
self
takePhoto
];
}
RCT_EXPORT_METHOD
(
deleteCache
)
{
RCT_EXPORT_METHOD
(
deleteCache
)
{
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
[
fileManager
removeItemAtPath
:
[
NSString
stringWithFormat
:
@"%@ImageCaches"
,
NSTemporaryDirectory
()]
error
:
nil
];
[
fileManager
removeItemAtPath
:
[
NSString
stringWithFormat
:
@"%@ImageCaches"
,
NSTemporaryDirectory
()]
error
:
nil
];
...
...
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