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)(8_2_X): can not show fullscreen modal windows anymore #11268

Merged
merged 10 commits into from
Oct 14, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
- (void)viewWillDisappear:(BOOL)animated;
- (void)viewDidAppear:(BOOL)animated;
- (void)viewDidDisappear:(BOOL)animated;
- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController;
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController;
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller;

- (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
26 changes: 26 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,31 @@ - (void)viewDidDisappear:(BOOL)animated
[super viewDidDisappear:animated];
}

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
if ([_proxy conformsToProtocol:@protocol(TiWindowProtocol)]) {
UIModalPresentationStyle style = [(id<TiWindowProtocol>)_proxy adaptivePresentationStyleForPresentationController:controller];
return style;
}
return UIModalPresentationNone;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default should be UIModalPresentationAutomatic for iOS 13+ and UIModalPresentationNone for < iOS 13 as per documentation.

}

#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
1 change: 1 addition & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiWindowProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
TiAnimation *closeAnimation;
UIView *animatedOver;
TiUIiOSTransitionAnimationProxy *transitionProxy;
UIModalPresentationStyle modalStyle;
vijaysingh-axway marked this conversation as resolved.
Show resolved Hide resolved
}

@property (nonatomic, readwrite, assign) TiViewProxy<TiTab> *tab;
Expand Down
27 changes: 23 additions & 4 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiWindowProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ - (void)openOnUIThread:(NSArray *)args
if (style != -1) {
[theController setModalTransitionStyle:style];
}
style = [TiUtils intValue:@"modalStyle" properties:dict def:-1];
if (style != -1) {
modalStyle = [TiUtils intValue:@"modalStyle" properties:dict def:-1];
if (modalStyle != -1) {
// modal transition style page curl must be done only in fullscreen
// so only allow if not page curl
if ([theController modalTransitionStyle] != UIModalTransitionStylePartialCurl) {
[theController setModalPresentationStyle:style];
[theController setModalPresentationStyle:modalStyle];
}
}

Expand Down Expand Up @@ -741,7 +741,26 @@ - (void)viewDidAppear:(BOOL)animated
}
- (void)viewDidDisappear:(BOOL)animated
{
if (isModal && (closing || !forceModal)) {
if (isModal && closing) {
[self windowDidClose];
}
}

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller
{
return modalStyle;
}

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

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