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-dropdown-button

v1.1.0

Published

A simple dropdown menu button for react native

Downloads

5

Readme

#react-native-menu-button dropdown menu button for react native

1.0.0 版本更新

fixed issue https://github.com/KenHky/react-native-menu-button/issues/4

解决了转屏后menu计算位置不对的问题。

重构了一些代码,语法更符合规范, 请使用 0.25+ 版本的react native。

api 没有变化。

简介

这是一个 react-native 的 menubutton 组件,支持 iOS 和 android,但是安卓的样式和 iOS 的有一些差异。

| iOS | Android | | --- | ------- | | | |

API

buttonStyle:按钮的样式,可覆盖默认样式。

optionsStyle:menu 组的样式,可覆盖默认的样式。

menuGroup:menu 数据,格式为[{key:num or str,value:num or str,text:str,hide:Boolean}]。value 为点击发生后传的值,text 为显示的字符串,hide 为 true 时隐藏该条数据,默认为 false。

onSelect:选择一个选项后的回调,参数为 menu 数据的 value 值。

button:可定制按钮,默认为{(<Text style={{ fontSize: 20,textAlign:"right" }}>⋮)} (0.1.0新增)。

optionStyle: menu items style,每个 menu item 的样式。(0.2.0新增)

selectedOptionStyle: menu item style when selected,选择后的 item 样式,默认无。(0.2.0新增)

optionTextStyle: menu item text style ,每个 menu item text 的样式,默认无。(0.3.0新增)

selectedOptionTextStyle: menu item text style when selected,选择后的 item text 的样式,默认无。(0.3.0新增)

demo

cd demo
npm install
react-native run-android
react-native run-ios

安装

npm install react-native-menu-button ——save

###使用

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import MenuButton from 'react-native-menu-button'

export default class rndemo extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selectData:""
    };
  }
  _handleOnSelect (value) {
    this.setState({selectData:value})
  }
  render() {
    menuGroup= [
      {key:"0",value:"menu1",text:"menu1"},
      {key:"1",value:"menu2",text:"menu2"},
      {key:"2",value:"菜单3",text:"菜单3"},
      {key:"3",value:"菜单4",text:"菜单4"},
    ]
    return (
      <View>
        <View style={styles.top}>
          <MenuButton  
            buttonStyle={[styles.rightButton]} 
            menuGroup={menuGroup}
            onSelect={this._handleOnSelect.bind(this)} 
            optionSelectedStyle={{backgroundColor:"red"}}
          />
        </View>
        <Text style={styles.text}>{`select ${this.state.selectData}`}</Text>
      </View>
    )
  }
}

const styles = StyleSheet.create({
  top:{
    backgroundColor: '#FFFFFF',
    paddingTop: 20,
    top: 0,
    height: 64,
    right: 0,
    left: 0,
    borderBottomWidth: 0.5,
    borderBottomColor: '#828287',
    position: 'relative',
  },
  text:{
    marginTop:20,
  },
  rightButton: {
    width: 100,
    height: 37,
    position: 'absolute',
    bottom: 8,
    right: 2,
    padding: 8
  },
})

AppRegistry.registerComponent('rndemo', () => rndemo)

###协议 MIT