Skip to content

Commit

Permalink
MMMNavigationStack: fix the issue with pop completion reporting succe…
Browse files Browse the repository at this point in the history
…ss even in case of a failure
  • Loading branch information
aleh committed Apr 16, 2023
1 parent 7cc3940 commit 8e652c4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Sources/MMMCommonUI/LayoutUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ extension UIView {
- the width of the view is limited to the given one so, let say the text does not become too wide on iPad
(if `maxWidth` is `0` or negative, then it's ignored).
*/
open func mmm_addConstraintsHorizontallyCentering(_ view: UIView, minPadding: CGFloat = 0, maxWidth: CGFloat = 0) {
public func mmm_addConstraintsHorizontallyCentering(_ view: UIView, minPadding: CGFloat = 0, maxWidth: CGFloat = 0) {
self.__mmm_addConstraintsHorizontallyCentering(view, minPadding: minPadding, maxWidth: maxWidth)
}

/// Similar to `mmm_addConstraints(horizontallyCenteringView:minPadding:maxWidth:)` but returns constraints
/// without adding them.
open func mmm_constraintsHorizontallyCentering(_ view: UIView, minPadding: CGFloat, maxWidth: CGFloat) -> [NSLayoutConstraint] {
public func mmm_constraintsHorizontallyCentering(_ view: UIView, minPadding: CGFloat, maxWidth: CGFloat) -> [NSLayoutConstraint] {
return self.__mmm_constraintsHorizontallyCentering(view, minPadding: minPadding, maxWidth: maxWidth)
}
}
4 changes: 4 additions & 0 deletions Sources/MMMCommonUIObjC/MMMContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

@import UIKit;

NS_ASSUME_NONNULL_BEGIN

/**
* Auto Layout does not support constraints against groups of items, so this is for the cases a normal UIView is
* typically used as a container for such a group.
Expand All @@ -19,3 +21,5 @@
- (id)initWithFrame:(CGRect)frame NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
4 changes: 0 additions & 4 deletions Sources/MMMCommonUIObjC/MMMNavigation.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ - (nonnull id)initWithHub:(MMMNavigation *)hub
return self;
}

- (void)dealloc {
MMM_LOG_TRACE(@"dealloc");
}

- (NSString *)debugDescription {
return [NSString stringWithFormat:@"<%@:%p original: %@, current: %@>", self.class, self, self.originalPath, self.path];
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/MMMCommonUIObjC/MMMNavigationStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ typedef void (^MMMNavigationStackCompletion)(BOOL success);
* in order to return to the previous navigation step.
*
* Again, navigation steps are not limited to modal view controllers, there can be any entity responsible for the current
* state of the UI which wants to clean it up properly when asked for via the correspondng delegate.
* state of the UI which wants to clean it up properly when asked for via the corresponding delegate.
*
* The optional `controller` parameter might be a view controller corresponding to the new navigation item. This can be used by
* this controller with `popAllAfterController:completion:` method in order to cancel/pop all the navigation items added after it.
Expand Down Expand Up @@ -65,7 +65,7 @@ typedef void (^MMMNavigationStackCompletion)(BOOL success);
* Should perform all the work necessary to pop the corresponding UI navigation item and must call `didPop` method
* on the corresponding item when done.
*
* Note that when the delegate is asked to pop, then all the items on top of it in the stack have been popped aready,
* Note that when the delegate is asked to pop, then all the items on top of it in the stack have been popped already,
* so the delegate should not ask the stack to do it. In fact asking for it and waiting for completion might freeze the popping
* process as pop completion callbacks are called only after all the whole popping process completes.
*/
Expand Down Expand Up @@ -97,7 +97,7 @@ typedef void (^MMMNavigationStackCompletion)(BOOL success);
* Returns YES, if the request to pop was accepted for execution; NO otherwise. The latter means programmers error (such as
* popping while another pop is in progress) and will terminate the app when assertions are enabled.
*
* Note that the completion handler is executed ony if the request has been accepted.
* Note that the completion handler is executed only if the request has been accepted.
*/
- (BOOL)popAllAfterThisItemWithCompletion:(MMMNavigationStackCompletion)completion;

Expand Down
10 changes: 5 additions & 5 deletions Sources/MMMCommonUIObjC/MMMNavigationStack.m
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ - (void)entriesDidChange {
}
}

- (BOOL)controller:(UIViewController *)controller isAnscestorOf:(UIViewController *)child {
- (BOOL)controller:(UIViewController *)controller isAncestorOf:(UIViewController *)child {

if (![child isKindOfClass:[UIViewController class]]) {
return controller == child;
Expand All @@ -271,7 +271,7 @@ - (BOOL)popAllAfterController:(id)controller completion:(MMMNavigationStackCompl

for (NSInteger i = _entries.count - 1; i >= 0; i--) {
MMMNavigationStack_Entry *e = _entries[i];
if ([self controller:e.controller isAnscestorOf:controller]) {
if ([self controller:e.controller isAncestorOf:controller]) {
[e.item popAllAfterThisItemWithCompletion:completion];
return YES;
}
Expand All @@ -291,9 +291,9 @@ - (void)didDeallocItemForEntry:(MMMNavigationStack_Entry *)entry {
}
}

- (void)didPopEntry:(MMMNavigationStack_Entry *)entry successfully:(BOOL)successfuly {
- (void)didPopEntry:(MMMNavigationStack_Entry *)entry successfully:(BOOL)successfully {

if (!successfuly) {
if (!successfully) {

MMM_LOG_TRACE(@"Could not pop %@, failing all pop requests", entry);

Expand Down Expand Up @@ -396,7 +396,7 @@ - (void)didFinishPoppingAllSuccessfully:(BOOL)successfully {
_state = MMMNavigationStackStateIdle;

for (MMMNavigationStack_PopRequest *r in completed) {
r.completion(YES);
r.completion(successfully);
}
}

Expand Down

0 comments on commit 8e652c4

Please sign in to comment.