BastiaanJansen / toast-swift

Customizable Swift Toast view built with UIKit. 🍞
MIT License
467 stars 77 forks source link

Toast bottom direction broke swipe to remove #28

Closed lkuraer closed 9 months ago

lkuraer commented 1 year ago

Great library. The problem is when enablePanToClose = true and direction = .bottom, when try to swipe from top to bottom - the whole app is trying to collapse (default for ios). Can you, please, add direction of swiping too?

Nikoloutsos commented 1 year ago

Hi @lkuraer, thanks for reporting this. When I find some time I'll take a look at it. PRs are always welcome 😄

Nikoloutsos commented 1 year ago

@lkuraer May you please share your code with us to reproduce the issue? I made a demo app with the following code and works as expected:

class ViewController: UIViewController {
    var toast: Toast!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.view.backgroundColor = .gray
        self.toast = Toast.text("Safari pasted from Noted", config: .init(direction: .bottom, enablePanToClose: true))
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            self.toast.show()
        }
    }
}

https://user-images.githubusercontent.com/14034942/214968314-c76a35b6-ba5d-4a95-82f2-ff1154b99c93.mp4

lkuraer commented 1 year ago

Thank for your response , @Nikoloutsos , I beleive, you should try on real device. Actually there are two problems, please check attached screencast:

code is the same:

Screenshot 2023-01-27 at 12 53 29

https://user-images.githubusercontent.com/17291231/215035719-562878e3-7c5f-4a82-81ad-09d2429157da.mp4

the first problem, is that app tries to hide when try to drag toast, that's why I think you should add this to config which swap direction to add (from bottom to top and vice-verse).

and the second problem is the same as in opened issue https://github.com/BastiaanJansen/toast-swift/issues/18

when try to pan to remove - library broke and toast can't be removed at all.

BastiaanJansen commented 1 year ago

The app hides because Reachability is enabled. I guess Reachability is by default disabled, so it works as expected on the simulator. Maybe disable Reachability on your phone (or enable in the simulator) to definitely say that is the problem?

@Nikoloutsos is already looking into #18 :).

lkuraer commented 1 year ago

@BastiaanJansen you are right, when disable Reachability in settings, pan works. But I think there is a good variant to add swipe direction for remove, what do you think?

BastiaanJansen commented 1 year ago

I agree

Nikoloutsos commented 1 year ago

@lkuraer @BastiaanJansen Just to make things clear because I am a little confused. At this moment, as shown in the ☝️ video, when developer uses the direction of bottom he has to drag from top-to-bottom in order to dismiss. And vice versa when direction of top is used he has to drag from bottom-to-top in order to dismiss. I think this is the intuitive behaviour of how the panToDismiss works.

So what you're suggesting is to give the ability to select either top-to-bottom or bottom-to-top pag gesture despite the toast direction? 🤔

lkuraer commented 1 year ago

Absolutely correct

lkuraer commented 1 year ago

@Nikoloutsos have you had a time to look into this? Also, the problem with enabling autohide + swipe to remove has come back. Toast does not disappear if try to swipe.

Nikoloutsos commented 1 year ago

@lkuraer At this moment I don't have much free time to look into it.

BastiaanJansen commented 10 months ago

@lkuraer the autohide + swipe bug should be resolved now.

lkuraer commented 10 months ago

@BastiaanJansen it works now, thanks! But the main issue is still exist. Selecting toast appear at top + swipe to close from bottom to top - works great. But when we select .bottom appearance, library supposes that we hide using top-to-bottom swipe, and this causes whole app to collide. Can you add selection of swipe-to-remove direction? I think this will be the final feature that will make this library must have, when you need simple toast in any simple app.

BastiaanJansen commented 10 months ago

Yes I am working on an implementation. See dev branch for details.

BastiaanJansen commented 9 months ago

@lkuraer version 2.0 is released with a swipe direction option!