forked from shadowfacts/Tusker
When routing the SplitNav responder chain through the root VC, go as deep into it as possible
Makes keyboard shortcuts from, e.g., TimelineVC accessible when the root is TimelinesPageVC See #302
This commit is contained in:
parent
1a64bfcef8
commit
cca2a03b2f
|
@ -198,3 +198,9 @@ extension SegmentedPageViewController: StatusBarTappableViewController {
|
||||||
return .continue
|
return .continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension SegmentedPageViewController: NestedResponderProvider {
|
||||||
|
var innerResponder: UIResponder? {
|
||||||
|
currentViewController
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -283,7 +283,11 @@ private class SplitSecondaryNavigationController: EnhancedNavigationViewControll
|
||||||
// ordinarily, the next responder in the chain would be the SplitNavigationController's view
|
// ordinarily, the next responder in the chain would be the SplitNavigationController's view
|
||||||
// but that would bypass the VC in the root nav, so we reroute the repsonder chain to include it
|
// but that would bypass the VC in the root nav, so we reroute the repsonder chain to include it
|
||||||
// first seems to be nil when using the view debugger for some reason, so in that case, defer to super
|
// first seems to be nil when using the view debugger for some reason, so in that case, defer to super
|
||||||
owner.viewControllers.first?.view ?? super.next
|
if let root = owner.viewControllers.first {
|
||||||
|
return root.innermostResponder() ?? super.next
|
||||||
|
} else {
|
||||||
|
return super.next
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func configureSecondarySplitCloseButton(for viewController: UIViewController) {
|
private func configureSecondarySplitCloseButton(for viewController: UIViewController) {
|
||||||
|
@ -300,3 +304,17 @@ private class SplitSecondaryNavigationController: EnhancedNavigationViewControll
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protocol NestedResponderProvider {
|
||||||
|
var innerResponder: UIResponder? { get }
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UIResponder {
|
||||||
|
func innermostResponder() -> UIResponder? {
|
||||||
|
if let nestedProvider = self as? NestedResponderProvider {
|
||||||
|
return nestedProvider.innerResponder?.innermostResponder() ?? self
|
||||||
|
} else {
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue