Commit b7ef3356 authored by Afid's avatar Afid

scroll to category

parent 398b4176
...@@ -181,7 +181,7 @@ class MenuSelection extends React.Component { ...@@ -181,7 +181,7 @@ class MenuSelection extends React.Component {
renderTabBar = ({ item }) => { renderTabBar = ({ item }) => {
return ( return (
<View style={{ flex: 1, height: 270 }}> <View style={{ flex: 1, height: 270 }}>
<TouchableOpacity> <TouchableOpacity onPress={() => this.scrollToIndex(item)}>
<Image style={{ height: 60, width: 60, top: 5 }} source={{ uri: item.image }} /> <Image style={{ height: 60, width: 60, top: 5 }} source={{ uri: item.image }} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
...@@ -277,6 +277,13 @@ class MenuSelection extends React.Component { ...@@ -277,6 +277,13 @@ class MenuSelection extends React.Component {
} }
} }
scrollToIndex = (item) => {
index = _.findIndex(this.props.menu_item, ['name', item.name])
if (index > -1) {
this.flatListRef.scrollToIndex({animated: true, index: index});
}
}
render() { render() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
...@@ -304,6 +311,7 @@ class MenuSelection extends React.Component { ...@@ -304,6 +311,7 @@ class MenuSelection extends React.Component {
/> />
)} )}
keyExtractor={item => item.id} keyExtractor={item => item.id}
ref={(ref) => { this.flatListRef = ref; }}
/> />
)} )}
</View> </View>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment