You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ji...@apache.org on 2020/06/17 11:56:47 UTC
[incubator-weex] branch master updated: [iOS] adapt modal and
picker modules for iPad
This is an automated email from the ASF dual-hosted git repository.
jianhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 07b6210 [iOS] adapt modal and picker modules for iPad
new 5ca2912 Merge pull request #3228 from jianhan-he/master
07b6210 is described below
commit 07b6210b3dd00b4a8a3d616e25ef09a7eae5c370
Author: linghe.lh <li...@alibaba-inc.com>
AuthorDate: Wed Jun 17 19:28:50 2020 +0800
[iOS] adapt modal and picker modules for iPad
---
ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m | 55 ++++++++++++------------
ios/sdk/WeexSDK/Sources/Module/WXPickerModule.m | 4 +-
2 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m b/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
index bdca09f..6e6f353 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
@@ -158,34 +158,35 @@ static const CGFloat WXToastDefaultPadding = 30.0;
CGSize windowSize = window.frame.size;
if ([WXUtility enableAdaptiveLayout]) {
windowSize = self.weexInstance.viewController.view.frame.size;
- }
-
- // adjust to screen orientation
- UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
- switch (orientation) {
- case UIDeviceOrientationPortrait: {
- point = CGPointMake(windowSize.width/2, windowSize.height/2);
- break;
- }
- case UIDeviceOrientationPortraitUpsideDown: {
- toastView.transform = CGAffineTransformMakeRotation(M_PI);
- float width = windowSize.width;
- float height = windowSize.height;
- point = CGPointMake(width/2, height/2);
- break;
- }
- case UIDeviceOrientationLandscapeLeft: {
- toastView.transform = CGAffineTransformMakeRotation(M_PI/2); //rotation in radians
- point = CGPointMake(windowSize.width/2, windowSize.height/2);
- break;
- }
- case UIDeviceOrientationLandscapeRight: {
- toastView.transform = CGAffineTransformMakeRotation(-M_PI/2);
- point = CGPointMake(windowSize.width/2, windowSize.height/2);
- break;
+ point = window.center;
+ } else {
+ // adjust to screen orientation
+ UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
+ switch (orientation) {
+ case UIDeviceOrientationPortrait: {
+ point = CGPointMake(windowSize.width/2, windowSize.height/2);
+ break;
+ }
+ case UIDeviceOrientationPortraitUpsideDown: {
+ toastView.transform = CGAffineTransformMakeRotation(M_PI);
+ float width = windowSize.width;
+ float height = windowSize.height;
+ point = CGPointMake(width/2, height/2);
+ break;
+ }
+ case UIDeviceOrientationLandscapeLeft: {
+ toastView.transform = CGAffineTransformMakeRotation(M_PI/2); //rotation in radians
+ point = CGPointMake(windowSize.width/2, windowSize.height/2);
+ break;
+ }
+ case UIDeviceOrientationLandscapeRight: {
+ toastView.transform = CGAffineTransformMakeRotation(-M_PI/2);
+ point = CGPointMake(windowSize.width/2, windowSize.height/2);
+ break;
+ }
+ default:
+ break;
}
- default:
- break;
}
toastView.center = point;
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXPickerModule.m b/ios/sdk/WeexSDK/Sources/Module/WXPickerModule.m
index 7538c41..cb4bb7b 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXPickerModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXPickerModule.m
@@ -182,6 +182,9 @@ WX_EXPORT_METHOD(@selector(pickTime:callback:))
[[[UIApplication sharedApplication] keyWindow] endEditing:YES]; //hide keyboard
UIWindow *window = [UIApplication sharedApplication].keyWindow;
[window addSubview:self.backgroundView];
+ if ([WXUtility enableAdaptiveLayout]) {
+ self.backgroundView.center = window.center;
+ }
if (self.isAnimating) {
return;
}
@@ -197,7 +200,6 @@ WX_EXPORT_METHOD(@selector(pickTime:callback:))
[UIView animateWithDuration:0.35f animations:^{
self.pickerView.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - WXPickerHeight, [UIScreen mainScreen].bounds.size.width, WXPickerHeight);
self.backgroundView.alpha = 1;
-
} completion:^(BOOL finished) {
self.isAnimating = NO;