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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hadss/react_native_picker

v1.0.0-rc.1

Published

RN picker interface package

Readme

@hadss/react_native_picker

介绍

为 React Native 提供音频、相机、联系人、文件、地图、照片、扫码的 Picker 能力。 相机、文件管理、联系人等系统应用提供了系统 Picker 组件,支持开发者无需申请权限、即可使用系统应用的一些常用功能,比如访问用户的资源文件。 应用拉起系统 Picker 组件后,由用户在 Picker 上选择对应的文件、照片、联系人等资源,应用即可获取到 Picker 的返回结果。

工程目录

.
├─harmony
|    ├─picker
│    │   └─src
│    │      ├─main
│    │          └─ets
│    │            ├─pickers
│    │            ├─PickerModule.ets         // Turbo Modules接口ArkTS实现
│    │            ├─PickerModulePackage.ets
│    │            └─PickerModuleSpec.ts      // Turbo Modules接口
|    └─PickerHO
         └─picker.har
├─src
│  ├─index.ts                                // RN模块导出
│  └─turbo
|     └─PickerModule.ts                      // RN Turbo Modules接口

安装与使用

进入到工程目录并输入以下命令:

npm

npm install @hadss/react_native_picker

yarn

yarn add @hadss/react_native_picker

下面的代码展示了这个库的基本使用场景:

Picker 能力使用示例

import React, {useState} from 'react';
import {SafeAreaView, ScrollView, Text, Button} from 'react-native';
import {
  Picker,
  SelectCameraPosition,
  SelectContactFilterType,
  SelectContactFilterCondition,
  ScanType,
  PhotoViewMIMETypes,
  CompleteButtonText,
  DocumentSelectMode,
} from '@hadss/react_native_picker';

function App(): JSX.Element {
  const [result, setResult] = useState('');

  const onPressAudio = async (): Promise<void> => {
    const res = await Picker.selectAudio({});
    setResult(JSON.stringify(res));
  };

  const onPressSelectCamera = async (): Promise<void> => {
    const res = await Picker.selectCamera(['photo', 'video'], {
      cameraPosition: SelectCameraPosition.CAMERA_POSITION_BACK,
    });
    setResult(JSON.stringify(res));
  };

  const onPressContact = async (): Promise<void> => {
    const res = await Picker.selectContact({
      filter: {
        filterClause: {
          name: [
            {
              filterCondition: SelectContactFilterCondition.NOT_IN,
              value: ['a', 'b'],
            },
          ],
        },
        filterType: SelectContactFilterType.SHOW_FILTER,
      },
    });
    setResult(JSON.stringify(res));
  };

  const onPressDocument = async (): Promise<void> => {
    const res = await Picker.selectDocument({
      maxSelectNumber: 3,
      selectMode: DocumentSelectMode.FILE,
    });
    setResult(JSON.stringify(res));
  };

  const onPressQueryLocation = async (): Promise<void> => {
    let queryLocationOptions = {
      location: {
        latitude: 39.9175,
        longitude: 116.3972,
      },
      name: '故宫博物院',
    };
    await Picker.queryLocation(queryLocationOptions);
  };

  const onPressChooseLocation = async (): Promise<void> => {
    const res = await Picker.chooseLocation({});
    setResult(JSON.stringify(res));
  };

  const onPressSelectDistrict = async (): Promise<void> => {
    const res = await Picker.selectDistrict({});
    setResult(JSON.stringify(res));
  };

  const onPressPhoto = async (): Promise<void> => {
    const res = await Picker.selectPhoto({
      MIMEType: PhotoViewMIMETypes.IMAGE_TYPE,
      completeButtonText: CompleteButtonText.TEXT_ADD,
    });
    setResult(JSON.stringify(res));
  };

  const onPressStartScan = async (): Promise<void> => {
    const res = await Picker.startScan({
      scanTypes: [ScanType.QR_CODE],
      enableAlbum: false,
    });
    setResult(JSON.stringify(res));
  };

  return (
    <SafeAreaView>
      <ScrollView contentInsetAdjustmentBehavior="automatic">
        <Text>Picker:</Text>
        <Button title="selectAudio" onPress={onPressAudio} />
        <Button title="selectCamera" onPress={onPressSelectCamera} />
        <Button title="selectContact" onPress={onPressContact} />
        <Button title="selectDocument" onPress={onPressDocument} />
        <Button title="queryLocation" onPress={onPressQueryLocation} />
        <Button title="chooseLocation" onPress={onPressChooseLocation} />
        <Button title="selectDistrict" onPress={onPressSelectDistrict} />
        <Button title="selectPhoto" onPress={onPressPhoto} />
        <Button title="startScan" onPress={onPressStartScan} />
        <Text>结果: {result}</Text>
      </ScrollView>
    </SafeAreaView>
  );
}

