How to detect if Dodo is showing for a specific view?
Closed this issue · 8 comments
Thanks
Hi @timbroder, good question. There is no way of doing it currently, unfortunately. Feel free to submit a pull request if you want to add it. It could be a property called view.dodo.visible
. The presence of a DodoToolbar can be detected the following way:
for view in superview.subviews {
if let existingToolbar = view as? DodoToolbar {
// present
return
}
}
// not present
got it thanks. I was looking for something that exposed exactly that.
Could also be done by checking if the DodoToolbar has a superView? (Just looking at what hide
does)
I'll try to get a PR together in the next few days
Great, thank you for your help.
Yes, checking for superview would work. However, I decided not to create a property for the toolbar object. Therefore, the only place to get it is from the subviews
array of the UIView object. There is only one place to look which makes the logic simpler.
There is actually a property called toolbar
in Dodo class that returns the toolbar object. It can be used to check if a toolbar is present. If this property returns nil, it means there is no toolbar.
private var toolbar: DodoToolbar? {
get {
return superview.subviews.filter { $0 is DodoToolbar }.map { $0 as! DodoToolbar }.first
}
}
There is one nuance. A toolbar is usually hidden with animation. So, if we call the hide
method the toolbar is still on screen until the animation is finished. And until the animation is finished, the new view.dodo.visible
property will return true
. Just something to be aware of.
Hi just wanted to update expectations. Still fully intend to write this PR, but it's looking like "next couple of week" instead of days.
Sorry!
No worries.
Closing the issue. Feel free to reopen if needed.
Thanks, sorry for being delinquent on this
It's ok, no stress. :)