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 156c966 [iOS] Public methods for getting/setting global device size.
(#2534)
156c966 is described below
commit 156c96634b72d2d9fde44d7bc46cca914da5ae0e
Author: wqyfavor <[email protected]>
AuthorDate: Wed Jun 12 15:04:08 2019 +0800
[iOS] Public methods for getting/setting global device size. (#2534)
---
ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm | 2 ++
ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h | 15 +++++++++++++++
ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m | 11 +++++++++++
3 files changed, 28 insertions(+)
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
index 4dcde85..da7514e 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
@@ -1046,6 +1046,7 @@ static WeexCore::ScriptBridge* jsBridge = nullptr;
+ (void)setDeviceSize:(CGSize)size
{
+ [WXCoreBridge install];
WeexCore::WXCoreEnvironment* env =
WeexCore::WXCoreEnvironment::getInstance();
env->SetDeviceWidth(std::to_string(size.width));
env->SetDeviceHeight(std::to_string(size.height));
@@ -1053,6 +1054,7 @@ static WeexCore::ScriptBridge* jsBridge = nullptr;
+ (CGSize)getDeviceSize
{
+ [WXCoreBridge install];
WeexCore::WXCoreEnvironment* env =
WeexCore::WXCoreEnvironment::getInstance();
return CGSizeMake(env->DeviceWidth(), env->DeviceHeight());
}
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
index ac014a5..9d70c9d 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
@@ -215,6 +215,21 @@
*/
+ (void)connectDevToolServer:(NSString *)URL;
+/**
+ * @abstract Set the global device size of all pages.
+ * You could also set unique device size used by a page using interface of
WXSDKInstance.
+ *
+ * @param size, the device size in UIKit system.
+ *
+ */
++ (void)setGlobalDeviceSize:(CGSize)size;
+
+/**
+ * @abstract Get the current global device size used by pages.
+ *
+ */
++ (CGSize)getGlobalDeviceSize;
+
@end
@interface WXSDKEngine (Deprecated)
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
index bdc6a3b..dc717d8 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
@@ -41,6 +41,7 @@
#import "WXExceptionUtils.h"
#import "WXConfigCenterProtocol.h"
#import "WXComponent+Layout.h"
+#import "WXCoreBridge.h"
@implementation WXSDKEngine
@@ -370,6 +371,16 @@ static NSDictionary *_customEnvironment = nil;
[[WXSDKManager bridgeMgr] connectToDevToolWithUrl:[NSURL
URLWithString:URL]];
}
++ (void)setGlobalDeviceSize:(CGSize)size
+{
+ [WXCoreBridge setDeviceSize:size];
+}
+
++ (CGSize)getGlobalDeviceSize
+{
+ return [WXCoreBridge getDeviceSize];
+}
+
+ (void)_originalRegisterComponents:(NSDictionary *)components {
NSMutableDictionary * mutableComponents = [components mutableCopy];
void (^componentBlock)(id, id, BOOL *) = ^(id mKey, id mObj, BOOL * mStop)
{