Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swipe behavior depending on tap location... #32

Open
davidakoontz opened this issue Feb 4, 2025 · 2 comments
Open

Swipe behavior depending on tap location... #32

davidakoontz opened this issue Feb 4, 2025 · 2 comments

Comments

@davidakoontz
Copy link

I'm seeing this weird behavior. In my list - I get a Delete button if I tap to swipe in the white-space; but I get the Edit button sometimes (I guess if I tap over text content).

Can you help me get consistent behavior?

Image

@davidakoontz
Copy link
Author

davidakoontz commented Feb 4, 2025

Oh - I think I found the issue... had existing code - that also worked quite well with SwipeAction - well, except for the UI weirdness. I've removed this code and then I do NOT get the red Delete button.

//     This onDelete also works in SwipeActions
                    .onDelete { indexSet in
                        withAnimation {
                            indexSet.forEach { index in
                                let stock = sortedEquities[index]
                                account.equities?.forEach({ stockIN in
                                    if stock.id == stockIN.id {
                                        dbContext.delete(stock)
                                    }
                                })
                            }
                        }
                    }

@davidakoontz
Copy link
Author

But now adding in the SwipeAction for a delete button...

                            SwipeAction("Delete", backgroundColor: .red) {
                                print("new Swipe Action: Delete")
                                swipe.state.wrappedValue = .closed
                                dbContext.delete(stock)
                            }
                            .allowSwipeToTrigger()

I get the Button - yet when clicked/tapped - the list does NOT refresh so the ROW stays on the screen, I have to leave the screen and come back to see the ROW has been removed. What magic do I need to get a refresh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant