[WIP] Add support to UINavigationController#2
[WIP] Add support to UINavigationController#2barbosa wants to merge 7 commits intomarcelofabri:masterfrom
Conversation
Current coverage is 98.27% (diff: 97.54%)@@ master #2 diff @@
========================================
Files 2 5 +3
Lines 56 174 +118
Methods 0 0
Messages 0 0
Branches 0 0
========================================
+ Hits 56 171 +115
- Misses 0 3 +3
Partials 0 0
|
| [nc postNotificationName:STGViewControllerWasPoppedNotificationName | ||
| object:self.topViewController | ||
| userInfo:@{STGViewControllerPoppingAnimatedKey: @(flag)}]; | ||
| return nil; |
There was a problem hiding this comment.
shouldn't these methods return the view controller that would be popped? It's not a big issue since I've never seen any code using the return code, but who knows ¯_(ツ)_/¯
There was a problem hiding this comment.
Yeah, I thought about that. Wasn't sure if necessary. But it makes sense. I'll do it.
|
I know that it's not probably the main use case in unit tests, but what if there's more than one navigation controller? Should we have a property in I also thought about init'ing it with a |
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
| } | ||
|
|
||
| - (UIViewController * _Nullable )topViewController { |
There was a problem hiding this comment.
(nullable UIViewController *) instead?
There was a problem hiding this comment.
You mean (nonnull UIViewController *)?
af97739 to
66a1f6f
Compare
|
Code coverage went down due to the new return statements. I'll add some unit tests to cover it. |
|
Hey @marcelofabri, I've finally had some time to have a look at it again. Based on your comment...
... I was thinking: Although we swizzle the implementations to send all the notifications we need and capture them, we don't follow the real implementation of the methods. Eg.: - (void)stg_pushViewController:(UIViewController *)viewControllerToPush
animated:(BOOL)flag {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:STGViewControllerWasPushedNotificationName
object:viewControllerToPush
userInfo:@{STGViewControllerPushingAnimatedKey: @(flag)}];
}In the case above, we're just posting the notification but we're not including the given viewController onto the navigation stack. The same logic applies to Because of that, methods returning viewControllers as part of the pop action, would have to know which viewControllers are already in the stack so it can pop the last one. Maybe if we just ignore those values, returning This would allow me to remove the Thoughts? |
|
@barbosa Sorry for taking so long, but I agree we can just return |
This is still a work in progress.
Its idea is to have a similar implementation of the verifier for
UINavigationControllers.Tasks are listed below:
STGNavigationControllerVerifierandUINavigationControllercategorypushViewController:animated:popViewControllerAnimated:popToRootViewControllerAnimated:popToViewController:animated:setViewControllers:animated: