If I have the Droar open, but my nav stack is dismissed, then the Droar is stuck open. Droar.isVisible is false because the containerViewController no longer has a parent. (Thus - I assume the “parent” is a VC from the stack I dismissed)
I was able to work around this issue by modifying the dismissalRecognizer.
@objc private static func dismissWindow() {
// if Droar.isVisible {
toggleVisibility(nil)
// }
}
It makes me uncomfortable that I'm toggling without knowing the view state though. Considering I am dismissing 100% of the time for this function, I should call something along the lines of dismiss - not toggle.
While I would love to called dismissWindow from the Droar class, I noticed that those functions are just toggles that check isVisible state (thus they wouldn't work either.
@objc public static func showWindow(completion: (()->Void)? = nil) {
guard !isVisible else { return }
toggleVisibility(completion)
}
@objc public static func dismissWindow(completion: (()->Void)? = nil) {
guard isVisible else { return }
toggleVisibility(completion)
}
So there are a couple issues at play.
- We should change how
isVisible is determined. It shouldn't have anything to do with a parent. It should probably be based on whether or not the Droar VC is included within the frame of the UIWindow.
- Create more explicit
show and dismiss functions. They should not be dependent on any UI state. Just set the VC offset to a reasonable value. Maybe even renamed them to open and close. Toggle should execute these functions based on UI state.
If I have the Droar open, but my nav stack is dismissed, then the Droar is stuck open.
Droar.isVisibleis false because the containerViewController no longer has a parent. (Thus - I assume the “parent” is a VC from the stack I dismissed)I was able to work around this issue by modifying the
dismissalRecognizer.It makes me uncomfortable that I'm toggling without knowing the view state though. Considering I am dismissing 100% of the time for this function, I should call something along the lines of dismiss - not toggle.
While I would love to called
dismissWindowfrom the Droar class, I noticed that those functions are just toggles that check isVisible state (thus they wouldn't work either.So there are a couple issues at play.
isVisibleis determined. It shouldn't have anything to do with a parent. It should probably be based on whether or not the Droar VC is included within the frame of the UIWindow.showanddismissfunctions. They should not be dependent on any UI state. Just set the VC offset to a reasonable value. Maybe even renamed them toopenandclose. Toggle should execute these functions based on UI state.