1- import React from 'react' ;
2- import { Platform , ScrollView , StyleSheet , Text , View } from 'react-native' ;
3- import { examples } from './Examples' ;
1+ import React , { useState } from 'react' ;
2+ import {
3+ Platform ,
4+ SafeAreaView ,
5+ ScrollView ,
6+ StyleSheet ,
7+ Text ,
8+ View ,
9+ } from 'react-native' ;
10+ import { examples , Props as ExamplesTabProperties } from './Examples' ;
11+ import { propsExamples , Props as PropsTabProperties } from './Props' ;
12+ import PagerView from 'react-native-pager-view' ;
13+ import Slider from '@react-native-community/slider' ;
414
515const App = ( ) => {
16+ const [ currentPage , setCurrentPage ] = useState ( 0 ) ;
17+ const titles = [ 'Examples' , 'Props' ] ;
18+
19+ const renderExampleTab = (
20+ sliders : PropsTabProperties [ ] | ExamplesTabProperties [ ] ,
21+ filtered ?: boolean ,
22+ ) => {
23+ return (
24+ < View >
25+ < ScrollView
26+ style = { styles . scrollView }
27+ contentContainerStyle = { styles . container } >
28+ { ( filtered
29+ ? ( sliders as ExamplesTabProperties [ ] ) . filter (
30+ e => ! e . platform || e . platform === Platform . OS ,
31+ )
32+ : sliders
33+ ) . map ( ( e , i ) => (
34+ < View key = { `slider${ i } ` } style = { styles . sliderWidget } >
35+ < Text style = { styles . instructions } > { e . title } </ Text >
36+ { e . render ( ) }
37+ </ View >
38+ ) ) }
39+ </ ScrollView >
40+ </ View >
41+ ) ;
42+ } ;
43+
644 return (
7- < ScrollView
8- style = { styles . scrollView }
9- contentContainerStyle = { styles . container } >
10- < Text testID = "testTextId" style = { styles . title } >
11- { '<Slider />' }
12- </ Text >
13- { examples
14- . filter ( e => ! e . platform || e . platform === Platform . OS )
15- . map ( ( e , i ) => (
16- < View key = { `slider${ i } ` } style = { styles . sliderWidget } >
17- < Text style = { styles . instructions } > { e . title } </ Text >
18- { e . render ( ) }
19- </ View >
20- ) ) }
21- </ ScrollView >
45+ < SafeAreaView style = { styles . homeScreenContainer } >
46+ < View >
47+ < Slider
48+ step = { 1 }
49+ maximumValue = { 3 }
50+ minimumValue = { 0 }
51+ style = { pageViewPositionSlider . style }
52+ value = { currentPage + 1 }
53+ thumbTintColor = { pageViewPositionSlider . thumbColor }
54+ disabled
55+ maximumTrackTintColor = { pageViewPositionSlider . trackColor }
56+ minimumTrackTintColor = { pageViewPositionSlider . trackColor }
57+ />
58+ < Text testID = "testTextId" style = { styles . title } >
59+ { titles [ currentPage ] }
60+ </ Text >
61+ </ View >
62+ < PagerView
63+ initialPage = { 0 }
64+ style = { styles . pagerViewContainer }
65+ onPageSelected = { e => {
66+ setCurrentPage ( e . nativeEvent . position ) ;
67+ } } >
68+ { renderExampleTab ( examples , true ) }
69+ { renderExampleTab ( propsExamples ) }
70+ </ PagerView >
71+ </ SafeAreaView >
2272 ) ;
2373} ;
2474
2575export default App ;
2676
77+ const pageViewPositionSlider = {
78+ trackColor : '#ABABAB' ,
79+ thumbColor : '#1411AB' ,
80+ style : {
81+ width : '100%' ,
82+ } ,
83+ } ;
84+
2785const styles = StyleSheet . create ( {
86+ pagerViewContainer : {
87+ flex : 1 ,
88+ } ,
89+ homeScreenContainer : {
90+ flex : 1 ,
91+ } ,
2892 scrollView : {
2993 backgroundColor : '#F5FCFF' ,
3094 } ,
@@ -34,7 +98,8 @@ const styles = StyleSheet.create({
3498 paddingVertical : 20 ,
3599 } ,
36100 title : {
37- fontSize : 20 ,
101+ fontSize : 30 ,
102+ color : pageViewPositionSlider . thumbColor ,
38103 textAlign : 'center' ,
39104 width : '100%' ,
40105 marginVertical : 20 ,
0 commit comments