Giter Site home page Giter Site logo

danceyoung / react-native-selectmultiple-button Goto Github PK

View Code? Open in Web Editor NEW
82.0 4.0 18.0 72.67 MB

A button (or a grouped buttons) supporting multiple or radio selection by building with React Native. https://github.com/danceyoung/selectmultiplebuttons for Swift.

License: MIT License

JavaScript 62.91% Java 7.03% Objective-C 21.57% Starlark 8.50%
react-native react ios android multiple select radio button tag

react-native-selectmultiple-button's Introduction

React Native SelectMultiple Button

This library is a button (or a grouped buttons) supporting multiple or radio selection by building with React Native. https://github.com/danceyoung/selectmultiplebuttons for Swift.

You can specify any Layout and Style for container view,button view and text through View Style Props, Layout Props and Text Style Props supporting by React Native

Example running in iOS and Android(captured by GIPHY CAPTURE)

captured by GIPHY CAPTURE

Note:Runing a Android Virtual Device is TMDing too large memory eated.

Instruction

  • SelectMultipleButton

  • SelectMultipleGroupButton

SelectMultipleButton

You need to set the props selected as true to highlight button's selected status and manage the data selected through event props singleTap(valueTap) by hard coding yourself.

SelectMultipleGroupButton

You needn't to set these settings like SelectMultipleButton, because these features are build in the SelectMultipleGroupButton. What you do is set the event props singleTap(valueTap) to hold the value tap and the event props onSelectedValuesChange(selectedValues) to hold the array of values selected.

Installation

cd your project root direction

$ npm install react-native-selectmultiple-button --save

Usage

code example

App.js

code snap

import {
  SelectMultipleButton,
  SelectMultipleGroupButton
} from "react-native-selectmultiple-button";

<SelectMultipleButton
  buttonViewStyle={{
    borderRadius: 10,

    height: 40
  }}
  textStyle={{
    fontSize: 15
  }}
  highLightStyle={{
    borderColor: "gray",

    backgroundColor: "transparent",

    textColor: "gray",

    borderTintColor: ios_blue,

    backgroundTintColor: ios_blue,

    textTintColor: "white"
  }}
  multiple={true}
  value={interest}
  selected={this.state.multipleSelectedData.includes(interest)}
  singleTap={valueTap => this._singleTapMultipleSelectedButtons(interest)}
/>;

<SelectMultipleGroupButton
  containerViewStyle={{
    justifyContent: "flex-start"
  }}
  highLightStyle={{
    borderColor: "gray",

    backgroundColor: "transparent",

    textColor: "gray",

    borderTintColor: ios_blue,

    backgroundTintColor: "transparent",

    textTintColor: ios_blue
  }}
  onSelectedValuesChange={selectedValues =>
    this._groupButtonOnSelectedValuesChange(selectedValues)
  }
  group={multipleGroupData}
/>;

Props

SelectMultipleButton

props type required desc
selected bool no Default is false. The selected prop determines whether the button is selected and highlighted
value one of types(string,number) yes Your business key
displayValue one of types(string,number) no Default is == value prop if not set displayValue prop. Displayed as button's text
singleTap function(valueTap) no Handler to be called when the user taps the button. The button's props value is passed as an argument to the callback handler

highLightStyle

Normal or highlighted style, the style object {} contains the following keys.

  • borderColor: PropTypes.string.isRequired---Normal color of button border.

  • backgroundColor: PropTypes.string.isRequired---Normal color of button background.

  • textColor: PropTypes.string.isRequired---Normal color of text.

  • borderTintColor: PropTypes.string.isRequired---Highlighted color of button border.

  • backgroundTintColor: PropTypes.string.isRequired---Highlighted color of button background.

  • textTintColor: PropTypes.string.isRequired--Highlighted color of text.

Default style is

{

borderColor: 'gray',

backgroundColor: 'transparent',

textColor: 'gray',

borderTintColor: ios_blue,

backgroundTintColor: 'transparent',

textTintColor: ios_blue,

}


buttonViewStyle

Style of button view. You can specify any View Style Props.

Default style is

{
  margin: 5,
  borderRadius: 3,
  alignItems: 'center',
  justifyContent: 'center',
  borderWidth: 1
}

textStyle

Style of text. You can specify any Text Style Props

Default style is

{
  textAlign: 'center',
  marginTop: 5,
  marginBottom: 5,
  marginLeft: 10,
  marginRight: 10,
}

SelectMultipleGroupButton

props type required desc
multiple bool no Default is true. The multiple prop determines the grouped buttons are multiple or radio selected
defaultSelectedIndexes array no The indexes array in group of the grouped buttons to be default selected and highlighted
maximumNumberSelected number no Specifies maximum number for selecting buttons, and its smallest value is 2. Only enabled for multiple prop is set true
group array of {value,displayValue} yes Just a plain array, value and displayValue props are akin to value and displayValue props of SelectMultipleButton.
singleTap function(valueTap) no Handler to be called when the user taps the button. The button's props value is passed as an argument to the callback handler.
onSelectedValuesChange function(selectedValues) no Handler to be called when the user taps the button.the array of selected values is passed as an argument to the callback handler.

highLightStyle

Normal or highlighted style, akin to highLightStyle of SelectMultipleButton.


buttonViewStyle

Style of button view, akin to buttonViewStyle of SelectMultipleButton.


textStyle

Style of text, akin to textStyle of SelectMultipleButton.


containerViewStyle

Style of the grouped buttons container view. You can specify any View Style Props and Layout Props.

Default View Style and Layout props is

{
  flexWrap: 'wrap',
  flexDirection: 'row',
  justifyContent: 'center'
}

License

react-native-selectmultiple-button is MIT Licensed.

react-native-selectmultiple-button's People

Contributors

ansidev avatar bilal-abdeen avatar danceyoung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-selectmultiple-button's Issues

defaultSelectedIndexes not working

Hi,
I'm trying to use defaultSelectedIndexes property

my group is: [9]
and my defaultSelectedIndexes: [0]
but when i open the SelectMultipleGroupButton the button is not selected (highlight)

what I'm doing is wrong?

Completely breaks Expo project

I love this library and would like to use it, I am not aware of a good alternative and now unfortunately have to use one. This completely crashes any expo project I use it in. Completely unusable unfortunately. I can provide more information if you are still actively maintaining this, it would be very helpful to have this.

Module naming conflict

After adding react-native-selectmultiple-button to the project the compiler spitted out this error:

jest-haste-map: @providesModule naming collision:
Duplicate module name: react-animated
Paths: /Users/MoorePro/Devs/Project/scaffolding/node_modules/react-native-selectmultiple-button/node_modules/react-native/Libraries/Animated/release/package.json collides with /Users/MoorePro/Devs/Project/scaffolding/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name across two different files.
ERROR
23:11
jest-haste-map: @providesModule naming collision:
Duplicate module name: react-animated
Paths: /Users/MoorePro/Devs/Project/scaffolding/node_modules/react-native-selectmultiple-button/node_modules/react-native/Libraries/Animated/release/package.json collides with /Users/MoorePro/Devs/Project/scaffolding/node_modules/react-native/Libraries/Animated/release/package.json

This error is caused by a @providesModule declaration with the same name across two different files.

I'm running this on expo 2.4.0, nodejs 10.13.0

Row Select Button

It's only support 2 row wrap?

i've 20 multiple data, and the result just showing 2 row

#CMIIW

customizing buttons with images

Hi,

I am using your library very well and it works great. I really love it!

I just wanna know if I could insert an image inside <SelectMultipleButton/> Please let me know!

Thanks in advance! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.