react-native-sortable-listview icon indicating copy to clipboard operation
react-native-sortable-listview copied to clipboard

FlatList support

Open vTrip opened this issue 7 years ago • 8 comments

Will this move to FlatList instead of ListView ??

FlatList has a handy feature scrollToItem that I would like to use with this library.

vTrip avatar Jun 06 '17 07:06 vTrip

As always, PR Is welcome.

chetstone avatar Jun 18 '17 19:06 chetstone

I like this repository, it's awesome. I hope you will support FlatList :)

Shinichi52 avatar Jun 23 '17 10:06 Shinichi52

Would be nice to see this since newer versions of React Native don't support ListView anymore.

mrbrdo avatar Jul 11 '17 17:07 mrbrdo

@mrbrdo ListView is depreciated not removed, I haven't switched to FlatList because there are still some minor issues with it

nihgwu avatar Aug 07 '17 03:08 nihgwu

@nihgwu i'd love to hear about the issues you have found with FlatList. May help me with future tasks

vTrip avatar Aug 18 '17 00:08 vTrip

Will be uploading my FlatList version of this library to a repo soon. It is a WIP. Would love some assistance with finishing it off. For anyone interested I will post a link here when it is up.

vTrip avatar Aug 29 '17 10:08 vTrip

Hey everyone. I've uploaded to a repo. My version is a WIP.

I need help finishing off functionality. Specifically around the animation for empty row that appears between rows when you are dragging around.

https://github.com/vTrip/FlatListSortable

vTrip avatar Sep 04 '17 03:09 vTrip

@vTrip the scrollToItem can be easly done using current code.

you can use internal layoutMap which contains array of all rows layouts (xPos, yPox, height, width)

Example function:

scrollToIndex = (index, animated) => {
    const y = this._list.layoutMap[index.toString()].y
    this._list.scrollTo({ x: 0, y: y , animated: true });
};

I use it to scroll when adding new element or on load. I'm using setTimeout as i'm waiting for redux to update the store and for list to catch up with the data update.

  componentDidMount() {
    setTimeout(() => {
      this.scrollToIndex(this.props.selectedConfigIdx, false);
    }, 300);
  }

  componentDidUpdate(prevProps, prevState) {
    if (prevProps.selectedConfigIdx !== this.props.selectedConfigIdx && this._areWeDuringAddNewConfig) {
      setTimeout(() => {
        this.scrollToIndex(this.props.selectedConfigIdx, true);
      }, 100);
    }
  }

  _addNewConfig = () => {
    if (this._areWeDuringAddNewConfig) {
      return;
    }

    this._areWeDuringAddNewConfig = true;
    this.props.onConfigAdd();
  };

  scrollToIndex = (index, animated) => {
    const y = this._list.layoutMap[index.toString()].y;
    this._areWeDuringAddNewConfig = false;
    this._list.scrollTo({ x: 0, y: y, animated: animated });
  };

gazickil avatar Mar 19 '18 22:03 gazickil