@@ -12,6 +12,8 @@ import {
1212} from 'react-native' ;
1313import Swiper from 'react-native-swiper' ;
1414import DoneButton from './components/DoneButton' ;
15+ import SkipButton from './components/SkipButton' ;
16+ import RenderDots from './components/Dots' ;
1517
1618const windowsWidth = Dimensions . get ( 'window' ) . width ;
1719const windowsHeight = Dimensions . get ( 'window' ) . height ;
@@ -183,75 +185,7 @@ export default class AppIntro extends Component {
183185 } ;
184186 }
185187
186- renderSkipButton = ( isSkipBtnShow , index ) => {
187- if ( Platform . OS === 'ios' ) {
188- return (
189- < Animated . View style = { [ this . styles . btnContainer , {
190- opacity : this . state . skipFadeOpacity ,
191- transform : [ {
192- translateX : this . state . skipFadeOpacity . interpolate ( {
193- inputRange : [ 0 , 1 ] ,
194- outputRange : [ 0 , 15 ] ,
195- } ) ,
196- } ] ,
197- } ] }
198- >
199- < TouchableOpacity
200- style = { this . styles . full }
201- onPress = { isSkipBtnShow ? ( ) => this . props . onSkipBtnClick ( index ) : null }
202- >
203- < Text style = { [ this . styles . controllText , { color : this . props . rightTextColor } ] } > { this . props . skipBtnLabel } </ Text >
204- </ TouchableOpacity >
205- </ Animated . View >
206- )
207- } else {
208- return (
209- < View style = { [ this . styles . btnContainer , {
210- paddingBottom : 5 ,
211- opacity : isSkipBtnShow ? 1 : 0 ,
212- } ] }
213- >
214- < TouchableOpacity
215- style = { this . styles . full }
216- onPress = { isSkipBtnShow ? ( ) => this . props . onSkipBtnClick ( index ) : null }
217- >
218- < Text style = { [ this . styles . controllText , { color : this . props . leftTextColor } ] } > { this . props . skipBtnLabel } </ Text >
219- </ TouchableOpacity >
220- </ View >
221- )
222- }
223- }
224-
225- renderDots = ( dots ) => {
226- if ( this . props . showDots ) {
227- return (
228- < View style = { this . styles . dotContainer } >
229- { dots }
230- </ View >
231- )
232- }
233- }
234-
235188 renderPagination = ( index , total , context ) => {
236- const { activeDotColor, dotColor, rightTextColor, leftTextColor } = this . props ;
237- const ActiveDot = (
238- < View
239- style = { [ this . styles . dotStyle , this . styles . activeDotStyle , { backgroundColor : activeDotColor } ] }
240- />
241- ) ;
242- const Dot = (
243- < View
244- style = { [ this . styles . dotStyle , { backgroundColor : dotColor } ] } />
245- ) ;
246-
247- let dots = [ ] ;
248- for ( let i = 0 ; i < total ; i ++ ) {
249- dots . push ( i === index ?
250- React . cloneElement ( ActiveDot , { key : i } )
251- :
252- React . cloneElement ( Dot , { key : i } )
253- ) ;
254- }
255189 let isDoneBtnShow ;
256190 let isSkipBtnShow ;
257191 if ( index === total - 1 ) {
@@ -269,8 +203,16 @@ export default class AppIntro extends Component {
269203 }
270204 return (
271205 < View style = { [ this . styles . paginationContainer ] } >
272- { this . props . showSkipButton && this . renderSkipButton ( isSkipBtnShow , index ) }
273- { this . renderDots ( dots ) }
206+ { this . props . showSkipButton && < SkipButton
207+ { ...this . props }
208+ { ...this . state }
209+ isSkipBtnShow = { isSkipBtnShow }
210+ styles = { this . styles }
211+ onSkipBtnClick = { ( ) => this . props . onSkipBtnClick ( index ) } /> }
212+ { this . props . showDots && RenderDots ( index , total , {
213+ ...this . props ,
214+ styles : this . styles
215+ } ) }
274216 { this . props . showDoneButton && < DoneButton
275217 { ...this . props }
276218 { ...this . state }
0 commit comments