export default App;

Link

目前 OpenHarmony 暂不支持 AutoLink,所以 Link 步骤需要手动配置。

首先需要使用 DevEco Studio 打开项目里的 OpenHarmony 工程,在工程根目录的oh-package.json5添加 overrides 字段:

{
  "overrides": {
    "@rnoh/react-native-openharmony": "./react_native_openharmony"
  }
}

引原生端代码

目前有两种方法:

  1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法)。

    >**说明:**
    >har包位于三方库安装路径的`harmony`文件夹下。
    
    a. 打开`entry/oh-package.json5`,添加以下依赖:
    
    ```
    "dependencies":{
        "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
        "@hadss/react_native_picker": "file:../../node_modules/@hadss/react_native_picker/harmony/picker.har",
      }
    ```
    
    b. 配置CMakeLists和引入RNOHGeneratedPackage:
    
    打开`entry/src/main/cpp/CMakeLists.txt`,添加:
    
    ```diff
    project(rnapp)
    cmake_minimum_required(VERSION 3.4.1)
    set(CMAKE_SKIP_BUILD_RPATH TRUE)
    set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
    set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
    
    set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@rnoh/react-native-openharmony/src/main/cpp")
    set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
    set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
    set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
    add_compile_definitions(WITH_HITRACE_SYSTRACE)
    set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
    + file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
    
    add_subdirectory("${RNOH_CPP_DIR}" ./rn)
    
    add_library(rnoh_app SHARED
    +    ${GENERATED_CPP_FILES}
        "./PackageProvider.cpp"
        "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
    )
    
    target_link_libraries(rnoh_app PUBLIC rnoh)
    ```
    
    c. 打开`entry/src/main/cpp/PackageProvider.cpp`,添加:
    
    ```diff
    #include "RNOH/PackageProvider.h"
    + #include "generated/RNOHGeneratedPackage.h"
    
    using namespace rnoh;
    
    std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
        return {
    +        std::make_shared<RNOHGeneratedPackage>(ctx)
        };
    }
    ```
    
    d. 在ArkTs侧引入AvoidModulePackage:
    
    打开`entry/src/main/ets/RNPackagesFactory.ts`,添加:
    
    ```diff
      ...
    + import { PickerModulePackage } from '@hadss/react_native_picker';
    
    export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
      return [
    +   new PickerModulePackage(ctx),
      ];
    }
    ```
    
    f. 运行:
    
    点击右上角的`sync`按钮
    
    或者在终端执行:
    
    ```bash
    cd entry
    ohpm install
    ```
    然后编译、运行即可。

    说明 若项目启动时报错:can not find record '&@rnoh/react-native-openharmony/generated/ts&X.X.X'。需在 entry\oh_modules@rnoh\react-native-openharmony\ts.ts 文件中添加 export * from './generated/ts',并删除.cxx 文件夹、build 文件夹,然后执行 sync 操作同步代码。

  2. 直接链接源码。

    如需使用直接链接源码,请参考直接链接源码说明

权限要求

如果使用地图Picker,应用需要开通地图服务

  • 方式一:通过DevEco Studio开通地图服务(需要DevEco Studio 6.0.0 Beta5以上版本)。 1.打开DevEco Studio File菜单,点击Project Structure。 2.进入“Signing Configs”页面,点击“Enable open capabilities”。 3.勾选“Map Kit”选项,点击“OK”。

  • 方式二:通过AppGallery Connect网站开通地图服务。 1.登录AppGallery Connect网站,选择“开发与服务”。 2.在项目列表中找到您的项目,在项目下的应用列表中选择需要打开“地图服务”的应用。 3.选择开放能力管理,找到“地图服务”开关,打开开关。 4.确认已经开启“地图服务”开放能力,并完成签名。

    • 调试阶段必须申请调试证书、注册设备、开启"地图服务"后重新申请调试Profile文件,并完成手动签名。
    • 发布阶段必须申请发布证书、开启“地图服务”后重新申请发布Profile文件,并配置签名信息。

