@hotta/react-native-imagepicker 0.1.2
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.
- package/NativeImagePicker.podspec +21 -0
- package/README.md +20 -0
- package/android/build.gradle +95 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/htreactnative/imagepicker/GlideEngine.kt +85 -0
- package/android/src/main/java/com/htreactnative/imagepicker/NativeImagePickerModule.kt +91 -0
- package/android/src/main/java/com/htreactnative/imagepicker/NativeImagePickerPackage.kt +33 -0
- package/ios/NSDictionary+SYSafeConvert.h +29 -0
- package/ios/NSDictionary+SYSafeConvert.m +92 -0
- package/ios/NativeImagePicker.h +7 -0
- package/ios/NativeImagePicker.mm +458 -0
- package/lib/module/NativeImagePicker.js +62 -0
- package/lib/module/NativeImagePicker.js.map +1 -0
- package/lib/module/index.js +10 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeImagePicker.d.ts +76 -0
- package/lib/typescript/src/NativeImagePicker.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +171 -0
- package/src/NativeImagePicker.ts +79 -0
- package/src/index.tsx +9 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "NativeImagePicker"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
14
|
+
s.source = { :git => "https://github.com/weiningtry7/ht-react-native-imagepicker.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
|
|
19
|
+
install_modules_dependencies(s)
|
|
20
|
+
s.dependency 'TZImagePickerController', '>= 3.8.9'
|
|
21
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# 基于react-native0.82版本的图片选择器(TurboModule)
|
|
2
|
+
|
|
3
|
+
This is a fork of [react-native-syan-image-picker]([GitHub - syanbo/react-native-syan-image-picker: React-Native 多图片选择 支持裁剪 压缩](https://github.com/syanbo/react-native-syan-image-picker))
|
|
4
|
+
|
|
5
|
+
### 原生框架依赖
|
|
6
|
+
|
|
7
|
+
- Android: [PictureSelector](https://github.com/LuckSiege/PictureSelector) - by [LuckSiege](https://github.com/LuckSiege)
|
|
8
|
+
|
|
9
|
+
- iOS:[TZImagePickerController](https://github.com/banchichen/TZImagePickerController) - by [banchichen](https://github.com/banchichen)
|
|
10
|
+
|
|
11
|
+
### 使用方法
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
import HTImagePicker from '@ht/react-native-image-picker/src';
|
|
15
|
+
const options: any = {
|
|
16
|
+
mediaType: 'photo',
|
|
17
|
+
sortOrder: 'asc',
|
|
18
|
+
}
|
|
19
|
+
const response = await HTImagePicker.asyncShowImagePicker(options);
|
|
20
|
+
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
def safeExtGet(prop, fallback) {
|
|
2
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
buildscript {
|
|
6
|
+
ext.getExtOrDefault = {name ->
|
|
7
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['NativeImagePicker_' + name]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
repositories {
|
|
11
|
+
google()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
dependencies {
|
|
16
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
17
|
+
// noinspection DifferentKotlinGradleVersion
|
|
18
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
apply plugin: "com.android.library"
|
|
24
|
+
apply plugin: "kotlin-android"
|
|
25
|
+
|
|
26
|
+
apply plugin: "com.facebook.react"
|
|
27
|
+
|
|
28
|
+
def getExtOrIntegerDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NativeImagePicker_" + name]).toInteger()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
android {
|
|
33
|
+
namespace "com.htreactnative.imagepicker"
|
|
34
|
+
|
|
35
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
36
|
+
|
|
37
|
+
defaultConfig {
|
|
38
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
39
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
buildFeatures {
|
|
43
|
+
buildConfig true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
buildTypes {
|
|
47
|
+
release {
|
|
48
|
+
minifyEnabled false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
lintOptions {
|
|
53
|
+
disable "GradleCompatible"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
compileOptions {
|
|
57
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
58
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
sourceSets {
|
|
62
|
+
main {
|
|
63
|
+
java.srcDirs += [
|
|
64
|
+
"generated/java",
|
|
65
|
+
"generated/jni"
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
repositories {
|
|
72
|
+
mavenCentral()
|
|
73
|
+
google()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
77
|
+
def glideVersion = safeExtGet('glideVersion', '4.16.0')
|
|
78
|
+
|
|
79
|
+
dependencies {
|
|
80
|
+
implementation "com.facebook.react:react-android"
|
|
81
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
82
|
+
implementation "com.github.bumptech.glide:glide:${glideVersion}"
|
|
83
|
+
annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}"
|
|
84
|
+
// PictureSelector basic (Necessary)
|
|
85
|
+
implementation 'io.github.lucksiege:pictureselector:v3.11.2'
|
|
86
|
+
|
|
87
|
+
// image compress library (Not necessary)
|
|
88
|
+
implementation 'io.github.lucksiege:compress:v3.11.2'
|
|
89
|
+
|
|
90
|
+
// uCrop library (Not necessary)
|
|
91
|
+
implementation 'io.github.lucksiege:ucrop:v3.11.2'
|
|
92
|
+
|
|
93
|
+
// simple camerax library (Not necessary)
|
|
94
|
+
implementation 'io.github.lucksiege:camerax:v3.11.2'
|
|
95
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package com.htreactnative.imagepicker
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.widget.ImageView
|
|
5
|
+
import com.bumptech.glide.Glide
|
|
6
|
+
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
|
7
|
+
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
|
8
|
+
import com.luck.picture.lib.engine.ImageEngine
|
|
9
|
+
import com.luck.picture.lib.utils.ActivityCompatHelper
|
|
10
|
+
|
|
11
|
+
class GlideEngine private constructor() : ImageEngine{
|
|
12
|
+
override fun loadImage(context: Context, url: String, imageView: ImageView) {
|
|
13
|
+
if (!ActivityCompatHelper.assertValidRequest(context)) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
Glide.with(context)
|
|
17
|
+
.load(url)
|
|
18
|
+
.into(imageView)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun loadImage(
|
|
22
|
+
context: Context,
|
|
23
|
+
imageView: ImageView,
|
|
24
|
+
url: String,
|
|
25
|
+
maxWidth: Int,
|
|
26
|
+
maxHeight: Int
|
|
27
|
+
) {
|
|
28
|
+
if (!ActivityCompatHelper.assertValidRequest(context)) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
Glide.with(context)
|
|
32
|
+
.load(url)
|
|
33
|
+
.override(maxWidth, maxHeight)
|
|
34
|
+
.into(imageView)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun loadAlbumCover(context: Context, url: String, imageView: ImageView) {
|
|
38
|
+
if (!ActivityCompatHelper.assertValidRequest(context)) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
Glide.with(context)
|
|
42
|
+
.asBitmap()
|
|
43
|
+
.load(url)
|
|
44
|
+
.override(180, 180)
|
|
45
|
+
.sizeMultiplier(0.5f)
|
|
46
|
+
.transform(CenterCrop(), RoundedCorners(8))
|
|
47
|
+
.into(imageView)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun loadGridImage(context: Context, url: String, imageView: ImageView) {
|
|
51
|
+
if (!ActivityCompatHelper.assertValidRequest(context)) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
Glide.with(context)
|
|
55
|
+
.load(url)
|
|
56
|
+
.override(200, 200)
|
|
57
|
+
.centerCrop()
|
|
58
|
+
.placeholder(com.luck.picture.lib.R.drawable.ps_image_placeholder)
|
|
59
|
+
.into(imageView)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override fun pauseRequests(context: Context) {
|
|
63
|
+
if (!ActivityCompatHelper.assertValidRequest(context)) {
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
Glide.with(context).pauseRequests()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
override fun resumeRequests(context: Context) {
|
|
70
|
+
if (!ActivityCompatHelper.assertValidRequest(context)) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
Glide.with(context).resumeRequests()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private object InstanceHolder {
|
|
77
|
+
val instance = GlideEngine()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
companion object {
|
|
81
|
+
fun createGlideEngine(): GlideEngine {
|
|
82
|
+
return InstanceHolder.instance
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
package com.htreactnative.imagepicker
|
|
2
|
+
|
|
3
|
+
import android.graphics.BitmapFactory
|
|
4
|
+
import com.facebook.react.bridge.Promise
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
|
+
import com.facebook.react.bridge.WritableNativeArray
|
|
9
|
+
import com.facebook.react.bridge.WritableNativeMap
|
|
10
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
11
|
+
import com.luck.picture.lib.basic.PictureSelector
|
|
12
|
+
import com.luck.picture.lib.config.SelectMimeType
|
|
13
|
+
import com.luck.picture.lib.entity.LocalMedia
|
|
14
|
+
import com.luck.picture.lib.interfaces.OnResultCallbackListener
|
|
15
|
+
import com.luck.picture.lib.utils.SdkVersionUtils
|
|
16
|
+
import java.io.File
|
|
17
|
+
import java.util.ArrayList
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@ReactModule(name = NativeImagePickerModule.NAME)
|
|
21
|
+
class NativeImagePickerModule(reactContext: ReactApplicationContext) :
|
|
22
|
+
NativeImagePickerSpec(reactContext) {
|
|
23
|
+
val imageEngine = GlideEngine.createGlideEngine()
|
|
24
|
+
var pickerOptions: ReadableMap? = null
|
|
25
|
+
override fun getName(): String {
|
|
26
|
+
return NAME
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun asyncShowImagePicker(
|
|
30
|
+
options: ReadableMap?,
|
|
31
|
+
promise: Promise?
|
|
32
|
+
) {
|
|
33
|
+
pickerOptions = options;
|
|
34
|
+
PictureSelector.create(reactApplicationContext.currentActivity)
|
|
35
|
+
.openGallery(SelectMimeType.ofImage())
|
|
36
|
+
.setImageEngine(imageEngine)
|
|
37
|
+
.forResult(object : OnResultCallbackListener<LocalMedia> {
|
|
38
|
+
override fun onResult(localMediaList: ArrayList<LocalMedia?>?) {
|
|
39
|
+
var data = WritableNativeArray()
|
|
40
|
+
localMediaList?.forEach { media -> media?.let {
|
|
41
|
+
data.pushMap(getImageResult(media))
|
|
42
|
+
} }
|
|
43
|
+
promise?.resolve(data)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun onCancel() {
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private fun getImageResult(media: LocalMedia): WritableMap {
|
|
54
|
+
val imageMap: WritableMap = WritableNativeMap()
|
|
55
|
+
var path: String = media.path
|
|
56
|
+
|
|
57
|
+
if (media.isCompressed || media.isCut) {
|
|
58
|
+
path = media.compressPath
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (media.isCut) {
|
|
62
|
+
path = media.cutPath
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
val isAndroidQ = SdkVersionUtils.isQ()
|
|
66
|
+
val isAndroidR = SdkVersionUtils.isR()
|
|
67
|
+
if (isAndroidQ) {
|
|
68
|
+
path = media.availablePath
|
|
69
|
+
}
|
|
70
|
+
if (isAndroidR) {
|
|
71
|
+
path = media.realPath;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
val options = BitmapFactory.Options()
|
|
75
|
+
options.inJustDecodeBounds = true
|
|
76
|
+
BitmapFactory.decodeFile(path, options)
|
|
77
|
+
imageMap.putDouble("width", options.outWidth.toDouble())
|
|
78
|
+
imageMap.putDouble("height", options.outHeight.toDouble())
|
|
79
|
+
imageMap.putString("type", "image")
|
|
80
|
+
imageMap.putString("path", path)
|
|
81
|
+
imageMap.putString("uri", "file://$path")
|
|
82
|
+
imageMap.putString("original_uri", "file://" + media.path)
|
|
83
|
+
imageMap.putInt("size", File(path).length().toInt())
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
return imageMap
|
|
87
|
+
}
|
|
88
|
+
companion object {
|
|
89
|
+
const val NAME = "NativeImagePicker"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.htreactnative.imagepicker
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class NativeImagePickerPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == NativeImagePickerModule.NAME) {
|
|
13
|
+
NativeImagePickerModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[NativeImagePickerModule.NAME] = ReactModuleInfo(
|
|
23
|
+
NativeImagePickerModule.NAME,
|
|
24
|
+
NativeImagePickerModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NSMutableDictionary+SYSafeConvert.h
|
|
3
|
+
// RNSyanImagePicker
|
|
4
|
+
//
|
|
5
|
+
// Created by CookieJ on 2017/10/18.
|
|
6
|
+
// Copyright © 2017年 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
|
|
11
|
+
@interface NSMutableDictionary (SYSafeConvert)
|
|
12
|
+
|
|
13
|
+
- (void)sy_setObject:(id)value forKey:(NSString *)key;
|
|
14
|
+
|
|
15
|
+
- (void)sy_setInteger:(NSInteger)value forKey:(NSString *)key;
|
|
16
|
+
|
|
17
|
+
- (void)sy_setBool:(BOOL)value forKey:(NSString *)key;
|
|
18
|
+
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@interface NSDictionary (SYSafeConvert)
|
|
22
|
+
|
|
23
|
+
- (NSString *)sy_stringForKey:(NSString *)key;
|
|
24
|
+
|
|
25
|
+
- (BOOL)sy_boolForKey:(NSString *)key;
|
|
26
|
+
|
|
27
|
+
- (NSInteger)sy_integerForKey:(NSString *)key;
|
|
28
|
+
|
|
29
|
+
@end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//
|
|
2
|
+
// NSMutableDictionary+SYSafeConvert.m
|
|
3
|
+
// RNSyanImagePicker
|
|
4
|
+
//
|
|
5
|
+
// Created by CookieJ on 2017/10/18.
|
|
6
|
+
// Copyright © 2017年 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "NSDictionary+SYSafeConvert.h"
|
|
10
|
+
|
|
11
|
+
@implementation NSMutableDictionary (SYSafeConvert)
|
|
12
|
+
|
|
13
|
+
- (void)sy_setObject:(id)value forKey:(NSString *)key {
|
|
14
|
+
if (![self isKindOfClass:[NSMutableDictionary class]]) {
|
|
15
|
+
NSLog(@"类型有误,非字典无法设置值!");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (value && value != [NSNull null] && key) {
|
|
20
|
+
[self setObject:value forKey:key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (void)sy_setBool:(BOOL)value forKey:(NSString *)key {
|
|
25
|
+
if (![self isKindOfClass:[NSMutableDictionary class]]) {
|
|
26
|
+
NSLog(@"类型有误,非字典无法设置值!");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (key) {
|
|
31
|
+
[self setObject:@(value) forKey:key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)sy_setInteger:(NSInteger)value forKey:(NSString *)key {
|
|
36
|
+
if (![self isKindOfClass:[NSMutableDictionary class]]) {
|
|
37
|
+
NSLog(@"类型有误,非字典无法设置值!");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (key) {
|
|
42
|
+
[self setObject:@(value) forKey:key];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@end
|
|
47
|
+
|
|
48
|
+
@implementation NSDictionary (SYSafeConvert)
|
|
49
|
+
|
|
50
|
+
- (BOOL)sy_boolForKey:(NSString *)key {
|
|
51
|
+
if (![self isKindOfClass:[NSDictionary class]]) {
|
|
52
|
+
NSLog(@"类型有误,无法从非字典取值!");
|
|
53
|
+
return nil;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
id value = [self objectForKey:key];
|
|
57
|
+
if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) {
|
|
58
|
+
return [value boolValue];
|
|
59
|
+
}
|
|
60
|
+
return NO;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (NSInteger)sy_integerForKey:(NSString *)key {
|
|
64
|
+
if (![self isKindOfClass:[NSDictionary class]]) {
|
|
65
|
+
NSLog(@"类型有误,无法从非字典取值!");
|
|
66
|
+
return nil;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
id value = [self objectForKey:key];
|
|
70
|
+
if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) {
|
|
71
|
+
return [value integerValue];
|
|
72
|
+
}
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (NSString *)sy_stringForKey:(NSString *)key {
|
|
77
|
+
if (![self isKindOfClass:[NSDictionary class]]) {
|
|
78
|
+
NSLog(@"类型有误,无法从非字典取值!");
|
|
79
|
+
return nil;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
id value = [self objectForKey:key];
|
|
83
|
+
if ([value isKindOfClass:[NSString class]]) {
|
|
84
|
+
return (NSString *)value;
|
|
85
|
+
}
|
|
86
|
+
if ([value isKindOfClass:[NSNumber class]]) {
|
|
87
|
+
return [value stringValue];
|
|
88
|
+
}
|
|
89
|
+
return nil;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#import <NativeImagePickerSpec/NativeImagePickerSpec.h>
|
|
2
|
+
#import "TZImagePickerController.h"
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
@interface NativeImagePicker : NSObject <NativeImagePickerSpec, TZImagePickerControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate>
|
|
6
|
+
|
|
7
|
+
@end
|