@hotta/react-native-imagepicker 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  package com.htreactnative.imagepicker
2
2
 
3
3
  import android.graphics.BitmapFactory
4
+ import android.graphics.Color
4
5
  import com.facebook.react.bridge.Promise
5
6
  import com.facebook.react.bridge.ReactApplicationContext
6
7
  import com.facebook.react.bridge.ReadableMap
@@ -10,8 +11,13 @@ import com.facebook.react.bridge.WritableNativeMap
10
11
  import com.facebook.react.module.annotations.ReactModule
11
12
  import com.luck.picture.lib.basic.PictureSelector
12
13
  import com.luck.picture.lib.config.SelectMimeType
14
+ import com.luck.picture.lib.config.SelectModeConfig
13
15
  import com.luck.picture.lib.entity.LocalMedia
14
16
  import com.luck.picture.lib.interfaces.OnResultCallbackListener
17
+ import com.luck.picture.lib.style.BottomNavBarStyle
18
+ import com.luck.picture.lib.style.PictureSelectorStyle
19
+ import com.luck.picture.lib.style.SelectMainStyle
20
+ import com.luck.picture.lib.style.TitleBarStyle
15
21
  import com.luck.picture.lib.utils.SdkVersionUtils
16
22
  import java.io.File
17
23
  import java.util.ArrayList
@@ -44,7 +50,7 @@ class NativeImagePickerModule(reactContext: ReactApplicationContext) :
44
50
  }
45
51
 
46
52
  override fun onCancel() {
47
-
53
+ promise?.reject("", "取消")
48
54
  }
49
55
 
50
56
  })
@@ -56,9 +62,13 @@ class NativeImagePickerModule(reactContext: ReactApplicationContext) :
56
62
  ) {
57
63
  pickerOptions = options;
58
64
  val videoCount = options?.getInt("videoCount") ?: 1
65
+ val isCamera = options?.getBoolean("isCamera") ?: false
59
66
  PictureSelector.create(reactApplicationContext.currentActivity)
60
67
  .openGallery(SelectMimeType.ofVideo())
61
- .setMaxSelectNum(videoCount)
68
+ .setSelectionMode(SelectModeConfig.SINGLE)
69
+ .setMaxSelectNum(1)
70
+ .isDisplayCamera(isCamera)
71
+ .setSelectorUIStyle(getNoCountStyle())
62
72
  .setImageEngine(imageEngine)
63
73
  .forResult(object : OnResultCallbackListener<LocalMedia> {
64
74
  override fun onResult(localMediaList: ArrayList<LocalMedia?>?) {
@@ -70,12 +80,39 @@ class NativeImagePickerModule(reactContext: ReactApplicationContext) :
70
80
  }
71
81
 
72
82
  override fun onCancel() {
73
-
83
+ promise?.reject("", "取消")
74
84
  }
75
85
 
76
86
  })
77
87
  }
78
88
 
89
+ private fun getNoCountStyle(): PictureSelectorStyle {
90
+ return PictureSelectorStyle().apply {
91
+ selectMainStyle = SelectMainStyle().apply {
92
+ // 隐藏选择后的数字/角标索引
93
+ isSelectNumberStyle = false
94
+ isPreviewSelectNumberStyle = false
95
+ // selectBackground = android.R.color.transparent
96
+ selectText = "下一步"
97
+ selectTextColor = Color.WHITE
98
+ }
99
+ bottomBarStyle = BottomNavBarStyle().apply {
100
+ isCompleteCountTips = false
101
+ bottomPreviewNormalText = "" // 未选中任何文件时的文字设为空
102
+ bottomPreviewSelectText = "" // 选中文件后的文字设为空
103
+
104
+ // (可选保障)为了防止有默认的点击态背景,你可以顺手把它的颜色也设为透明
105
+ bottomPreviewNormalTextColor = android.R.color.transparent
106
+ bottomPreviewSelectTextColor = android.R.color.transparent
107
+ }
108
+
109
+ titleBarStyle = TitleBarStyle().apply {
110
+
111
+ }
112
+
113
+ }
114
+ }
115
+
79
116
  private fun getVideoResult(media: LocalMedia): WritableMap {
80
117
  val videoMap: WritableMap = WritableNativeMap()
81
118
  var path: String = media.path
@@ -92,7 +129,7 @@ class NativeImagePickerModule(reactContext: ReactApplicationContext) :
92
129
  videoMap.putDouble("width", media.width.toDouble())
93
130
  videoMap.putDouble("height", media.height.toDouble())
94
131
  videoMap.putDouble("duration", media.duration * 1000.0)
95
- videoMap.putInt("size", media.size)
132
+ videoMap.putLong("size", media.size)
96
133
  videoMap.putString("filename", media.fileName)
97
134
  return videoMap
98
135
  }
