1.1.6 • Published 5 years ago

react-native-ossd-radio-button v1.1.6

Weekly downloads
11
License
MIT
Repository
gitlab
Last release
5 years ago

react-native-ossd-radio-button

Customizable React Native Radio Button

Here you can implement radio button without radio. This library give you customizable radio button. We hope the library can improve user experience and developer experience in developing application with React Native.

alt text

How to install

Use the package manager npm to install react-native-ossd-radio-button.

npm i react-native-ossd-radio-button

Usage

Import RadioList from 'react-native-ossd-radio-button'

import { RadioList } from 'react-native-ossd-radio-button'

create the data for the application to render in a list with this kind of format, the icon format is optional.

const radioDatas = [
    {
        text: "Liverpool",
        iconUrl: require("./assets/icons/unactive_promo.png")
    },
    {
        text: "Manchester United",
        iconUrl: require("./assets/icons/wrong_location.png")
    }
]

Define the state that will save the choosen radio and add this callback function to the radio button

onChangeState(text, radioState) {
    this.setState({ text: text, radioState: radioState })
}

Optional If the option of other is true

changeRadioState(item) {
    this.setState({ item: item })
}
<RadioList
    onChangeState={this.onChangeState.bind(this)}
    radioState={this.state.radioState}
    changeRadioState={this.changeRadioState.bind(this)}
/>

Props for Radio List

PropsTypeFunction
radioStatestringstate that can be retrieved outside the component
radioDatasListList of text data and image (optional) to be shown when component rendered
imageShowbooleanshow/hide the image
widthnumberwidth of radio button item
heightnumberheight of radio button item
activeColorstringColor of the radio button when clicked
defaultColorstringDefault color when radio button not clicked
textColorstringColor of the text of radio button
borderColorstringRadio button border color
borderWidthnumberborder width
justifyContentstringRadio button alignment
imageColorstringTint color of image
otherbooleanshow text option
otherTextstringtext that show in other option
iconUrlTextnumberrequire() image for other option

Callback for Radio List

CallbackFunction
onChangeStatecallback for change the state of choosen value
changeRadioStatecallback for change the state on other value

React Native OSSD Radio Button TODO List

  • Create new repository and first commit
  • Learn about npm and how to publish to it
  • Create npm account
  • Create src and RadioButton Component
  • Create first simple radio button without custom settings
  • Radio Button can show/hide image
  • Publish to npm
  • Radio Button can customize button color
  • Radio Button can customize text color
  • Radio Button can customize line color
  • Radio Button can customize line size
  • Radio Button can resize
  • Radio Button can recenter
  • Radio Button image can tint color
  • Add image to read me
  • Object choosen
  • create new type of radio button with textInput
  • customizable textInput
  • Create documentation