@react-native-oh-tpl/react-native-syan-image-picker
Advanced tools
Comparing version 0.5.3-0.0.2 to 0.5.3-0.0.3
@@ -1,2 +0,1 @@ | ||
# react-native-syan-image-picker | ||
@@ -3,0 +2,0 @@ |
@@ -26,4 +26,4 @@ /** | ||
import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts'; | ||
import { TM } from "@rnoh/react-native-openharmony/generated/ts" | ||
import { ImagePickerOption, ImagePickerResponseData, SelectedPhoto } from "./model/Model" | ||
import { TM } from '@rnoh/react-native-openharmony/generated/ts'; | ||
import { ImagePickerOption, ImagePickerResponseData, SelectedPhoto } from './model/Model'; | ||
import Logger from './Logger'; | ||
@@ -36,5 +36,6 @@ import image from '@ohos.multimedia.image'; | ||
import photoAccessHelper from '@ohos.file.photoAccessHelper'; | ||
import { JSON, List } from '@kit.ArkTS'; | ||
import { JSON } from '@kit.ArkTS'; | ||
import { cameraPicker } from '@kit.CameraKit'; | ||
import { media } from '@kit.MediaKit'; | ||
import type Want from '@ohos.app.ability.Want'; | ||
@@ -62,3 +63,2 @@ export class RNSyanImagePickerTurboModule extends TurboModule implements TM.RNSyanImagePicker.Spec { | ||
const ONLY_ONE_NUMBER: number = 1; | ||
switch (imageOrVideo) { | ||
@@ -70,8 +70,9 @@ case true: | ||
optionsPassedToOHSelector.isEditSupported = options.isCrop; | ||
optionsPassedToOHSelector.isOriginalSupported=options.allowPickingOriginalPhoto; | ||
break; | ||
case false: | ||
optionsPassedToOHSelector.MIMEType = photoAccessHelper.PhotoViewMIMETypes.VIDEO_TYPE; | ||
optionsPassedToOHSelector.maxSelectNumber = | ||
options.allowPickingMultipleVideo ? options.videoCount : ONLY_ONE_NUMBER; | ||
options.allowPickingMultipleVideo ? options.videoCount : ONLY_ONE_NUMBER; | ||
optionsPassedToOHSelector.isOriginalSupported=options.allowPickingOriginalPhoto; | ||
break; | ||
@@ -417,3 +418,3 @@ default: | ||
private async pickCamera(cameraPickerModule, mContext, mediaType, pickerProfile) { | ||
public async pickCamera(cameraPickerModule, mContext, mediaType, pickerProfile) { | ||
try { | ||
@@ -439,3 +440,29 @@ const pickerResult = await cameraPickerModule.default.pick(mContext, mediaType, pickerProfile); | ||
} else { | ||
callback(null, imagePickerResponseDataToClient.selectedPhoto); | ||
if (!options.allowPickingMultipleVideo) { | ||
let bundleName=this.ctx.uiAbilityContext.abilityInfo.bundleName; | ||
try { | ||
let want: Want = { | ||
"bundleName": bundleName, | ||
"abilityName": "ImageCropAbility", | ||
} | ||
AppStorage.setOrCreate('filePath', imagePickerResponseDataToClient.selectedPhoto[0].original_uri); | ||
AppStorage.setOrCreate('CropW', options.CropW); | ||
AppStorage.setOrCreate('CropH', options.CropH); | ||
AppStorage.setOrCreate('showCropCircle', options.showCropCircle); | ||
AppStorage.setOrCreate('circleCropRadius', options.circleCropRadius); | ||
this.ctx.uiAbilityContext.startAbilityForResult(want, (error, data) => { | ||
let imagePath = AppStorage.get('cropImagePath') as string; | ||
let selectPhoto= new SelectedPhoto() | ||
selectPhoto.original_uri= imagePath | ||
selectPhoto.width=AppStorage.get('width') as number | ||
selectPhoto.height=AppStorage.get('height') as number | ||
selectPhoto.size=AppStorage.get('size') as number | ||
callback(null, [selectPhoto]); | ||
}); | ||
} catch (err) { | ||
console.info("crop image fail"+JSON.stringify(err)) | ||
} | ||
}else { | ||
callback(null, imagePickerResponseDataToClient.selectedPhoto); | ||
} | ||
} | ||
@@ -450,6 +477,7 @@ }) | ||
asyncShowImagePicker(options: ImagePickerOption): Promise<SelectedPhoto[]> { | ||
/*** Call the native image selector to obtain a set of URLs for the selected images**/ | ||
const photoPicker = new photoAccessHelper.PhotoViewPicker(); | ||
return photoPicker.select(this.buildSelectOption(options, true)) | ||
@@ -464,2 +492,3 @@ .then((result: photoAccessHelper.PhotoSelectResult) => { | ||
console.info("test image :"+JSON.stringify(imagePickerResponseDataToClient.selectedPhoto)) | ||
return imagePickerResponseDataToClient.selectedPhoto; | ||
@@ -492,3 +521,3 @@ }) | ||
let mContext = this.ctx.uiAbilityContext; | ||
let pickerProfile = { cameraPosition: cameraModule.default.CameraPosition.CAMERA_POSITION_UNSPECIFIED }; | ||
let pickerProfile = { cameraPosition: cameraModule.default.CameraPosition.CAMERA_POSITION_UNSPECIFIED,videoDuration: options.videoMaximumDuration}; | ||
return this.pickCamera(cameraPickerModule, mContext, mediaType, pickerProfile); | ||
@@ -495,0 +524,0 @@ }) |
{ | ||
"name": "@react-native-oh-tpl/react-native-syan-image-picker", | ||
"version": "0.5.3-0.0.2", | ||
"version": "0.5.3-0.0.3", | ||
"description": "React-Native 多图片选择 支持裁剪 压缩", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156043
35
832