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

Problem with dragging several cells at same time #9

Closed
HaidenTenno opened this issue Jan 12, 2023 · 9 comments · Fixed by #32
Closed

Problem with dragging several cells at same time #9

HaidenTenno opened this issue Jan 12, 2023 · 9 comments · Fixed by #32
Assignees
Labels
enhancement New feature or request

Comments

@HaidenTenno
Copy link

Hi! Your lib works perfectly for my app, but i noticed strange behavior:

I need to show button only for single cell per time, and SwipeState property works good, but if you swipe multiple cells at same time, then several cells remain open.

RPReplay_Final1673530851.mp4

Is it a bug, or feature?
Thank you!

@c-villain
Copy link
Owner

@HaidenTenno Petr, hi! Thx for sharing! That's interesting question! How do u think the behaviour should be?🤔

@HaidenTenno
Copy link
Author

Something like telegram or whatsapp have in chat list (it's just not possible to swipe several items at same time 😅)

@c-villain
Copy link
Owner

@HaidenTenno sounds good! Actually you can disable multitouch drag or you have to support multitouch, haven't you?...
All in all that's really good notice! I'll try to found some decision)

@HaidenTenno
Copy link
Author

Yeah I don't know why, but that solution does not solve the problem for me =(
Thanks a lot!

@c-villain
Copy link
Owner

@HaidenTenno I've just checked this decision. It works fine!

You should set

UIView.appearance().isMultipleTouchEnabled = false
UIView.appearance().isExclusiveTouch = true

e.g. in onAppear for ur RootView

Check this out!

@HaidenTenno
Copy link
Author

@c-villain Hm, I don't know, but it does nothing for me 😅

The comment below answer said it's about multi touch, not multi drag gesture

I've published a sample app, if you interest:
https://github.com/HaidenTenno/MultipleCellSwipeProblem

@c-villain
Copy link
Owner

@HaidenTenno yeah! Thx for sharing!🤝

@c-villain c-villain added the enhancement New feature or request label Sep 7, 2024
@c-villain c-villain self-assigned this Sep 7, 2024
@c-villain
Copy link
Owner

c-villain commented Sep 9, 2024

@HaidenTenno FYI

Due to SwiftUI philosophy is not quite possible to control multi touching in general and dragging several cells particularly. Anyway we can disable multitouch using UIKit by adding exclusive touch flag ... For this one in the release 0.4.0 of this SPM you can add special view modifier: .allowMultitouching(false) to your view strictly before using swipe actions:

...
YourView(...)
      .allowMultitouching(false) // <= look here
      .addSwipeAction( ...) {
        ...
      }
...

By default this flag is true. Using this modifier will repeat telegram's behaviour where you can drag only one cell during multitouching.

Actually the problem exist only in fullswiping mode. In default mode you can drag several cells but after ending touching only one will be opened.

But as soon as this solution is based on UIKit you can't optimise rendering of YourView with drawingGroup():

...
YourView(...)
      .allowMultitouching(false) // <= look here
      .addSwipeAction( ...) {
        ...
      }
      .drawingGroup() // <=  ❌ DON'T DO THAT
...

You'll definitely get this:

Screenshot 2024-09-09 at 15 22 35

Actually rendering will be optimizing by SwiftUI engine... For full control you can add view modifier .identifier(your id) to YourView(...)

@c-villain
Copy link
Owner

fix in 0.4.0

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

Successfully merging a pull request may close this issue.

2 participants