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

react-native-contact-book

v1.0.4

Published

一个类似于微信通讯录插件,交互顺畅,拓展性高!

Downloads

7

Readme

react-native-contact-book

Props

| props | type | default | desc | | :-------: | :---: | :---: | :------------: | | contactList | array | [] | 通讯录数据,必须有nickname | | headerComponent | node | null | 用于传递顶部导航栏header | | topComponent | node | null | 滚动列表头部扩展组件,要给定高度,否则影响滚动位置计算 | | topComponentHeight | number | 0 | 如果传了头部扩展组件,则必须传该组件的高度 | | titleHeight | number | 25 | 通讯录字母标题的高度 | | itemHeight | number | 60 | 通讯录项的高度 | | letterHeight | number | 20 | 侧边字母栏每个字母的高度 | | activeLetterBg | string | '#125FED' | 侧边字母栏选中字母的背景色 | | activeLetterShowType | string | 'side' | 触摸侧边字母栏滚动时选中字母的显示方式,可选side和center | | showAvatar | boolean | true | 是否显示头像 | | titleStyle | object | {} | 自定义通讯录字母标题样式 | | itemStyle | object | {} | 自定义通讯录项的样式 | | onPressItem | function | ()=>{} | 点击通讯录项事件,返回item数据 |

用法

步骤 1 - 安装

$ npm install react-native-contact-book --save

or

$ yarn add react-native-contact-book

步骤 2 - 引入

import React from 'react';
import {View, Text, TouchableOpacity} from 'react-native';
import Feather from 'react-native-vector-icons/Feather';
import ContactBook from 'react-native-contact-book';
import contactList from '@/assets/contactList.json';

export default function TestContactBookPlugin() {
  const options = {
    contactList: contactList,
    headerComponent: header(),
    topComponent: topEl(),
    topComponentHeight: 80,  //若传了topComponent,这个高度必传
    activeLetterShowType: 'side',
  };

  function header() {
    return (
      <View
        style={{
          height: 60,
          backgroundColor: '#F5F5F5',
          alignItems: 'center',
          justifyContent: 'center',
        }}>
        <Text style={{fontSize: 20, fontWeight: 'bold'}}>通讯录</Text>
      </View>
    );
  }

  function topEl() {
    return (
      <View
        style={{
          height: 80,
          backgroundColor: '#FFF',
          flexDirection: 'row',
          alignItems: 'center',
          justifyContent: 'space-around',
        }}>
        <TouchableOpacity activeOpacity={0.6} style={{alignItems:'center'}}>
          <Feather name="user-plus" color={'#125FED'} size={30} />
          <Text style={{fontSize: 16, marginTop: 5}}>新朋友</Text>
        </TouchableOpacity>
        <TouchableOpacity activeOpacity={0.6} style={{alignItems:'center'}}>
          <Feather name="users" color={'#125FED'} size={30} />
          <Text style={{fontSize: 16, marginTop: 5}}>群聊</Text>
        </TouchableOpacity>
      </View>
    );
  }

  return <ContactBook {...options} />;
}

注意

传入的数据contactList 是array类型,列表项必须要有nickname,如果有头像则添加avatar,格式如下:

[
  {
    "nickname": "路飞",
    "avatar": "https://z3.ax1x.com/2021/05/07/g123h6.jpg",
    "id": "openid1"
  },
  {
    "nickname": "钢铁侠",
    "avatar": "https://z3.ax1x.com/2021/05/07/g121tx.jpg",
    "id": "openid2"
  },

  ...

]