React-native-swipe-list-view: LANDSCAPE View swipebar size issue

Created on 22 Dec 2016  路  2Comments  路  Source: jemise111/react-native-swipe-list-view

@jemise111 This works like a charm but In the props we put the amount of pixels for left or right swipe but after the orientation of device the pixels changed and the sizes should be changed.is their a way to capture this functionality easily without working with orientation change? thanks in advance

Most helpful comment

Hey @asela-wijesinghe, as a small perf optimization the layout is only calculated once by default. There is a prop you can pass to the SwipeListView called recalculateHiddenLayout={true} which I think should solve your issue. It should look like so:

<SwipeListView
    recalculateHiddenLayout={true}
    dataSource={this.ds.cloneWithRows(this.state.listViewData)}
    renderRow={ data => (
        <TouchableHighlight
            onPress={ _ => console.log('You touched me') }
            style={styles.rowFront}
            underlayColor={'#AAA'}
        >
            <View>
                <Text>I'm {data} in a SwipeListView</Text>
            </View>
        </TouchableHighlight>
    )}
    renderHiddenRow={ (data, secId, rowId, rowMap) => (
        <View style={styles.rowBack}>
            <Text>Left</Text>
            <View style={[styles.backRightBtn, styles.backRightBtnLeft]}>
                <Text style={styles.backTextWhite}>Right</Text>
            </View>
            <TouchableOpacity style={[styles.backRightBtn, styles.backRightBtnRight]} onPress={ _ => this.deleteRow(secId, rowId, rowMap) }>
                <Text style={styles.backTextWhite}>Delete</Text>
            </TouchableOpacity>
        </View>
    )}
    leftOpenValue={75}
    rightOpenValue={-150}
/>

After passing that prop it worked perfectly for me:

http://g.recordit.co/GsZ4vwkmsZ.gif

Let me know if this does the trick for you, thanks!

All 2 comments

Hey @asela-wijesinghe, as a small perf optimization the layout is only calculated once by default. There is a prop you can pass to the SwipeListView called recalculateHiddenLayout={true} which I think should solve your issue. It should look like so:

<SwipeListView
    recalculateHiddenLayout={true}
    dataSource={this.ds.cloneWithRows(this.state.listViewData)}
    renderRow={ data => (
        <TouchableHighlight
            onPress={ _ => console.log('You touched me') }
            style={styles.rowFront}
            underlayColor={'#AAA'}
        >
            <View>
                <Text>I'm {data} in a SwipeListView</Text>
            </View>
        </TouchableHighlight>
    )}
    renderHiddenRow={ (data, secId, rowId, rowMap) => (
        <View style={styles.rowBack}>
            <Text>Left</Text>
            <View style={[styles.backRightBtn, styles.backRightBtnLeft]}>
                <Text style={styles.backTextWhite}>Right</Text>
            </View>
            <TouchableOpacity style={[styles.backRightBtn, styles.backRightBtnRight]} onPress={ _ => this.deleteRow(secId, rowId, rowMap) }>
                <Text style={styles.backTextWhite}>Delete</Text>
            </TouchableOpacity>
        </View>
    )}
    leftOpenValue={75}
    rightOpenValue={-150}
/>

After passing that prop it worked perfectly for me:

http://g.recordit.co/GsZ4vwkmsZ.gif

Let me know if this does the trick for you, thanks!

@jemise111
It worked Thank You :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ramisalem picture ramisalem  路  5Comments

bohdan145 picture bohdan145  路  6Comments

grigy picture grigy  路  4Comments

mohitmishra22 picture mohitmishra22  路  6Comments

nzrin picture nzrin  路  5Comments