启用了android优化的ViewPager。review by liben。
Showing
3 changed files
with
15 additions
and
9 deletions
@@ -280,7 +280,6 @@ export default class extends Component { | @@ -280,7 +280,6 @@ export default class extends Component { | ||
280 | * @param {object} e native event | 280 | * @param {object} e native event |
281 | */ | 281 | */ |
282 | onScrollEnd = e => { | 282 | onScrollEnd = e => { |
283 | - console.log('onPageSelected'); | ||
284 | // update scroll state | 283 | // update scroll state |
285 | this.internals.isScrolling = false | 284 | this.internals.isScrolling = false |
286 | 285 | ||
@@ -395,7 +394,6 @@ export default class extends Component { | @@ -395,7 +394,6 @@ export default class extends Component { | ||
395 | if (state.dir === 'x') x = diff * state.width | 394 | if (state.dir === 'x') x = diff * state.width |
396 | if (state.dir === 'y') y = diff * state.height | 395 | if (state.dir === 'y') y = diff * state.height |
397 | 396 | ||
398 | - console.log('xxxxx scrollBy diff=' + diff); | ||
399 | if (Platform.OS === 'android') { | 397 | if (Platform.OS === 'android') { |
400 | this.refs.scrollView && this.refs.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff) | 398 | this.refs.scrollView && this.refs.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff) |
401 | } else { | 399 | } else { |
@@ -459,7 +457,7 @@ export default class extends Component { | @@ -459,7 +457,7 @@ export default class extends Component { | ||
459 | 457 | ||
460 | let dots = [] | 458 | let dots = [] |
461 | const ActiveDot = this.props.activeDot || <View style={[{ | 459 | const ActiveDot = this.props.activeDot || <View style={[{ |
462 | - backgroundColor: this.props.activeDotColor || '#007aff', | 460 | + backgroundColor: this.props.activeDotColor || 'white', |
463 | width: 8, | 461 | width: 8, |
464 | height: 8, | 462 | height: 8, |
465 | borderRadius: 4, | 463 | borderRadius: 4, |
@@ -469,7 +467,7 @@ export default class extends Component { | @@ -469,7 +467,7 @@ export default class extends Component { | ||
469 | marginBottom: 3 | 467 | marginBottom: 3 |
470 | }, this.props.activeDotStyle]} /> | 468 | }, this.props.activeDotStyle]} /> |
471 | const Dot = this.props.dot || <View style={[{ | 469 | const Dot = this.props.dot || <View style={[{ |
472 | - backgroundColor: this.props.dotColor || 'rgba(0,0,0,.2)', | 470 | + backgroundColor: this.props.dotColor || 'rgba(237, 237, 237, 0.5)', |
473 | width: 8, | 471 | width: 8, |
474 | height: 8, | 472 | height: 8, |
475 | borderRadius: 4, | 473 | borderRadius: 4, |
@@ -606,7 +604,6 @@ export default class extends Component { | @@ -606,7 +604,6 @@ export default class extends Component { | ||
606 | pages.unshift(total - 1 + '') | 604 | pages.unshift(total - 1 + '') |
607 | pages.push('0') | 605 | pages.push('0') |
608 | } | 606 | } |
609 | - console.log(pages); | ||
610 | 607 | ||
611 | pages = pages.map((page, i) => { | 608 | pages = pages.map((page, i) => { |
612 | if (props.loadMinimal) { | 609 | if (props.loadMinimal) { |
@@ -5,6 +5,7 @@ import ReactNative from 'react-native'; | @@ -5,6 +5,7 @@ import ReactNative from 'react-native'; | ||
5 | import Swiper from 'react-native-swiper'; | 5 | import Swiper from 'react-native-swiper'; |
6 | import YH_Image from '../../../common/components/YH_Image'; | 6 | import YH_Image from '../../../common/components/YH_Image'; |
7 | import Immutable, {Map} from 'immutable'; | 7 | import Immutable, {Map} from 'immutable'; |
8 | +import RecyclerSwiper from '../../../common/recycler-swiper/recyclerswiper' | ||
8 | 9 | ||
9 | const { | 10 | const { |
10 | View, | 11 | View, |
@@ -15,6 +16,8 @@ const { | @@ -15,6 +16,8 @@ const { | ||
15 | Platform, | 16 | Platform, |
16 | } = ReactNative; | 17 | } = ReactNative; |
17 | 18 | ||
19 | +const YH_Swiper = (Platform.OS === 'ios') ? Swiper : RecyclerSwiper; | ||
20 | + | ||
18 | 21 | ||
19 | export default class ImageSlider extends React.Component { | 22 | export default class ImageSlider extends React.Component { |
20 | 23 | ||
@@ -84,7 +87,7 @@ export default class ImageSlider extends React.Component { | @@ -84,7 +87,7 @@ export default class ImageSlider extends React.Component { | ||
84 | ); | 87 | ); |
85 | } else { | 88 | } else { |
86 | return ( | 89 | return ( |
87 | - <Swiper | 90 | + <YH_Swiper |
88 | showsButtons={false} | 91 | showsButtons={false} |
89 | loop={true} | 92 | loop={true} |
90 | autoplay={true} | 93 | autoplay={true} |
@@ -123,7 +126,7 @@ export default class ImageSlider extends React.Component { | @@ -123,7 +126,7 @@ export default class ImageSlider extends React.Component { | ||
123 | </TouchableOpacity> | 126 | </TouchableOpacity> |
124 | ); | 127 | ); |
125 | })} | 128 | })} |
126 | - </Swiper> | 129 | + </YH_Swiper> |
127 | ); | 130 | ); |
128 | } | 131 | } |
129 | } | 132 | } |
@@ -5,6 +5,8 @@ import ReactNative from 'react-native'; | @@ -5,6 +5,8 @@ import ReactNative from 'react-native'; | ||
5 | import Swiper from 'react-native-swiper'; | 5 | import Swiper from 'react-native-swiper'; |
6 | import YH_Image from '../../../common/components/YH_Image'; | 6 | import YH_Image from '../../../common/components/YH_Image'; |
7 | import Immutable, {Map} from 'immutable'; | 7 | import Immutable, {Map} from 'immutable'; |
8 | +import RecyclerSwiper from '../../../common/recycler-swiper/recyclerswiper' | ||
9 | + | ||
8 | 10 | ||
9 | const { | 11 | const { |
10 | View, | 12 | View, |
@@ -13,8 +15,12 @@ const { | @@ -13,8 +15,12 @@ const { | ||
13 | TouchableOpacity, | 15 | TouchableOpacity, |
14 | StyleSheet, | 16 | StyleSheet, |
15 | Dimensions, | 17 | Dimensions, |
18 | + Platform, | ||
16 | } = ReactNative; | 19 | } = ReactNative; |
17 | 20 | ||
21 | +const YH_Swiper = (Platform.OS === 'ios') ? Swiper : RecyclerSwiper; | ||
22 | + | ||
23 | + | ||
18 | export default class Announcement extends React.Component { | 24 | export default class Announcement extends React.Component { |
19 | 25 | ||
20 | constructor(props) { | 26 | constructor(props) { |
@@ -48,7 +54,7 @@ export default class Announcement extends React.Component { | @@ -48,7 +54,7 @@ export default class Announcement extends React.Component { | ||
48 | 54 | ||
49 | <Image style={styles.icon} source={require('../../images/announcement_speaker_icon.png')} /> | 55 | <Image style={styles.icon} source={require('../../images/announcement_speaker_icon.png')} /> |
50 | 56 | ||
51 | - <Swiper | 57 | + <YH_Swiper |
52 | style={styles.banner} | 58 | style={styles.banner} |
53 | horizontal={false} | 59 | horizontal={false} |
54 | showsButtons={false} | 60 | showsButtons={false} |
@@ -73,7 +79,7 @@ export default class Announcement extends React.Component { | @@ -73,7 +79,7 @@ export default class Announcement extends React.Component { | ||
73 | </TouchableOpacity> | 79 | </TouchableOpacity> |
74 | ); | 80 | ); |
75 | })} | 81 | })} |
76 | - </Swiper> | 82 | + </YH_Swiper> |
77 | </View> | 83 | </View> |
78 | ); | 84 | ); |
79 | } | 85 | } |
-
Please register or login to post a comment