npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

native-cmos-image-picker

v0.0.2

Published

use react-native-image-picker

Downloads

2

Readme

native-cmos-image-picker

描述

native-cmos-image-picker是基于react-native-image-picker基础上 再次封装,以使用与自己的项目;

####安装

npm install native-cmos-image-picker@latest --save

自动配置

React Native >= 0.29 $react-native link

React Native < 0.29 $rnpm link

备注: 手动需要以下配置.

手动的配置

iOS

  1. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ Add Files to <...>
  2. Go to node_modulesreact-native-image-pickerios ➜ select RNImagePicker.xcodeproj
  3. Add RNImagePicker.a to Build Phases -> Link Binary With Libraries
  4. For iOS 10+, Add the NSPhotoLibraryUsageDescription and NSCameraUsageDescription keys to your Info.plist with strings describing why your app needs these permissions
  5. Compile and have fun

Android

// file: android/settings.gradle
...

include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(settingsDir, '../node_modules/react-native-image-picker/android')
// file: android/app/build.gradle
...

dependencies {
    ...
    compile project(':react-native-image-picker')
}
<!-- file: android/app/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myApp">

    <uses-permission android:name="android.permission.INTERNET" />

    <!-- add following permissions -->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
    <!-- -->
    ...
// file: android/app/src/main/java/com/<...>/MainApplication.java
...

import com.imagepicker.ImagePickerPackage; // <-- add this import

public class MainApplication extends Application implements ReactApplication {
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new ImagePickerPackage() // <-- add this line
        );
    }
...
}

Options

option | iOS | Android | 说明 ------ | ---- | ------- | ---- title | OK | OK | 指定null 或 empty则没有标题 ,选择弹出框的标题 cancelButtonTitle | OK | OK | 指定 null或empty 则没有取消按钮 (Android only) takePhotoButtonTitle | OK | OK | 指定 null 或 empty 则没有打开相机的按钮 chooseFromLibraryButtonTitle | OK | OK | 指定 null or 空,则没有打开相册按钮 customButtons | OK | OK | An array containing objects with the name and title of buttons cameraType | OK | - | 'front' or 'back' mediaType | OK | OK | 'photo', 'video'或 'mixed' 在iOS设备上, 'photo'或'video' 在 Android设备上 maxWidth | OK | OK | 仅相片,最大宽度 maxHeight | OK | OK | 仅相片,最大高度 quality | OK | OK | 0 到 1, 仅相片,图片压缩质量 videoQuality | OK | OK | 'low', 'medium', or 'high'在IOS终端, 'low' or 'high' 在Android终端 durationLimit | OK | OK | 视频最大记录时间, 单位/s rotation | - | OK | 紧图片, 0 to 360 旋转 allowsEditing | OK | - | bool - 是否启动编辑图片 noData | OK | OK |为true时,则禁用 base64 data storageOptions | OK | OK | If this key is provided, the image will get saved in the Documents directory on iOS, and the Pictures directory on Android (rather than a temporary directory) storageOptions.skipBackup | OK | - | If true, the photo will NOT be backed up to iCloud storageOptions.path | OK | - | If set, will save image at /Documents/[path] rather than the root storageOptions.cameraRoll | OK | - | If true, the cropped photo will be saved to the iOS Camera Roll. storageOptions.waitUntilSaved | OK | - | If true, will delay the response callback until after the photo/video was saved to the Camera Roll. If the photo or video was just taken, then the file name and timestamp fields are only provided in the response object when this is true.

回参对象

参数 | iOS | Android | 描述 ------ | ---- | ------- | ---------------------- didCancel | OK | OK | 取消选择时,返回didCancel error | OK | OK | 出现异常时,返回异常信息 data | OK | OK | 图片 ,将返回base64字符串 uri | OK | OK | 返回本地路径 (photo or video) origURL | OK | - | 原始的URL资源在照片库 isVertical | OK | OK | 如果图像是垂直的,则为true width | OK | OK | 图片宽度 height | OK | OK | 图片高度 fileSize | OK | OK | 图片字节大小 (photos only) type | - | OK | 图片类型 (photos only) fileName | OK (photos and videos) | OK (photos) |文件名 path | - | OK | 文件路径 latitude | OK | OK | Latitude metadata, if available longitude | OK | OK | Longitude metadata, if available timestamp | OK | OK | Timestamp metadata, if available, in ISO8601 UTC format originalRotation | - | OK | 旋转度 (photos only) See #109

使用示例

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import ImgPicker from 'native-cmos-image-picker';
export default class example extends Component {
  constructor(props){
    super(props)
    this.callback = this.callback.bind(this);
  }
  callback(res){
    if (res.didCancel) {
        console.log('取消选择');
      }else if (res.error) {
        console.log('图片选择失败', res.error);
      }else{
        //选择图片成功执行
        console.log(res)
      }
  }
  render() {
    return (
      <View style={styles.container}>
        <ImgPicker  options={{title:'选择'}} imagePickerCall={this.callback}>
          <Text>上传图片 测试</Text>
        </ImgPicker>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('example', () => example);
	

直接启动相机或图片库

// Launch Camera:
ImagePicker.launchCamera(options, (response)  => {
  // Same code as in above section!
});

// Open Image Library:
ImagePicker.launchImageLibrary(options, (response)  => {
  // Same code as in above section!
});

备注

在IOS上不要以绝对路径返回

更新

版本号|时间|说明 :----|:---:|:---- v0.0.2|2017-3-29|解决react-native-image-picker native版本冲突问题