@@ -121,19 +121,20 @@
121
121
  // 照片最大可选张数
122
122
  NSInteger imageCount = _cameraOptions->imageCount();
123
123
  // 显示内部拍照按钮
124
- BOOL isCamera = _cameraOptions->isCamera();
125
- BOOL isCrop = _cameraOptions->isCrop();
126
- BOOL isGif = _cameraOptions->isGif();
127
- BOOL showCropCircle = _cameraOptions->showCropCircle();
128
- BOOL isRecordSelected = _cameraOptions->isRecordSelected();
129
- BOOL allowPickingOriginalPhoto = _cameraOptions->allowPickingOriginalPhoto();
130
- BOOL allowPickingMultipleVideo = _cameraOptions->allowPickingMultipleVideo();
131
- BOOL sortAscendingByModificationDate = _cameraOptions->sortAscendingByModificationDate();
132
- BOOL showSelectedIndex = _cameraOptions->showSelectedIndex();
133
- NSInteger CropW = _cameraOptions->CropW();
134
- NSInteger CropH = _cameraOptions->CropH();
135
- NSInteger circleCropRadius = _cameraOptions->circleCropRadius();
136
- NSInteger quality = _cameraOptions->quality();
124
+ BOOL isCamera = [self.pickOptions sy_boolForKey:@"isCamera"];
125
+ BOOL isCrop = [self.pickOptions sy_boolForKey:@"isCrop"];
126
+ BOOL isGif = [self.pickOptions sy_boolForKey:@"isGif"];
127
+ BOOL showCropCircle = [self.pickOptions sy_boolForKey:@"showCropCircle"];
128
+ BOOL isRecordSelected = [self.pickOptions sy_boolForKey:@"isRecordSelected"];
129
+ BOOL allowPickingOriginalPhoto = [self.pickOptions sy_boolForKey:@"allowPickingOriginalPhoto"];
130
+ BOOL allowPickingMultipleVideo = [self.pickOptions sy_boolForKey:@"allowPickingMultipleVideo"];
131
+ BOOL sortAscendingByModificationDate = [self.pickOptions sy_boolForKey:@"sortAscendingByModificationDate"];
132
+ BOOL showSelectedIndex = [self.pickOptions sy_boolForKey:@"showSelectedIndex"];
133
+ NSInteger CropW = [self.pickOptions sy_integerForKey:@"CropW"];
134
+ NSInteger CropH = [self.pickOptions sy_integerForKey:@"CropH"];
135
+ NSInteger circleCropRadius = [self.pickOptions sy_integerForKey:@"circleCropRadius"];
136
+ NSInteger quality = [self.pickOptions sy_integerForKey:@"quality"];
137
+
137
138
 
138
139
  TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:imageCount delegate:self];
139
140
  imagePickerVc.iconThemeColor = [UIColor colorWithRed:255.0/255.0 green:177.0/255.0 blue:82.0/255.0 alpha:1.0];
@@ -265,12 +266,12 @@
265
266
  [tzImagePickerVc hideProgressHUD];
266
267
 
267
268
  TZAssetModel *assetModel = [[TZImageManager manager] createModelWithAsset:asset];
