SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.33k stars 747 forks source link

Fade out dim while the centered view is going out of screen #216

Open Jasperav opened 6 years ago

Jasperav commented 6 years ago

I am using the new feature with the centered view which can be pushed away by the user. It look amazing. However, I have one little request. When the user 'pushes' the view away, the dim mode stays dark (does not fade out) while the view is going out of screen (by the physics).

So the user sees the UIView flying away with a dimmed background. I think for appearance it would be great that the dim mode will fade out while the UIView is flying out out of the screen. Else I think the user just needs to wait a little to long to use the screen again. It looks more like he is forced to see the animation and can not continue using the app.

It looks like it can be partly solved by changing this line: animator.delegate?.hide(animator: animator)that is around line 122 in PhysicsPanHandler.swift. If it gets moved a few lines down under if energy > 200 && speed > 600 {, it looks a bit better. However, now the UIView gets dismissed to soon and makes weird movements.

The further away the user drags the UIView from the middle (starting point), the lighter the dimmode should be, that would look amazing :)

wtmoose commented 6 years ago

Thanks for the suggestion. I'll look into it when I get a chance.

Jasperav commented 6 years ago

@wtmoose Thank you very much. Maybe you can also have a look ad adding the dragging at the eventListeners enum. I got the following issue:

I got a tableview inside the centered view. When the user taps on one of the cells, the cell gets highlighted. If the user now drag around his finger, the tableview will drag with his finger (which is great). However, when the user stops dragging and releases his finger, the tableview bounces back but the cell is still highlighted. If an event case gets added like: startedDrag, endedDrag, I can tackle this problem easy :). I can make a separate issue for this though.

Thanks!

Above issue isn't valid anymore

wtmoose commented 6 years ago

I'm a little confused by your last comment. Scroll views have their own gesture recognizers, so I don't see why you'd want your table view's behavior to depend on SwiftMessages.

Jasperav commented 6 years ago

@wtmoose Nvm, I subclasses a UIButton, with custom touch down events. They were not called anymore after dragging around the centered view. After I added a UIControlEvent with type 'touchCancel', it worked. So last comment isn't valid anymore.