API

说明: "Platform"列表示支持的平台,All 表示支持所有平台。

Picker 接口

Picker | Name | Description | Type | Platform | | ------------------- | -----------------------------------------------------| -------- | --------- | | selectAudio | 拉起 audioPicker 界面,用户可以选择一个或多个音频文件。 | (options: SelectAudioOptions) => Promise<SelectAudioResult> | OpenHarmony| | selectCamera | 拉起相机,根据媒体类型进入相应的模式。 | (mediaTypes: SelectCameraMediaTypes, options: SelectCameraOptions) => Promise<SelectCameraResult> | OpenHarmony| | selectContact | 拉起选择联系人界面 | (options: SelectContactOptions) => Promise<SelectContactResult> | OpenHarmony| | selectDocument | 拉起 documentPicker 界面,用户可以选择一个或多个文件。 | (options: SelectDocumentOptions) => Promise<SelectDocumentResult> | OpenHarmony| | queryLocation | 拉起地点详情展示控件 | (options: QueryLocationOptions) => Promise<void> | OpenHarmony| | chooseLocation | 拉起地点选取控件 | (options: ChooseLocationOptions) => Promise<ChooseLocationResult> | OpenHarmony| | selectDistrict | 拉起区划选择页面 | (options: SelectDistrictOptions) => Promise<SelectDistrictResult> | OpenHarmony| | selectPhoto | 拉起 photoPicker 界面,用户可以选择一个或多个图片/视频。 | (options: SelectPhotoOptions) => Promise<SelectPhotoResult> | OpenHarmony| | startScan | 拉起扫码界面 | (options: StartScanOptions) => Promise<StartScanResult> | OpenHarmony|

Interface: SelectAudioOptions

音频选择参数

Properties

| Property | Type | Description | | ----------------------------------------------- | -------- | ------------------------------ | | maxSelectNumber? | number | 最大可以选择的数量.范围 1-500. |


Type Alias: SelectAudioResult

SelectAudioResult = string[]

音频选择结果


Interface: SelectCameraOptions

相机选择参数

Properties

| Property | Type | Description | | -------------------------------------------- | ----------------------------------------------------------------- | ---------------------------------------------------------- | | cameraPosition | SelectCameraPosition | 相机位置。 | | saveUri? | string | 保存配置信息的 uri | | videoDuration? | number | 录制的最大时长(单位:秒)。默认为 0,不设置最大录制时长。 |


Type Alias: SelectCameraMediaTypes

SelectCameraMediaTypes = ("photo" | "video")[]

媒体类型。


Enumeration: SelectCameraPosition

相机的位置

Enumeration Members

| Enumeration Member | Value | Description | | ------ | ------ | ------ | | CAMERA_POSITION_BACK | 1 | 后置相机。 | | CAMERA_POSITION_FOLD_INNER | 3 | 折叠态相机。 从API version 11开始支持,从API version 12开始废弃。。 | | CAMERA_POSITION_FRONT | 2 | 前置相机。 | | CAMERA_POSITION_UNSPECIFIED | 0 | 相对于设备屏幕没有固定的朝向的相机。 |


Interface: SelectCameraResult

相机选择结果

Properties

| Property | Type | Description | | ------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | mediaType | string | 返回的媒体类型。 | | resultCode | number | 保存配置信息的 uri | | resultUri | string | 返回的 uri 地址。若 saveUri 为空,resultUri 为公共媒体路径。若 saveUri 不为空且具备写权限,resultUri 与 saveUri 相同。若 saveUri 不为空且不具备写权限,则无法获取到 resultUri。 |


Interface: SelectContactOptions

选择联系人参数。

Properties

| Property | Type | Description | | --------------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------- | | filter? | SelectContactFilter | 联系人查询过滤器。 | | isDisplayedByName? | boolean | 是否按联系人姓名维度展示,true:按联系人姓名维度展示,false:按联系人号码维度展示。默认值为 false。 | | isMultiSelect? | boolean | 是否为多选,true:多选,false:单选。默认值为 false。 | | maxSelectable? | number | 联系人选择数量上限。默认值为 10000。 |