268
- BOOL isCrop = self->_cameraOptions->isCrop();
269
- BOOL showCropCircle = self->_cameraOptions->showCropCircle();
270
- NSInteger CropW = self->_cameraOptions->CropW();
271
- NSInteger CropH = self->_cameraOptions->CropH();
272
- NSInteger circleCropRadius = self->_cameraOptions->circleCropRadius();
273
- NSInteger quality = self->_cameraOptions->quality();
269
+ BOOL isCrop = [self.pickOptions sy_boolForKey:@"isCrop"];
270
+ BOOL showCropCircle = [self.pickOptions sy_boolForKey:@"showCropCircle"];
271
+ NSInteger CropW = [self.pickOptions sy_integerForKey:@"CropW"];
272
+ NSInteger CropH = [self.pickOptions sy_integerForKey:@"CropH"];
273
+ NSInteger circleCropRadius = [self.pickOptions sy_integerForKey:@"circleCropRadius"];
274
+ NSInteger quality = [self.pickOptions sy_integerForKey:@"quality"];
274
275
 
275
276
  if (isCrop) {
276
277
  TZImagePickerController *imagePicker = [[TZImagePickerController alloc] initCropTypeWithAsset:assetModel.asset photo:image completion:^(UIImage *cropImage, id asset) {
@@ -310,7 +311,7 @@
310
311
  }
311
312
 
312
313
  - (BOOL)isAssetCanSelect:(PHAsset *)asset {
313
- BOOL allowPickingGif = _cameraOptions->isGif();
314
+ BOOL allowPickingGif = [self.pickOptions sy_boolForKey:@"isGif"];;
314
315
  BOOL isGIF = [[TZImageManager manager] getAssetType:asset] == TZAssetModelMediaTypePhotoGif;
315
316
  if (!allowPickingGif && isGIF) {
316
317
  return NO;
@@ -368,7 +369,7 @@
368
369
  NSString *fileExtension = [filename pathExtension];
369
370
  NSMutableString *filePath = [NSMutableString string];
370
371
  BOOL isPNG = [fileExtension hasSuffix:@"PNG"] || [fileExtension hasSuffix:@"png"];
371
- BOOL compressFocusAlpha = _cameraOptions->compressFocusAlpha();
372
+ BOOL compressFocusAlpha = [self.pickOptions sy_boolForKey:@"compressFocusAlpha"];
372
373
 
373
374
  if (isPNG) {
374
375
  [filePath appendString:[NSString stringWithFormat:@"%@SyanImageCaches/%@", NSTemporaryDirectory(), filename]];
@@ -385,7 +386,7 @@
385
386
  NSInteger size = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil].fileSize;
386
387
  photo[@"size"] = @(size);
387
388
  photo[@"mediaType"] = @(phAsset.mediaType);
388
- if (_cameraOptions->enableBase64()) {
389
+ if ([self.pickOptions sy_boolForKey:@"enableBase64"]) {
389
390
  if(isPNG){
390
391
  photo[@"base64"] = [NSString stringWithFormat:@"data:image/png;base64,%@", [writeData base64EncodedStringWithOptions:0]];
391
392
  }else{
@@ -431,7 +432,7 @@
431
432
  NSInteger size = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil].fileSize;
432
433
  photo[@"size"] = @(size);
433
434
  photo[@"mediaType"] = @(phAsset.mediaType);
434
- if (_cameraOptions->enableBase64() && !isGIF) {
435
+ if ([self.pickOptions sy_boolForKey:@"enableBase64"] && !isGIF) {
435
436
  if(isPNG){
436
437
  photo[@"base64"] = [NSString stringWithFormat:@"data:image/png;base64,%@", [writeData base64EncodedStringWithOptions:0]];
437
438
  }else{
@@ -9,6 +9,13 @@ const HTNativeImagePicker = (() => {
9
9
  ...options
10
10
  };
11
11
  return NativeImagePicker.asyncShowImagePicker(_options);
12
+ },
13
+ asyncShowVideoPicker: options => {
14
+ const _options = {
15
+ ...defaultOptions,
16
+ ...options
17
+ };
18
+ return NativeImagePicker.asyncShowVideoPicker(_options);
12
19
  }
13
20
  };
14
21
  })();
@@ -1 +1 @@
1
- {"version":3,"names":["NativeImagePicker","defaultOptions","HTNativeImagePicker","asyncShowImagePicker","options","_options"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAOA,iBAAiB,IAAIC,cAAc,QAAoD,wBAAqB;AAEnH,MAAMC,mBAAmB,GAAG,CAAC,MAAM;EACjC,OAAO;IACLC,oBAAoB,EAAGC,OAA0B,IAAM;MACrD,MAAMC,QAAQ,GAAG;QAAE,GAAGJ,cAAc;QAAE,GAAGG;MAAQ,CAAC;MAClD,OAAOJ,iBAAiB,CAACG,oBAAoB,CAACE,QAAQ,CAAC;IACzD;EACF,CAAC;AACH,CAAC,EAAE,CAAC;AAEJ,eAAeH,mBAAmB","ignoreList":[]}
1
+ {"version":3,"names":["NativeImagePicker","defaultOptions","HTNativeImagePicker","asyncShowImagePicker","options","_options","asyncShowVideoPicker"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAOA,iBAAiB,IACtBC,cAAc,QAIR,wBAAqB;AAE7B,MAAMC,mBAAmB,GAAG,CAAC,MAAM;EACjC,OAAO;IACLC,oBAAoB,EAAGC,OAA0B,IAAM;MACrD,MAAMC,QAAQ,GAAG;QAAE,GAAGJ,cAAc;QAAE,GAAGG;MAAQ,CAAC;MAClD,OAAOJ,iBAAiB,CAACG,oBAAoB,CAACE,QAAQ,CAAC;IACzD,CAAC;IACDC,oBAAoB,EAAGF,OAA0B,IAAM;MACrD,MAAMC,QAAQ,GAAG;QAAE,GAAGJ,cAAc;QAAE,GAAGG;MAAQ,CAAC;MAClD,OAAOJ,iBAAiB,CAACM,oBAAoB,CAACD,QAAQ,CAAC;IACzD;EACF,CAAC;AACH,CAAC,EAAE,CAAC;AAEJ,eAAeH,mBAAmB","ignoreList":[]}
@@ -70,14 +70,14 @@ export declare const defaultOptions: {
70
70
  };
71
71
  export type VideoPickerOption = {
72
72
  videoCount: number;
73
- isCamera: boolean;
74
- MaxSecond: number;
75
- MinSecond: number;
76
- videoMaximumDuration: number;
77
- sortAscendingByModificationDate: boolean;
78
- showSelectedIndex: boolean;
73
+ isCamera?: boolean;
74
+ MaxSecond?: number;
75
+ MinSecond?: number;
76
+ videoMaximumDuration?: number;
77
+ sortAscendingByModificationDate?: boolean;
78
+ showSelectedIndex?: boolean;
79
79
  };
80
- interface SelectedVideo {
80
+ export interface SelectedVideo {
81
81
  path: string;
82
82
  size: number;
83
83
  width: number;
@@ -96,8 +96,8 @@ export declare const defaultVideoOptions: {
96
96
  showSelectedIndex: boolean;
97
97
  };
98
98
  export interface Spec extends TurboModule {
99
- asyncShowImagePicker(options: ImagePickerOption): Promise<Array<SelectedPhoto>>;
100
- asyncShowVideoPicker(options: VideoPickerOption): Promise<Array<SelectedVideo>>;
99
+ asyncShowImagePicker(options: Object): Promise<Array<SelectedPhoto>>;
100
+ asyncShowVideoPicker(options: Object): Promise<Array<SelectedVideo>>;
101
101
  }
102
102
  declare const _default: Spec;
103
103
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeImagePicker.d.ts","sourceRoot":"","sources":["../../../src/NativeImagePicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,MAAM,iBAAiB,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAC,OAAO,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,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@ -1,7 +1,8 @@
1
- import { type ImagePickerOption, type SelectedPhoto } from './NativeImagePicker';
1
+ import { type ImagePickerOption, type SelectedPhoto, type VideoPickerOption } from './NativeImagePicker';
2
2
  export type { SelectedPhoto, ImagePickerOption };
3
3
  declare const HTNativeImagePicker: {
4
4
  asyncShowImagePicker: (options: ImagePickerOption) => Promise<SelectedPhoto[]>;
5
+ asyncShowVideoPicker: (options: VideoPickerOption) => Promise<import("./NativeImagePicker").SelectedVideo[]>;
5
6
  };
6
7
  export default HTNativeImagePicker;
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAA0B,EAAkB,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpH,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;AACjD,QAAA,MAAM,mBAAmB;oCAEW,iBAAiB;CAKjD,CAAA;AAEJ,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAA0B,EAExB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,MAAM,qBAAqB,CAAC;AAC9B,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;AACjD,QAAA,MAAM,mBAAmB;oCAEW,iBAAiB;oCAIjB,iBAAiB;CAKjD,CAAA;AAEJ,eAAe,mBAAmB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotta/react-native-imagepicker",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "@hotta/react-native-imagepicker",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -74,15 +74,15 @@ export const defaultOptions = {
74
74
  };
75
75
  export type VideoPickerOption = {
76
76
  videoCount: number, // 最大选择视频数目,默认1
77
- isCamera: boolean, // 是否允许录制视频,默认true
78
- MaxSecond: number, // 选择视频最大时长,默认是180秒
79
- MinSecond: number, // 选择视频最小时长,默认是1秒
80
- videoMaximumDuration: number, // 视频最大录制时长,默认是600秒
81
- sortAscendingByModificationDate: boolean, // 按修改时间升序,默认是YES
82
- showSelectedIndex: boolean, // 是否显示序号,默认不显示
77
+ isCamera?: boolean, // 是否允许录制视频,默认true
78
+ MaxSecond?: number, // 选择视频最大时长,默认是180秒
79
+ MinSecond?: number, // 选择视频最小时长,默认是1秒
80
+ videoMaximumDuration?: number, // 视频最大录制时长,默认是600秒
81
+ sortAscendingByModificationDate?: boolean, // 按修改时间升序,默认是YES
82
+ showSelectedIndex?: boolean, // 是否显示序号,默认不显示
83
83
  }
84
84
 
85
- interface SelectedVideo {
85
+ export interface SelectedVideo {
86
86
  path: string, // 视频路径
87
87
  size: number, // 文件大小,单位为字节
88
88
  width: number, // 视频宽度
@@ -103,8 +103,8 @@ export const defaultVideoOptions = {
103
103
  }
104
104
 
105
105
  export interface Spec extends TurboModule {
106
- asyncShowImagePicker(options:ImagePickerOption): Promise<Array<SelectedPhoto>>;
107
- asyncShowVideoPicker(options:VideoPickerOption): Promise<Array<SelectedVideo>>;
106
+ asyncShowImagePicker(options:Object): Promise<Array<SelectedPhoto>>;
107
+ asyncShowVideoPicker(options:Object): Promise<Array<SelectedVideo>>;
108
108
  }
109
109
 
110
110
  export default TurboModuleRegistry.getEnforcing<Spec>('NativeImagePicker');
package/src/index.ts CHANGED
@@ -1,11 +1,20 @@
1
- import NativeImagePicker, { defaultOptions, type ImagePickerOption, type SelectedPhoto } from './NativeImagePicker';
1
+ import NativeImagePicker, {
2
+ defaultOptions,
3
+ type ImagePickerOption,
4
+ type SelectedPhoto,
5
+ type VideoPickerOption
6
+ } from './NativeImagePicker';
2
7
  export type { SelectedPhoto, ImagePickerOption };
3
8
  const HTNativeImagePicker = (() => {
4
9
  return {
5
10
  asyncShowImagePicker: (options: ImagePickerOption ) => {
6
11
  const _options = { ...defaultOptions, ...options }
7
12
  return NativeImagePicker.asyncShowImagePicker(_options)
8
- }
13
+ },
14
+ asyncShowVideoPicker: (options: VideoPickerOption ) => {
15
+ const _options = { ...defaultOptions, ...options }
16
+ return NativeImagePicker.asyncShowVideoPicker(_options)
17
+ },
9
18
  };
10
19
  })()
11
20