@@ -12,6 +12,8 @@ import {
12
12
} from 'react-native' ;
13
13
import Swiper from 'react-native-swiper' ;
14
14
import DoneButton from './components/DoneButton' ;
15
+ import SkipButton from './components/SkipButton' ;
16
+ import RenderDots from './components/Dots' ;
15
17
16
18
const windowsWidth = Dimensions . get ( 'window' ) . width ;
17
19
const windowsHeight = Dimensions . get ( 'window' ) . height ;
@@ -183,75 +185,7 @@ export default class AppIntro extends Component {
183
185
} ;
184
186
}
185
187
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
-
235
188
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
- }
255
189
let isDoneBtnShow ;
256
190
let isSkipBtnShow ;
257
191
if ( index === total - 1 ) {
@@ -269,8 +203,16 @@ export default class AppIntro extends Component {
269
203
}
270
204
return (
271
205
< 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
+ } ) }
274
216
{ this . props . showDoneButton && < DoneButton
275
217
{ ...this . props }
276
218
{ ...this . state }
0 commit comments