Using React Native 0.47 and yarn, I'm creating an introduction section in which you can swipe through multiple pages and finally get to the home page. So we swipe pages from right to left and move like this: Slide1 -> Slide2 -> Slide3 -> Slide4 -> Home . I have a component that displays a slide page which covers all of the screen. For example, first slide looks like this:
And the code for that is :
class IntroSlide extends Component { render () { return ( <View style={[styles.introSlide, this.props.myStyle]}> <View style={styles.introSlideIconView}> <Icon name={this.props.iconName} size={SLIDE_ICON_SIZE} color="white"/> </View> <View style={styles.introSlideTextView}> <Text style={styles.introSlideTextHeader}> {this.props.headerText} </Text> <Text style={styles.introSlideText}> {this.props.text} </Text> </View> </View> ); } }
And i use it that here:
import AppIntro from 'react-native-app-intro'; // Other imports here export default class Intro extends Component { render() { return ( <View style={{flex: 1}}> <AppIntro showSkipButton={false} nextBtnLabel={<Text style={styles.introButton}>بعدی</Text>} doneBtnLabel={<Text style={styles.introButton}>شروع</Text>} > <IntroSlide iconName="user" myStyle={styles.introSlide1} headerText="DontCare" text= "SomeTextDoesntMatter" /> </AppIntro> </View> ); } }
I'm using react-native-app-intro for this which provides me a very cool swiper but here's the problem:
I have a small View
component with an Icon
(react-native-vector-icons) in it as you can see that i want to rotate as i swipe to the next page. I created a panResponder in IntroSlide
and set it to top View
of it. but my slide can't receive any events. i think some parent views provided by react-native-app-intro
captures all the events and i can still swipe through pages but no console log appears. here's what i did:
class IntroSlide extends Component { constructor(props) { super(props); const panResponder = PanResponder.create({ onStartShouldSetPanResponder: () => true, onPanResponderMove: () => console.log("Moving"), }); this.pan = panResponder; } render () { return ( <View style={[styles.introSlide, this.props.myStyle]} {...this.pan.panHandlers} > <View style={styles.introSlideIconView}> <Icon name={this.props.iconName} size={SLIDE_ICON_SIZE} color="white"/> </View> <View style={styles.introSlideTextView}> <Text style={styles.introSlideTextHeader}> {this.props.headerText} </Text> <Text style={styles.introSlideText}> {this.props.text} </Text> </View> </View> ); } }
I did the same to the View
component with flex: 1
and i had different result. i get console logs as expected but i can't swipe anymore. So how can i swipe through pages while receiving touch events in parent component ? (In other words, i want two different components to receive touch events, and I'm developing for android)
0 comments:
Post a Comment