deanmcpherson / react-native-sortable-listview

Drag drop capable wrapper of ListView for React Native
MIT License
917 stars 235 forks source link

is it possible to add a right icon to click on it for sorting? #85

Closed constantinosergiou closed 7 years ago

constantinosergiou commented 7 years ago

with the method onPress

jackdclark commented 7 years ago

@constantinosergiou yup, just make sure the icon is inside a TouchableHighlight and pass the props.sortHandlers onto that, e.g.

class Example extends Component {
  render () {
    return (
      <SortableListView
        ...
        renderRow={row => <RowComponent data={row} />}
      />
    )
  }
}

class RowComponent extends Component {
  render () {
    return (
      <View>
        <Text>{this.props.data.text}</Text>
        <TouchableHighlight  {...this.props.sortHandlers}>
          <YourIconGoesHere />
        </TouchableHighlight>
      </View>
    )
  }
}
chetstone commented 7 years ago

Closing.. Thanks @jackdcrawford for the help.