Interface: SelectContactFilter

联系人查询过滤器。

Properties

| Property | Type | Description | | ---------------------------------------- | ----------------------------------------------------------------------- | ----------- | | filterClause | SelectContactFilterClause | 过滤条件。 | | filterType | SelectContactFilterType | 过滤类型。 |


Interface: SelectContactFilterClause

联系人过滤条件。

Properties

| Property | Type | Description | | ------------------------------------------- | --------------------------------------------------------------- | ------------------ | | dataItem? | SelectContactDataFilter | 联系人数据过滤项。 | | focusModeList? | SelectContactFilterOptions[] | 专注模式。 | | id? | SelectContactFilterOptions[] | 联系人 id。 | | name? | SelectContactFilterOptions[] | 联系人姓名。 |


Enumeration: SelectContactFilterType

枚举,联系人过滤类型。

Enumeration Members

| Enumeration Member | Value | | ---------------------------------------------------------------------------- | ----- | | DEFAULT_SELECT | 1 | | SHOW_FILTER | 0 | | SHOW_FILTER_AND_DEFAULT_SELECT | 2 |


Interface: SelectContactDataFilter

联系人数据过滤项。

Properties

| Property | Type | | ------------------------------ | --------------------------------------------------------------- | | field | SelectContactDataField | | options | SelectContactFilterOptions[] |


Interface: SelectContactFilterOptions

联系人过滤参数。

Properties

| Property | Type | Description | | ---------------------------------------------- | ----------------------------------------------------------------------------------- | -------------------------- | | filterCondition | SelectContactFilterCondition | 过滤条件。 | | value? | string | SelectContactValueType[] | 过滤值,默认为 undefined。 |


Enumeration: SelectContactFilterCondition

枚举,过滤条件。

Enumeration Members

| Enumeration Member | Value | | ---------------------------------------- | ----- | | CONTAINS | 5 | | EQUAL_TO | 1 | | IN | 3 | | IS_NOT_NULL | 0 | | NOT_EQUAL_TO | 2 | | NOT_IN | 4 |


Type Alias: SelectContactValueType

SelectContactValueType = number | string | boolean

过滤值。


Type Alias: SelectContactResult

SelectContactResult = Contact[]

选择联系人结果。


Interface: Contact

联系人对象类。

Properties

| Property | Type | Description | | ----------------------------------------------- | ------------------------------------- | -------------------------------------- | | emails? | Email[] | - | | events? | Event[] | 联系人的生日、周年纪念等重要日期列表。 | | groups? | Group[] | 联系人的群组列表。 | | id? | number | 联系人的 id,由系统自动生成。 | | imAddresses? | ImAddress[] | 联系人的即时消息地址列表。 | | key? | string | 联系人的 key,由系统自动生成。 | | name? | Name | - | | nickName? | NickName | - | | note? | Note | 联系人的备注。 | | organization? | Organization | 联系人的组织信息。 | | phoneNumbers? | PhoneNumber[] | - | | portrait? | Portrait | 联系人的头像。 | | postalAddresses? | PostalAddress[] | 联系人的邮政地址列表。 | | relations? | Relation[] | 联系人的关系列表。 | | sipAddresses? | SipAddress[] | 联系人的会话发起协议(SIP)地址列表。 | | websites? | Website[] | - |


Interface: Email

Properties

| Property | Type | | --------------------------------------- | -------- | | displayName? | string | | email | string | | labelId? | number | | labelName? | string |


Interface: District

Properties

| Property | Type | | --------------------------------------- | --------------------- | | adminCode? | string | | adminLevel? | string | | cityCode? | string | | countryCode? | string | | location? | LatLng | | name? | string | | siteId? | string |


Interface: City

Properties

| Property | Type | | --------------------------------- | -------- | | cityCode? | string | | cityId? | string | | cityName? | string |


Interface: Event

Properties

| Property | Type | | ----------------------------------- | -------- | | eventDate | string | | labelId? | number | | labelName? | string |


Interface: Group

Properties

