Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): close window handling from presentationController’s delegate method #11257

Merged
merged 4 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
- (void)viewWillDisappear:(BOOL)animated;
- (void)viewDidAppear:(BOOL)animated;
- (void)viewDidDisappear:(BOOL)animated;
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController;
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController;

- (void)preferredContentSizeDidChangeForChildContentContainer:(id<UIContentContainer>)container;
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "TiControllerProtocols.h"
#import <UIKit/UIKit.h>

@interface TiViewController : UIViewController {
@interface TiViewController : UIViewController <UIAdaptivePresentationControllerDelegate> {

TiViewProxy *_proxy;
TiOrientationFlags _supportedOrientations;
Expand Down
17 changes: 17 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ - (id)initWithViewProxy:(TiViewProxy *)window
{
if (self = [super init]) {
_proxy = window;
self.presentationController.delegate = self;
[self updateOrientations];
[TiUtils configureController:self withObject:_proxy];
}
Expand Down Expand Up @@ -167,6 +168,22 @@ - (void)viewDidDisappear:(BOOL)animated
[super viewDidDisappear:animated];
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController
{
if ([_proxy conformsToProtocol:@protocol(TiWindowProtocol)]) {
[(id<TiWindowProtocol>)_proxy presentationControllerWillDismiss:presentationController];
}
}

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
{
if ([_proxy conformsToProtocol:@protocol(TiWindowProtocol)]) {
[(id<TiWindowProtocol>)_proxy presentationControllerDidDismiss:presentationController];
}
}
#endif

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
if ([_proxy conformsToProtocol:@protocol(TiWindowProtocol)]) {
Expand Down
16 changes: 15 additions & 1 deletion iphone/TitaniumKit/TitaniumKit/Sources/API/TiWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,21 @@ - (void)viewDidAppear:(BOOL)animated
}
- (void)viewDidDisappear:(BOOL)animated
{
if (isModal && (closing || !forceModal)) {
if (isModal && closing) {
[self windowDidClose];
}
}

- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController
{
if (isModal) {
[self windowWillClose];
}
}

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
{
if (isModal) {
[self windowDidClose];
}
}
Expand Down