jemise111 / react-native-swipe-list-view

A React Native ListView component with rows that swipe open and closed
https://www.npmjs.com/package/react-native-swipe-list-view
MIT License
2.78k stars 528 forks source link

SwipeRow : Unable to close row programatically. #618

Open yubarajoli77 opened 1 year ago

yubarajoli77 commented 1 year ago

Here is my implementation. I am using this SwipeRow only (Standalone without SwipeListView).

<SwipeRow
      disableRightSwipe
      onRowPress={onPress}
      onRowOpen={onRowOpen}
      useNativeDriver
      rightOpenValue={-160}>
      <BackView
        isCompleted={Boolean(status.isDone)}
        isProcessing={processing}
      />
      {children}
    </SwipeRow>
const onRowOpen = async (toValue: number) => {
    setProcessing(true);
    if (status.isDone) {
      await unmark();
    } else {
      await mark();
    }
    setProcessing(false);
  };

Now I just want to close the Row automatically after successful execution of "mark" or "unmark" async function. How can I close that opened row programmatically?

You can see the screen recording below. I have to close it manually by swiping right.

https://user-images.githubusercontent.com/31098546/231096683-0097a1f6-a853-464f-be49-fa163898bf96.mov

baargava commented 1 year ago

did u solve the issue?

mmaass commented 3 months ago

For anyone wondering this is the gardening app Plantura. :D Can recommend.

@baargava I've just found the view in question in the app and the SwipeRow isn't there, so i guess no solution was found or the idea as a whole was scrapped.

as for a solution, use ref + closeRow(). see here

yubarajoli77 commented 3 months ago

@mmaass Thank you so much for recommending the Plantura gardening app :). We're thrilled to hear that you're enjoying it :D. Regarding the SwipeRow feature, the idea has been put on hold till now.

For those looking for a solution in similar scenarios, you can use useRef as mentioned by @mmaass