leecade / leecade/react-native-swiper

Can not slide next page dynamically from external view.

Open
#855 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.5k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

Which OS ?

Android - 7.1.0

Version
  • react-native-swiper: ^1.5.13
  • react-native: 0.56

I have set two images at the center|bottom and tried to swipe to next screen on that click.

export default class SwiperView extends Component {

constructor(props) {
    super(props);
    this.state = {
        indexOfPage: 0
    };
    updateScreens = updateScreens.bind(this)
}

render() {
    
    return (
        <View style={{flex:1}}>

            <Swiper style={styles.wrapper}
                    showsButtons={false}
                    showsPagination={false}
                    loop={false}
                    index={this.state.indexOfPage}
                    scrollEnabled={false}>
                
                <View style={styles.slide1}>
                    <Text style={styles.text}> {this.state.indexOfPage} </Text>
                </View>
    
                <View style={styles.slide2}>
                    <Text style={styles.text}>Beautiful</Text>
                </View>
    
                <View style={styles.slide3}>
                    <Text style={styles.text}>And simple</Text>
                </View>

            </Swiper>
            
            <View
                style={{height:'20%', flexDirection:'row',
                    position:'absolute', bottom:0,
                    justifyContent:'center', alignSelf:'center'}}>
    
                <TouchableOpacity
                    style={{width:48, height:48, marginRight:16}}
                    activeOpacity = { .9 }
                    onPress={() => **updateScreens**(false)}>
        
                    <Image
                        source={require('../images/arrow_left.png')}/>
    
                </TouchableOpacity>
    
                <TouchableOpacity
                    style={{width:48, height:48}}
                    activeOpacity = { .9 }
                    onPress={() => **updateScreens**(true)}>
        
                    <Image
                        source={require('../images/arrow_right.png')}/>
    
                </TouchableOpacity>

            </View>
            
        </View>
    );
}

}

function updateScreens(isNext) {
var index = this.state.indexOfPage;
if (isNext) {
if (index <= 1) {
index += 1
} else {
return
}
} else {
if (index > 0) {
index -= 1
} else {
return
}
}
this.setState({ indexOfPage: index})
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown SwiperView component, focusing on the external TouchableOpacity handlers and updateScreens. Read how react-native-swiper handles the index and scrollEnabled props, then verify that the external buttons move between the three displayed views in both directions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.