1.0.3 • Published 6 years ago

react-native-customer-button v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

The final rendering

The final rendering The final rendering-image

Description:


A custom button component that should render nicely on any platform. Supports a minimal level of customization.

Installation:


 npm install --save react-native-custom-button

Example usage:


1.basic

import Button from 'react-native-custom-button';
   ...
   _onPress = () => {
     console.log('onPress');
   }
  render() {
    return (
      <View style={styles.container}>
        <Button onPress={this._onPress} />
      </View>
    );
  }

Props:

PropsExplaintyperequiredefault
onPresshandler to be called when the user taps the buttonfunctionyesno
titletext to display inside the buttonstringyesok
disabledIf true, disable all interactions for this component.boolnofalse
stylebutton style,The style used to modify the buttonobjectno{ backgroundColor: '#43CCFF',height: 30,width: 100,}
textStyleThe style of the text in the buttonobjectno{fontSize: 15, color: '#000000'}
iconbutton icon file resource, resource file introduced by requireImage resourcesnono
iconStyleImage's styleobjectno{}

Examples from props:

 render() {
    return (
      <View style={styles.container}>
        <Text style={{ marginBottom: 10 }}>{this.state.count}</Text>
        <Button
          style={{ marginBottom: 5 }}
          onPress={() => this.setState({ count: this.state.count + 1 })}
        />
        <Button
          title={'cancel'}
          style={{ marginBottom: 5 }}
          onPress={() => this.setState({ count: 'cancel' })}
        />
        <Button
          title={'submit'}
          style={{
            marginBottom: 5,
            backgroundColor: 'gray'
          }}
          onPress={() => this.setState({ count: 'submit' })}
        />
        <Button
          title={'white font'}
          style={{
            marginBottom: 5,
            backgroundColor: 'gray'
          }}
          textStyle={{
            color: '#fff',
            fontSize: 16
          }}
          underlayColor={'#ff0'}
          onPress={() => this.setState({ count: 'submit' })}
        />
        <Button
          title={'white font'}
          style={{
            marginBottom: 5,
            backgroundColor: 'gray'
          }}
          textStyle={{
            color: '#fff',
            fontSize: 16
          }}
          icon={require('../constants/icon_user.png')}
          underlayColor={'#ff0'}
          onPress={() => this.setState({ count: 'submit' })}
        />
      </View>
    );
  }

LICENSE:


MIT