1.0.1 • Published 6 years ago

react-native-whc-banner v1.0.1

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

react-native-whc-banner

A react native module to banner auto play loop component, it works on iOS and Android.

release PRs Welcome NPM version License MIT 语言 中文

Content

Installation

  • 1.Run npm i react-native-whc-banner --save
  • 2.import Banner, {IndicaterAlign, IndicaterType} from 'react-native-whc-banner'

Demo

Screenshots

Getting started

Add react-native-whc-banner to your js file.

import Banner, {IndicaterAlign, IndicaterType} from 'react-native-whc-banner'

Your component's render method, use Banner:

 render() {
         return (
             <Banner style = {styles.banner}>
                 <View><Image style = {styles.img} source = {images[0]}/></View>
                 <View><Image style = {styles.img} source = {images[1]}/></View>
                 <View><Image style = {styles.img} source = {images[2]}/></View>
             </Banner>
         );
 }

Basic usage

render() {
        return (
            <Banner style = {styles.banner}
                    indicaterType = {IndicaterType.circle}>
                <View><Image style = {styles.img} source = {images[0]}/></View>
                <View><Image style = {styles.img} source = {images[1]}/></View>
                <View><Image style = {styles.img} source = {images[2]}/></View>
            </Banner>
        );
    }

Custom Banner

render() {
        return (
            <Banner style = {styles.banner}
                    indicaterStyle = {styles.indicater}
                    dotStyle = {styles.dot}
                    currentDotStyle = {styles.currentDot}
                    circleStyle = {styles.circle}
                    numberStyle = {styles.number}
                    titleStyle = {styles.title}
                    titles = {['react-native banner', 'ios native banner', 'android native banner']}
                    autoPlay = {true}
                    autoLoop = {true}
                    indicaterType = {IndicaterType.dot}
                    indicaterAlign = {IndicaterAlign.center}
                    duration = {5000}
                    >
                <View><Image style = {styles.img} source = {images[0]}/></View>
                <View><Image style = {styles.img} source = {images[1]}/></View>
                <View><Image style = {styles.img} source = {images[2]}/></View>
            </Banner>
        );
    }

API

IndicaterTypeDescription
IndicaterType.noneThere is no indicator
IndicaterType.circleCircle number indicator
IndicaterType.numberNumber indicator
IndicaterType.titleTitle text indicator
IndicaterType.number_titleNumber and title text indicator
IndicaterType.dotDot indicator
IndicaterAlignDescription
IndicaterAlign.leftIndicator element left alignment
IndicaterAlign.centerIndicator element center alignment
IndicaterAlign.rightIndicator element right alignment
PropsTypeOptionalDefaultDescription
styleViewPropTypes.styletrue{}Custom banner style
indicaterStyleViewPropTypes.styletrue{}Custom banner indicater style
dotStyleViewPropTypes.styletrue{}Custom indicater for dot style
currentDotStyleViewPropTypes.styletrue{}Custom indicater current dot style
circleStyleViewPropTypes.styletrue{}Custom indicater for circle style
numberStyleText.propTypes.styletrue{}Custom indicater for number style
titleStyleText.propTypes.styletrue{}Custom indicater for title style
titlesPropTypes.arraytrue[]When indicater for title type show title
autoPlayPropTypes.booltruetrueIs auto play for banner
autoLoopPropTypes.booltruetrueIs auto loop for banner
indicaterTypeIndicaterTypetrueIndicaterType.dotCustom indicater type
indicaterAlignIndicaterAligntrueIndicaterAlign.centerCustom indicater align type
durationPropTypes.numbertrue5000Custom banner auto play duration

Contribution

Issues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.

Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.


MIT Licensed