| Property | Type | | ------------------------------- | -------- | | groupId? | number | | title | string |


Interface: ImAddress

Properties

| Property | Type | | ----------------------------------- | -------- | | imAddress | string | | labelId? | number | | labelName? | string |


Interface: Name

Properties

| Property | Type | | ----------------------------------------------------- | -------- | | familyName? | string | | familyNamePhonetic? | string | | fullName | string | | givenName? | string | | givenNamePhonetic? | string | | middleName? | string | | middleNamePhonetic? | string | | namePrefix? | string | | nameSuffix? | string |


Interface: NickName

Properties

| Property | Type | | -------------------------------- | -------- | | nickName | string |


Interface: Note

Properties

| Property | Type | | -------------------------------------- | -------- | | noteContent | string |


Interface: Organization

Properties

| Property | Type | | --------------------------- | -------- | | name | string | | title? | string |


Interface: PhoneNumber

Properties

| Property | Type | | -------------------------------------- | -------- | | labelId? | number | | labelName? | string | | phoneNumber | string |


Interface: Portrait

Properties

| Property | Type | | ---------------------- | -------- | | uri | string |


Interface: PostalAddress

Properties

| Property | Type | | ------------------------------------------ | -------- | | city? | string | | country? | string | | labelId? | number | | labelName? | string | | neighborhood? | string | | pobox? | string | | postalAddress | string | | postcode? | string | | region? | string | | street? | string |


Interface: Relation

Properties

| Property | Type | | ---------------------------------------- | -------- | | labelId? | number | | labelName? | string | | relationName | string |


Interface: SipAddress

Properties

| Property | Type | | ------------------------------------ | -------- | | labelId? | number | | labelName? | string | | sipAddress | string |


Interface: Website

Properties

| Property | Type | | ------------------------------ | -------- | | website | string |


Interface: SelectDocumentOptions

文档选择选项。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | authMode? | boolean | 拉起授权Picker,默认为false(非授权模式)。当authMode为true时为授权模式,defaultFilePathUri必填,表明待授权URI。 | | defaultFilePathUri? | string | 指定选择的文件或者目录的URI。默认为空(效果为拉起最近打开页)。 | | fileSuffixFilters? | string[] | 选择文件的后缀类型。传入字符串数组,每一项代表一个后缀选项,每一项内部用"|"分为两部分,第一部分为描述,第二部分为过滤后缀。没有"|"则没有描述,该项整体是一个过滤后缀。每项过滤后缀可以存在多个后缀名,则每一个后缀名之间用英文逗号进行分隔,传入数组长度不能超过100,例如:['图片(.png, .jpg)|.png,.jpg', '文档|.txt', '视频|.mp4', '.pdf']。 | | isEncryptionSupported? | boolean | 是否支持加密(仅支持文件,文件夹不生效),默认为false。该参数为true时,在Picker界面可以选择对文件进行加密。 | | maxSelectNumber? | number | 选择文件最大个数,上限为500个,有效值范围1-500(选择目录仅对具有该系统能力的设备开放。且目录选择的最大个数为1)。默认值是500。 | | mergeMode? | MergeTypeMode | 开启聚合视图模式,支持拉起文件管理应用的聚合视图。默认为DEFAULT,表示该参数不生效,非聚合视图。当该参数置为非DEFAULT时,其他参数不生效。 | | multiAuthMode? | boolean | 支持批量授权模式,默认为false(非批量授权模式)。当multiAuthMode为true时为批量授权模式。当multiAuthMode为true时,只有multiUriArray参数生效,其他参数不生效。 | | multiUriArray? | string[] | 传入需要批量授权的URI数组(仅支持文件,文件夹不生效)。配合multiAuthMode使用。当multiAuthMode为false时,配置该参数不生效。默认为空(效果为拉起批量授权页面后展示的文件为空)。 | | selectMode? | DocumentSelectMode | Picker选择的文档类型,默认值是FILE(文件类型)。 |


Enumeration: MergeTypeMode

枚举,文件聚合类型。

Enumeration Members

| Enumeration Member | Value | | ------ | ------ | | AUDIO | 1 | | DEFAULT | 0 | | DOCUMENT | 3 | | PICTURE | 4 | | VIDEO | 2 |


Enumeration: DocumentSelectMode

