3333 Image
3434} = ReactNative ;
3535
36- exports . displayName = ( undefined : ? string ) ;
36+ exports . displayName = 'ScrollViewExample' ;
3737exports . title = '<ScrollView>' ;
3838exports . description = 'Component that enables scrolling through child components' ;
3939exports . examples = [
@@ -50,7 +50,7 @@ exports.examples = [
5050 onScroll = { ( ) => { console . log ( 'onScroll!' ) ; } }
5151 scrollEventThrottle = { 200 }
5252 style = { styles . scrollView } >
53- { THUMBS . map ( createThumbRow ) }
53+ { THUMB_URLS . map ( createThumbRow ) }
5454 </ ScrollView >
5555 < TouchableOpacity
5656 style = { styles . button }
@@ -69,26 +69,37 @@ exports.examples = [
6969 title : '<ScrollView> (horizontal = true)' ,
7070 description : 'You can display <ScrollView>\'s child components horizontally rather than vertically' ,
7171 render : function ( ) {
72- var _scrollView : ScrollView ;
72+
73+ function renderScrollView ( title : string , addtionalStyles : StyleSheet ) {
74+ var _scrollView : ScrollView ;
75+ return (
76+ < View style = { addtionalStyles } >
77+ < Text style = { styles . text } > { title } </ Text >
78+ < ScrollView
79+ ref = { ( scrollView ) => { _scrollView = scrollView ; } }
80+ automaticallyAdjustContentInsets = { false }
81+ horizontal = { true }
82+ style = { [ styles . scrollView , styles . horizontalScrollView ] } >
83+ { THUMB_URLS . map ( createThumbRow ) }
84+ </ ScrollView >
85+ < TouchableOpacity
86+ style = { styles . button }
87+ onPress = { ( ) => { _scrollView . scrollTo ( { x : 0 } ) ; } } >
88+ < Text > Scroll to start</ Text >
89+ </ TouchableOpacity >
90+ < TouchableOpacity
91+ style = { styles . button }
92+ onPress = { ( ) => { _scrollView . scrollToEnd ( { animated : true } ) ; } } >
93+ < Text > Scroll to end</ Text >
94+ </ TouchableOpacity >
95+ </ View >
96+ ) ;
97+ }
98+
7399 return (
74100 < View >
75- < ScrollView
76- ref = { ( scrollView ) => { _scrollView = scrollView ; } }
77- automaticallyAdjustContentInsets = { false }
78- horizontal = { true }
79- style = { [ styles . scrollView , styles . horizontalScrollView ] } >
80- { THUMBS . map ( createThumbRow ) }
81- </ ScrollView >
82- < TouchableOpacity
83- style = { styles . button }
84- onPress = { ( ) => { _scrollView . scrollTo ( { x : 0 } ) ; } } >
85- < Text > Scroll to start</ Text >
86- </ TouchableOpacity >
87- < TouchableOpacity
88- style = { styles . button }
89- onPress = { ( ) => { _scrollView . scrollToEnd ( { animated : true } ) ; } } >
90- < Text > Scroll to end</ Text >
91- </ TouchableOpacity >
101+ { renderScrollView ( 'LTR layout' , { direction : 'ltr' } ) }
102+ { renderScrollView ( 'RTL layout' , { direction : 'rtl' } ) }
92103 </ View >
93104 ) ;
94105 }
@@ -101,49 +112,59 @@ class Thumb extends React.Component {
101112
102113 render ( ) {
103114 return (
104- < View style = { styles . button } >
105- < Image style = { styles . img } source = { { uri : this . props . uri } } />
115+ < View style = { styles . thumb } >
116+ < Image style = { styles . img } source = { this . props . source } />
106117 </ View >
107118 ) ;
108119 }
109120}
110121
111- var THUMBS = [ 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851549_767334479959628_274486868_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851561_767334496626293_1958532586_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851579_767334503292959_179092627_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851589_767334513292958_1747022277_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851563_767334559959620_1193692107_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851593_767334566626286_1953955109_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851591_767334523292957_797560749_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851567_767334529959623_843148472_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851548_767334489959627_794462220_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851575_767334539959622_441598241_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851573_767334549959621_534583464_n.png' , 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851583_767334573292952_1519550680_n.png' ] ;
112- THUMBS = THUMBS . concat ( THUMBS ) ; // double length of THUMBS
113- var createThumbRow = ( uri , i ) => < Thumb key = { i } uri = { uri } /> ;
122+ var THUMB_URLS = [
123+ require ( './Thumbnails/like.png' ) ,
124+ require ( './Thumbnails/dislike.png' ) ,
125+ require ( './Thumbnails/call.png' ) ,
126+ require ( './Thumbnails/fist.png' ) ,
127+ require ( './Thumbnails/bandaged.png' ) ,
128+ require ( './Thumbnails/flowers.png' ) ,
129+ require ( './Thumbnails/heart.png' ) ,
130+ require ( './Thumbnails/liking.png' ) ,
131+ require ( './Thumbnails/party.png' ) ,
132+ require ( './Thumbnails/poke.png' ) ,
133+ require ( './Thumbnails/superlike.png' ) ,
134+ require ( './Thumbnails/victory.png' ) ,
135+ ] ;
136+
137+ THUMB_URLS = THUMB_URLS . concat ( THUMB_URLS ) ; // double length of THUMB_URLS
138+
139+ var createThumbRow = ( uri , i ) => < Thumb key = { i } source = { uri } /> ;
114140
115141var styles = StyleSheet . create ( {
116142 scrollView : {
117- backgroundColor : '#6A85B1 ' ,
143+ backgroundColor : '#eeeeee ' ,
118144 height : 300 ,
119145 } ,
120146 horizontalScrollView : {
121- height : 120 ,
122- } ,
123- containerPage : {
124- height : 50 ,
125- width : 50 ,
126- backgroundColor : '#527FE4' ,
127- padding : 5 ,
147+ height : 106 ,
128148 } ,
129149 text : {
130- fontSize : 20 ,
131- color : '#888888' ,
132- left : 80 ,
133- top : 20 ,
134- height : 40 ,
150+ fontSize : 16 ,
151+ fontWeight : 'bold' ,
152+ margin : 5 ,
153+ textAlign : 'left' ,
135154 } ,
136155 button : {
137- margin : 7 ,
156+ margin : 5 ,
138157 padding : 5 ,
139158 alignItems : 'center' ,
140- backgroundColor : '#eaeaea ' ,
159+ backgroundColor : '#cccccc ' ,
141160 borderRadius : 3 ,
142161 } ,
143- buttonContents : {
144- flexDirection : 'row' ,
145- width : 64 ,
146- height : 64 ,
162+ thumb : {
163+ margin : 5 ,
164+ padding : 5 ,
165+ backgroundColor : '#cccccc' ,
166+ borderRadius : 3 ,
167+ minWidth : 96 ,
147168 } ,
148169 img : {
149170 width : 64 ,
0 commit comments