Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
Merged
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
30 changes: 30 additions & 0 deletions Frameworks/UIKit/UIAlertView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import <UIKit/UILabel.h>
#import <UIKit/UIScreen.h>
#import <UIKit/UIView.h>
#import <UIKit/UIWindow.h>

#import <Foundation/NSString.h>
#import <Foundation/NSMutableArray.h>
Expand Down Expand Up @@ -396,6 +397,32 @@ - (BOOL)isVisible {
return alertPriv->_isVisible;
}

- (void) _handleRotation {
// We need to offset the 'presentationTransform' used in WOCDispalyMode, because we always want to render alerts vertically.

Choose a reason for hiding this comment

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

nit: "dispaly"

// TODO: We'll remove this when we switch UIAlertView over to a Xaml ContentDialog, since rotation will be handled for us.
const float c_angleToRadian = kPi / 180.0;
switch ([[UIApplication displayMode] presentationTransform]) {
case UIInterfaceOrientationLandscapeRight:
[self setTransform:CGAffineTransformMakeRotation(-static_cast<float>(DisplayProperties::ScreenRotation90Clockwise) * c_angleToRadian)];
break;

case UIInterfaceOrientationPortrait:
[self setTransform:CGAffineTransformMakeTranslation(0.0f, 0.0f)];
break;

case UIInterfaceOrientationLandscapeLeft:
[self setTransform:CGAffineTransformMakeRotation(-static_cast<float>(DisplayProperties::ScreenRotation90CounterClockwise) * c_angleToRadian)];
break;

case UIInterfaceOrientationPortraitUpsideDown:
[self setTransform:CGAffineTransformMakeRotation(-static_cast<float>(DisplayProperties::ScreenRotation180) * c_angleToRadian)];
break;

default:
break;
}
}

/**
@Status Interoperable
*/
Expand Down Expand Up @@ -550,6 +577,9 @@ - (BOOL)isVisible {
frame.size.height = curHeight;
[self initWithFrame:frame];

// Make sure we're not rotated even if WOCDisplayMode rotates the presentation surface
[self _handleRotation];

id image;
image = [[UIImage imageNamed:@"/img/alert-background@2x.png"] stretchableImageWithLeftCapWidth:25 topCapHeight:30];
UIImageSetLayerContents([self layer], image);
Expand Down