枚举,选择的文档类型。

Enumeration Members

| Enumeration Member | Value | | ------ | ------ | | FILE | 0 | | FOLDER | 1 | | MIXED | 2 |


Type Alias: SelectDocumentResult

SelectDocumentResult = string[]


Interface: QueryLocationOptions

查询地点详情的参数。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | address? | string | 地点的地址。如果没有siteId,使用address作为location的地址标注。 | | language? | string | 语言,请参见地图Picker支持语言,如果未设置,默认使用系统语言。 | | location? | LatLng | 地图中心点坐标。如果没有siteId,使用location查询地点详情。 | | name? | string | 地点的名称。如果没有siteId,使用name作为location的名称标注。 | | showBusiness? | boolean | 是否显示商业信息(如打车),默认值为true。 | | siteId? | string | 地点详情页的地点ID。 |


Interface: LatLng

经纬度对象。

Properties

| Property | Type | | ------ | ------ | | latitude | number | | longitude | number |


Interface: ChooseLocationOptions

地点选取的参数。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | language? | string | 语言,请参见地图Picker支持语言,如果未设置,默认使用系统语言。 | | location? | LatLng | 地图中心点坐标。如果参数未传,使用设备当前位置作为中心点;如果未获取到设备当前位置,默认以故宫博物院为中心点。 | | poiTypes? | string[] | 指定需要展示的POI类别。取值范围参见HwLocationType。 | | searchEnabled? | boolean | 是否展示搜索控件,默认值为false,异常值按默认值处理。 | | showNearbyPoi? | boolean | 是否展示附近POI,默认值为false,异常值按默认值处理。 |


Interface: ChooseLocationResult

Properties

| Property | Type | | ------ | ------ | | address | string | | addressComponent? | AddressComponent | | location? | LatLng | | name? | string | | siteId? | string | | zoom | number |


Interface: AddressComponent

地址详细信息。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | adminCode? | string | 行政区划码。 | | adminLevel1? | string | 一级行政区。 | | adminLevel2? | string | - | | adminLevel3? | string | - | | adminLevel4? | string | - | | adminLevel5? | string | - | | city? | City | - | | countryCode? | string | 国家/地区码。 | | countryName? | string | 国家名。 | | locality? | string | 地区、区域。 | | neighborhoods? | string[] | 街区、城区。 | | postalCode? | string | - | | streetNumber? | StreetNumber | - | | subLocality1? | string | 一级子区域。 | | subLocality2? | string | - |


Interface: StreetNumber

Properties

| Property | Type | | ------ | ------ | | direction? | string | | distance? | number | | formatAddress? | string | | location? | LatLng | | streetName? | string | | streetNumber? | string |


Interface: SelectDistrictOptions

区划选择页面初始选项。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | address? | string | - | | countryCode? | string | 查询指定国家或地区的行政区划,国家或地区码必须符合ISO 3166-1 alpha-2规则。 | | language? | string | - |


Interface: SelectDistrictResult

区划选择请求的结果。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | addressDescription? | string | 返回所选行政区划的地址信息。 | | districts | District[] | 所选行政区划的级别信息。 |


Interface: District

Properties

| Property | Type | | ------ | ------ | | adminCode? | string | | adminLevel? | string | | cityCode? | string | | countryCode? | string | | location? | LatLng | | name? | string | | siteId? | string |


Interface: SelectPhotoOptions

图库选择选项

Properties

| Property | Type | Description | | ------ | ------ | ------ | | completeButtonText? | CompleteButtonText | 完成按钮显示的内容。完成按钮指在界面右下方,用户点击表示图片选择已完成的按钮。 | | isEditSupported? | boolean | 是否支持编辑照片,true表示支持,false表示不支持,默认为true。 | | isOriginalSupported? | boolean | 是否显示选择原图按钮,true表示显示,false表示不显示,默认为true。 | | isPhotoTakingSupported? | boolean | 是否支持拍照,true表示支持,false表示不支持,默认为true。 | | isSearchSupported? | boolean | 是否支持搜索,true表示支持,false表示不支持,默认为true。 | | maxSelectNumber? | number | 选择媒体文件数量的最大值(最大可设置的值为500,若不设置则默认为50)。 | | MIMEType? | PhotoViewMIMETypes | 可选择的媒体文件类型,若无此参数,则默认为图片和视频类型。 | | mimeTypeFilter? | MimeTypeFilter | 文件类型的过滤配置,支持指定多个类型过滤。 |


