Merge pull request #3176 from chenzefeng09/master
[Android]Fix rows doesn't work in textarea
diff --git a/WeexSDK.podspec b/WeexSDK.podspec
index 050e37f..37fbc1b 100644
--- a/WeexSDK.podspec
+++ b/WeexSDK.podspec
@@ -72,6 +72,8 @@
'ios/sdk/WeexSDK/Sources/View/WXView.h',
'ios/sdk/WeexSDK/Sources/View/WXErrorView.h',
'ios/sdk/WeexSDK/Sources/Protocol/*.h',
+ 'ios/sdk/WeexSDK/Sources/Plugin/WXEaglePluginManager.h',
+ 'ios/sdk/WeexSDK/Sources/Plugin/WXEaglePlugin.h',
'ios/sdk/WeexSDK/Sources/Network/WXResourceRequestHandler.h',
'ios/sdk/WeexSDK/Sources/Network/WXResourceRequest.h',
'ios/sdk/WeexSDK/Sources/Network/WXResourceResponse.h',
@@ -87,6 +89,7 @@
'ios/sdk/WeexSDK/Sources/Manager/WXHandlerFactory.h',
'ios/sdk/WeexSDK/Sources/Manager/WXComponentFactory.h',
'ios/sdk/WeexSDK/Sources/Manager/WXInvocationConfig.h',
+ 'ios/sdk/WeexSDK/Sources/Manager/WXModuleFactory.h',
'ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h',
'ios/sdk/WeexSDK/Sources/Engine/WXSDKError.h',
'ios/sdk/WeexSDK/Sources/Eagle/WXDataRenderHandler.h',
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.mm b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.mm
index 22be575..e379ca2 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerComponent.mm
@@ -229,6 +229,15 @@
}
}
+- (void)updateStyles:(NSDictionary *)styles {
+ [super updateStyles:styles];
+
+ //Need layout if the attribute of columnWidth changed on iPad
+ if ([WXUtility enableAdaptiveLayout]) {
+ [self updateAttributes:self.attributes];
+ }
+}
+
- (void)updateAttributes:(NSDictionary *)attributes
{
[super updateAttributes:attributes];
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
index 5cd5de6..fec4ac6 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
@@ -428,7 +428,7 @@
/**
* Set specific required page width and height to prevent this page using global values.
*/
-- (void)setPageRequiredWidth:(CGFloat)width height:(CGFloat)height;
+- (BOOL)setPageRequiredWidth:(CGFloat)width height:(CGFloat)height;
/**
* Set specific required view port width prevent this page using global value (750px).
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index cdfd2b3..3f2bdf9 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -256,6 +256,7 @@
_rootView.frame = frame;
WXPerformBlockOnComponentThread(^{
[self.componentManager rootViewFrameDidChange:frame];
+ [[WXSDKManager bridgeMgr] fireEvent:_instanceId ref:WX_SDK_ROOT_REF type:@"viewportchange" params:nil domChanges:nil];
});
}
});
@@ -301,8 +302,11 @@
[WXCoreBridge setPageArgument:_instanceId key:@"url" value:[_scriptURL absoluteString]];
}
-- (void)setPageRequiredWidth:(CGFloat)width height:(CGFloat)height
+- (BOOL)setPageRequiredWidth:(CGFloat)width height:(CGFloat)height
{
+ if (CGSizeEqualToSize(_screenSize, CGSizeMake(width, height))) {
+ return NO;
+ }
_screenSize = CGSizeMake(width, height);
// notify weex core
@@ -310,6 +314,7 @@
WXPerformBlockOnComponentThread(^{
[WXCoreBridge setPageRequired:pageId width:width height:height];
});
+ return YES;
}
- (void)renderWithURL:(NSURL *)url
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m b/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
index 7a5ba0f..bdca09f 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXModalUIModule.m
@@ -156,7 +156,7 @@
window = [[[UIApplication sharedApplication] windows] firstObject];
}
CGSize windowSize = window.frame.size;
- if ([WXUtility deviceIsiPad]) {
+ if ([WXUtility enableAdaptiveLayout]) {
windowSize = self.weexInstance.viewController.view.frame.size;
}
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
index d9b1e5c..0112322 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
@@ -531,6 +531,13 @@
+ (void)setDarkSchemeSupportEnable:(BOOL)value;
+ (BOOL)isDarkSchemeSupportEnabled;
+/**
+* @abstract Switch for adapt iPad.
+*
+*/
++ (void)setEnableAdaptiveLayout:(BOOL)value;
++ (BOOL)enableAdaptiveLayout;
+
+ (long) getUnixFixTimeMillis;
+ (NSArray<NSString *> *_Nullable)extractPropertyNamesOfJSValueObject:(JSValue *_Nullable)jsvalue;
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
index 9ded42f..ebe1a8f 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
@@ -45,6 +45,7 @@
static BOOL enableRTLLayoutDirection = YES;
static BOOL isDarkSchemeSupportEnabled = YES;
+static BOOL enableAdaptiveLayout = NO;
void WXPerformBlockOnMainThread(void (^ _Nonnull block)(void))
{
@@ -852,6 +853,18 @@
return isDarkSchemeSupportEnabled;
}
+#pragma mark - Adapt iPad
+
++ (void)setEnableAdaptiveLayout:(BOOL)value
+{
+ enableAdaptiveLayout = value;
+}
+
++ (BOOL)enableAdaptiveLayout
+{
+ return enableAdaptiveLayout;
+}
+
#pragma mark - get deviceID
+ (NSString *)getDeviceID {
NSMutableDictionary *usernamepasswordKVPairs = (NSMutableDictionary *)[self load:KEY_USERNAME_PASSWORD];
diff --git a/weex_core/Source/core/common/view_utils.h b/weex_core/Source/core/common/view_utils.h
index 550f262..008f96a 100644
--- a/weex_core/Source/core/common/view_utils.h
+++ b/weex_core/Source/core/common/view_utils.h
@@ -116,7 +116,7 @@
}
float f = getFloat(temp.c_str());
float density = getFloat(WXCoreEnvironment::getInstance()->GetOption(SCALE).c_str());
- return density * f * viewport / device_width; WXCoreEnvironment::getInstance()->DeviceWidth();
+ return density * f * viewport / device_width;
}
inline static float getFloatByViewport(std::string src, const float &viewport,
@@ -139,14 +139,15 @@
return ret;
}
- inline static float getWebPxByWidth(float pxValue, float customViewport) {
+ inline static float getWebPxByWidth(float pxValue, float customViewport, float deviceWidth) {
if (isnan(pxValue))
return NAN;
- float realPx = (pxValue * customViewport / WXCoreEnvironment::getInstance()->DeviceWidth());
#if OS_IOS
+ float realPx = (pxValue * customViewport / deviceWidth);
return realPx;
#else
+ float realPx = (pxValue * customViewport / WXCoreEnvironment::getInstance()->DeviceWidth());
float result = realPx > 0.005 && realPx < 1 ? 1.0f : realPx;
return result;
#endif
diff --git a/weex_core/Source/core/render/node/render_list.cpp b/weex_core/Source/core/render/node/render_list.cpp
index 0e724e9..6935b24 100644
--- a/weex_core/Source/core/render/node/render_list.cpp
+++ b/weex_core/Source/core/render/node/render_list.cpp
@@ -116,8 +116,8 @@
this->available_width_ =
TakeStyleWidth() -
- getWebPxByWidth(getPaddingLeft(), RenderManager::GetInstance()->viewport_width(page_id())) -
- getWebPxByWidth(getPaddingRight(), RenderManager::GetInstance()->viewport_width(page_id()));
+ getWebPxByWidth(getPaddingLeft(), RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id())) -
+ getWebPxByWidth(getPaddingRight(), RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id()));
if (AUTO_VALUE == this->column_count_ &&
AUTO_VALUE == this->column_width_) {
@@ -224,15 +224,15 @@
float RenderList::TakeStyleWidth() {
float width =
- getWebPxByWidth(getLayoutWidth(), RenderManager::GetInstance()->viewport_width(page_id()));
+ getWebPxByWidth(getLayoutWidth(), RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id()));
if (isnan(width) || width <= 0) {
if (getParent() != nullptr) {
width = getWebPxByWidth(getParent()->getLayoutWidth(),
- RenderManager::GetInstance()->viewport_width(page_id()));
+ RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id()));
}
if (isnan(width) || width <= 0) {
width = getWebPxByWidth(RenderObject::getStyleWidth(),
- RenderManager::GetInstance()->viewport_width(page_id()));
+ RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id()));
}
}
if (isnan(width) || width <= 0) {
diff --git a/weex_core/Source/core/render/node/render_mask.cpp b/weex_core/Source/core/render/node/render_mask.cpp
index 4e3bd19..217bf19 100644
--- a/weex_core/Source/core/render/node/render_mask.cpp
+++ b/weex_core/Source/core/render/node/render_mask.cpp
@@ -59,9 +59,9 @@
style->insert(std::pair<std::string, std::string>(POSITION, "absolute"));
style->insert(std::pair<std::string, std::string>(
- WIDTH, to_string(getWebPxByWidth(width, RenderManager::GetInstance()->viewport_width(page_id())))));
+ WIDTH, to_string(getWebPxByWidth(width, RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id())))));
style->insert(std::pair<std::string, std::string>(
- HEIGHT, to_string(getWebPxByWidth(height, RenderManager::GetInstance()->viewport_width(page_id())))));
+ HEIGHT, to_string(getWebPxByWidth(height, RenderManager::GetInstance()->viewport_width(page_id()), RenderManager::GetInstance()->DeviceWidth(page_id())))));
style->insert(std::pair<std::string, std::string>(TOP, "0"));
return style;
}