Skip to content

Commit 5de06a7

Browse files
author
yuji
committed
fixes #3 & supports react-native 0.4.1
1 parent 21cb373 commit 5de06a7

File tree

278 files changed

+4803
-3969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+4803
-3969
lines changed

dist/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
138138
autoplay: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool,
139139
autoplayTimeout: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number,
140140
autoplayDirection: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool,
141-
index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number },
141+
index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number,
142+
renderPagination: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes['function'] },
142143

143144
mixins: [_TimerMixin2['default']],
144145

@@ -268,7 +269,11 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
268269
* @return {object} react-dom
269270
*/
270271
renderPagination: function renderPagination() {
271-
var dots = [];
272+
273+
// By default, dots only show when `total` > 2
274+
if (this.state.total <= 1) {
275+
return null;
276+
}var dots = [];
272277
for (var i = 0; i < this.state.total; i++) {
273278
dots.push(i === this.state.index ? this.props.activeDot || _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].createElement(_React$StyleSheet$Text$View$ScrollView$TouchableOpacity.View, { style: {
274279
backgroundColor: '#007aff',
@@ -409,7 +414,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
409414
}, props),
410415
pages
411416
),
412-
props.showsPagination && total > 1 && this.renderPagination(),
417+
props.showsPagination && (props.renderPagination ? this.props.renderPagination(state.index, state.total) : this.renderPagination()),
413418
this.renderTitle(),
414419
this.props.showsButtons && this.renderButtons()
415420
);

examples/examples/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
138138
autoplay: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool,
139139
autoplayTimeout: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number,
140140
autoplayDirection: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.bool,
141-
index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number },
141+
index: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes.number,
142+
renderPagination: _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].PropTypes['function'] },
142143

143144
mixins: [_TimerMixin2['default']],
144145

@@ -268,7 +269,11 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
268269
* @return {object} react-dom
269270
*/
270271
renderPagination: function renderPagination() {
271-
var dots = [];
272+
273+
// By default, dots only show when `total` > 2
274+
if (this.state.total <= 1) {
275+
return null;
276+
}var dots = [];
272277
for (var i = 0; i < this.state.total; i++) {
273278
dots.push(i === this.state.index ? this.props.activeDot || _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['default'].createElement(_React$StyleSheet$Text$View$ScrollView$TouchableOpacity.View, { style: {
274279
backgroundColor: '#007aff',
@@ -409,7 +414,7 @@ exports['default'] = _React$StyleSheet$Text$View$ScrollView$TouchableOpacity2['d
409414
}, props),
410415
pages
411416
),
412-
props.showsPagination && total > 1 && this.renderPagination(),
417+
props.showsPagination && (props.renderPagination ? this.props.renderPagination(state.index, state.total) : this.renderPagination()),
413418
this.renderTitle(),
414419
this.props.showsButtons && this.renderButtons()
415420
);

examples/examples/swiper_number.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
var React = require('react-native')
2+
var Swiper = require('./')
3+
var {
4+
StyleSheet,
5+
Text,
6+
View,
7+
Image,
8+
} = React
9+
10+
var styles = StyleSheet.create({
11+
wrapper: {
12+
},
13+
slide: {
14+
flex: 1,
15+
justifyContent: 'center',
16+
backgroundColor: 'transparent',
17+
},
18+
text: {
19+
color: '#fff',
20+
fontSize: 30,
21+
fontWeight: 'bold',
22+
},
23+
image: {
24+
flex: 1,
25+
}
26+
})
27+
28+
var renderPagination = function (index, total) {
29+
return (
30+
<View style={{
31+
position: 'absolute',
32+
bottom: -25,
33+
right: 10,
34+
}}>
35+
<Text><Text style={{
36+
color: '#007aff',
37+
fontSize: 20,
38+
}}>{index + 1}</Text>/{total}</Text>
39+
</View>
40+
)
41+
}
42+
43+
var swiper = React.createClass({
44+
render: function() {
45+
return (
46+
<View>
47+
<Swiper style={styles.wrapper} height={240}
48+
renderPagination={renderPagination}
49+
paginationStyle={{
50+
bottom: -23, left: null, right: 10,
51+
}} loop={false}>
52+
<View style={styles.slide} title={<Text numberOfLines={1}>Aussie tourist dies at Bali hotel</Text>}>
53+
<Image style={styles.image} source={{uri: 'http://c.hiphotos.baidu.com/image/w%3D310/sign=0dff10a81c30e924cfa49a307c096e66/7acb0a46f21fbe096194ceb468600c338644ad43.jpg'}} />
54+
</View>
55+
<View style={styles.slide} title={<Text numberOfLines={1}>Big lie behind Nine’s new show</Text>}>
56+
<Image style={styles.image} source={{uri: 'http://a.hiphotos.baidu.com/image/w%3D310/sign=4459912736a85edffa8cf822795509d8/bba1cd11728b4710417a05bbc1cec3fdfc032374.jpg'}} />
57+
</View>
58+
<View style={styles.slide} title={<Text numberOfLines={1}>Why Stone split from Garfield</Text>}>
59+
<Image style={styles.image} source={{uri: 'http://e.hiphotos.baidu.com/image/w%3D310/sign=9a8b4d497ed98d1076d40a30113eb807/0823dd54564e9258655f5d5b9e82d158ccbf4e18.jpg'}} />
60+
</View>
61+
<View style={styles.slide} title={<Text numberOfLines={1}>Learn from Kim K to land that job</Text>}>
62+
<Image style={styles.image} source={{uri: 'http://e.hiphotos.baidu.com/image/w%3D310/sign=2da0245f79ec54e741ec1c1f89399bfd/9d82d158ccbf6c818c958589be3eb13533fa4034.jpg'}} />
63+
</View>
64+
</Swiper>
65+
</View>
66+
)
67+
}
68+
})
69+
70+
module.exports = swiper
71+

examples/index.ios.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var {
77

88
// var swiper = require('./examples/basic')
99
var swiper = require('./examples/swiper')
10+
// var swiper = require('./examples/swiper_number')
1011
// var swiper = require('./examples/phone')
1112

1213
AppRegistry.registerComponent('swiper', () => swiper)

examples/node_modules/react-native/Examples/SampleApp/SampleApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node_modules/react-native/Examples/SampleApp/iOS/AppDelegate.m

Lines changed: 25 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node_modules/react-native/Examples/SampleApp/iOS/main.jsbundle

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/RCTActionSheet.xcscheme

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/vjeux.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/RCTActionSheet.xcscheme

Lines changed: 0 additions & 77 deletions
This file was deleted.

examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)