Enumeration: PhotoViewMIMETypes

枚举,可选择的媒体文件类型。

Enumeration Members

| Enumeration Member | Value | | ------ | ------ | | IMAGE_TYPE | "image/*" | | IMAGE_VIDEO_TYPE | "*/*" | | MOVING_PHOTO_IMAGE_TYPE | "image/movingPhoto" | | VIDEO_TYPE | "video/*" |


Interface: MimeTypeFilter

文件类型的过滤配置。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | mimeTypeArray | string[] | PhotoPicker可供用户选择媒体文件的过滤类型。 例如:“image/jpeg”、“video/mp4”等。 |


Enumeration: CompleteButtonText

Enumeration Members

| Enumeration Member | Value | | ------ | ------ | | TEXT_ADD | 2 | | TEXT_DONE | 0 | | TEXT_SEND | 1 |


Interface: SelectPhotoResult

图库选择返回结果

Properties

| Property | Type | Description | | ------ | ------ | ------ | | isOriginalPhoto | boolean | 是否是原图 | | photoUris | string[] | 返回图库选择后的媒体文件的uri数组,此uri数组只能通过临时授权的方式调用photoAccessHelper.getAssets接口去使用,具体使用方式参见用户文件uri介绍中的媒体文件uri的使用方式。 |


Interface: StartScanOptions

扫码参数。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | enableAlbum? | boolean | 是否开启相册,默认true。 | | enableMultiMode? | boolean | 是否开启多码识别,默认false。 | | scanTypes? | ScanType[] | 设置扫码类型,默认扫码ALL(全部码类型)。 |


Enumeration: ScanType

枚举,码类型。

Enumeration Members

| Enumeration Member | Value | Description | | ------ | ------ | ------ | | ALL | 1001 | 以上所有类型,此参数不可用作码图生成 | | AZTEC_CODE | 1 | - | | CODABAR_CODE | 2 | - | | CODE128_CODE | 5 | - | | CODE39_CODE | 3 | - | | CODE93_CODE | 4 | - | | DATAMATRIX_CODE | 6 | - | | EAN13_CODE | 8 | - | | EAN8_CODE | 7 | - | | FORMAT_UNKNOWN | 0 | 未知类型,用于事先不知道要扫哪种类型码的场景,此参数不可用作码图生成 | | ITF14_CODE | 9 | - | | MULTIFUNCTIONAL_CODE | 14 | - | | ONE_D_CODE | 100 | 条形码,包含:CODABAR、CODE 39、CODE 93、CODE 128、EAN-8、EAN-13、ITF-14、UPC-A、UPC-E,此参数不可用作码图生成 | | PDF417_CODE | 10 | - | | QR_CODE | 11 | - | | TWO_D_CODE | 101 | 二维码,包含:AZTEC、DATA MATRIX、PDF417、QR CODE、MULTIFUNCTIONAL CODE,此参数不可用作码图生成 | | UPC_A_CODE | 12 | - | | UPC_E_CODE | 13 | - |


Interface: StartScanResult

扫码结果。

Properties

| Property | Type | Description | | ------ | ------ | ------ | | cornerPoints? | Point[] | 码识别角点位置信息,返回QR Code四个角点。 | | originalValue | string | 码识别内容结果。 | | scanCodeRect? | ScanCodeRect | 码识别位置信息。 | | scanType | ScanType | - |


Interface: ScanCodeRect

Properties

| Property | Type | | ------ | ------ | | bottom | number | | left | number | | right | number | | top | number |


Interface: Point

Properties

| Property | Type | | ------ | ------ | | x | number | | y | number |

说明: 封装了系统 Picker 接口,参数和系统接口参数一致(省略部分不常用参数),枚举类型使用枚举的值类型。 底层实现参考官方文档:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/system-app-startup

约束与限制

设备限制

支持的设备类型:手机、平板、2in1.

支持的手机系统:​​HarmonyOS 5.0.0 Release 及以上版本。

​API 版本 ​​:>= 5.0.0(12)