You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/04/12 06:25:12 UTC
[1/2] incubator-weex git commit: [WEEX-282][iOS] update layout system
to support rtl direction
Repository: incubator-weex
Updated Branches:
refs/heads/master fdf7669c4 -> e5cad8e12
[WEEX-282][iOS] update layout system to support rtl direction
Modified WXComponent+Layout.m:
1.set direction value to cssNode
2.setNeedLayout changed to trigger sibling component recalculate cssNode->layout
Modified WXConvert.h/m:
add convert for "direction"
Modified WXConvertTests.m:
add Tests for convert direction
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/487b6924
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/487b6924
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/487b6924
Branch: refs/heads/master
Commit: 487b6924c9d200c315c96104c49f5f718aae0c5a
Parents: bb29077
Author: Klueze <ti...@alibaba-inc.com>
Authored: Sun Apr 8 17:37:00 2018 +0800
Committer: Klueze <ti...@alibaba-inc.com>
Committed: Mon Apr 9 11:31:08 2018 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Layout/WXComponent+Layout.m | 31 +++++++++++++++++++-
ios/sdk/WeexSDK/Sources/Utility/WXConvert.h | 1 +
ios/sdk/WeexSDK/Sources/Utility/WXConvert.m | 14 +++++++++
ios/sdk/WeexSDKTests/WXConvertTests.m | 8 +++++
4 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/487b6924/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
index 44aef1c..db40bc0 100644
--- a/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
+++ b/ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
@@ -35,13 +35,23 @@
- (void)setNeedsLayout
{
- _isLayoutDirty = YES;
WXComponent *supercomponent = [self supercomponent];
if(supercomponent){
+ for (WXComponent *siblingComponent in [supercomponent subcomponents]) {
+ [siblingComponent _needRecalculateLayout];
+ }
[supercomponent setNeedsLayout];
+ } else {
+ [self _needRecalculateLayout];
}
}
+- (void)_needRecalculateLayout
+{
+ _isLayoutDirty = YES;
+ [self _clearLayoutCSS];
+}
+
- (BOOL)needsLayout
{
return _isLayoutDirty;
@@ -208,6 +218,23 @@
[self layoutDidFinish];
}
+/**
+ * clear the layout variables on css node
+ **/
+- (void)_clearLayoutCSS {
+ memset(&(_cssNode->layout), 0, sizeof(_cssNode->layout));
+ _cssNode->layout.dimensions[CSS_WIDTH] = CSS_UNDEFINED;
+ _cssNode->layout.dimensions[CSS_HEIGHT] = CSS_UNDEFINED;
+
+ // Such that the comparison is always going to be false
+ _cssNode->layout.last_requested_dimensions[CSS_WIDTH] = -1;
+ _cssNode->layout.last_requested_dimensions[CSS_HEIGHT] = -1;
+ _cssNode->layout.last_parent_max_width = -1;
+ _cssNode->layout.last_parent_max_height = -1;
+ _cssNode->layout.last_direction = (css_direction_t)-1;
+ _cssNode->layout.should_update = true;
+}
+
#define WX_STYLE_FILL_CSS_NODE(key, cssProp, type)\
do {\
id value = styles[@#key];\
@@ -248,6 +275,7 @@ do {\
- (void)_fillCSSNode:(NSDictionary *)styles
{
+ WX_STYLE_FILL_CSS_NODE(direction, direction, css_direction_t)
// flex
WX_STYLE_FILL_CSS_NODE(flex, flex, CGFloat)
WX_STYLE_FILL_CSS_NODE(flexDirection, flex_direction, css_flex_direction_t)
@@ -311,6 +339,7 @@ do {\
- (void)_resetCSSNode:(NSArray *)styles;
{
+ WX_STYLE_RESET_CSS_NODE(direction, direction, CSS_DIRECTION_LTR)
// flex
WX_STYLE_RESET_CSS_NODE(flex, flex, 0.0)
WX_STYLE_RESET_CSS_NODE(flexDirection, flex_direction, CSS_FLEX_DIRECTION_COLUMN)
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/487b6924/ios/sdk/WeexSDK/Sources/Utility/WXConvert.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXConvert.h b/ios/sdk/WeexSDK/Sources/Utility/WXConvert.h
index 25c6430..775fa05 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXConvert.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXConvert.h
@@ -40,6 +40,7 @@ typedef CGFloat WXPixelType;
// @parameter scaleFactor: please use weexInstance's pixelScaleFactor property
+ (WXPixelType)WXPixelType:(id)value scaleFactor:(CGFloat)scaleFactor;
++ (css_direction_t)css_direction_t:(id)value;
+ (css_flex_direction_t)css_flex_direction_t:(id)value;
+ (css_align_t)css_align_t:(id)value;
+ (css_wrap_type_t)css_wrap_type_t:(id)value;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/487b6924/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m b/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m
index f7e82f6..2744e60 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m
@@ -146,6 +146,20 @@ WX_NUMBER_CONVERT(NSUInteger, unsignedIntegerValue)
#pragma mark CSS Layout
++ (css_direction_t)css_direction_t:(id)value
+{
+ if([value isKindOfClass:[NSString class]]){
+ if ([value isEqualToString:@"inherit"]) {
+ return CSS_DIRECTION_INHERIT;
+ } else if ([value isEqualToString:@"ltr"]) {
+ return CSS_DIRECTION_LTR;
+ } else if ([value isEqualToString:@"rtl"]) {
+ return CSS_DIRECTION_RTL;
+ }
+ }
+ return CSS_DIRECTION_LTR;
+}
+
+(css_position_type_t)css_position_type_t:(id)value
{
if([value isKindOfClass:[NSString class]]){
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/487b6924/ios/sdk/WeexSDKTests/WXConvertTests.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDKTests/WXConvertTests.m b/ios/sdk/WeexSDKTests/WXConvertTests.m
index 8b33922..a773775 100644
--- a/ios/sdk/WeexSDKTests/WXConvertTests.m
+++ b/ios/sdk/WeexSDKTests/WXConvertTests.m
@@ -36,6 +36,14 @@
[super tearDown];
}
+- (void)testDirection {
+ NSArray *testDirections = @[@"inherit", @"ltr", @"rtl"];
+ css_direction_t directions[3] = {CSS_DIRECTION_INHERIT, CSS_DIRECTION_LTR, CSS_DIRECTION_RTL};
+ for (int i = 0; i<testDirections.count; i++) {
+ XCTAssertTrue([WXConvert wx_css_direction_t:testDirections[i]] == directions[i]);
+ }
+}
+
- (void)testBOOL {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
[2/2] incubator-weex git commit: Merge branch
'ios-feature-RTL-layout' of https://github.com/win80540/incubator-weex into
merge-pull-request-master
Posted by ac...@apache.org.
Merge branch 'ios-feature-RTL-layout' of https://github.com/win80540/incubator-weex into merge-pull-request-master
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e5cad8e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e5cad8e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e5cad8e1
Branch: refs/heads/master
Commit: e5cad8e1211db18c39326b7be9ee69b74a8fdc25
Parents: fdf7669 487b692
Author: acton393 <zh...@gmail.com>
Authored: Thu Apr 12 14:25:02 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu Apr 12 14:25:02 2018 +0800
----------------------------------------------------------------------
.../WeexSDK/Sources/Layout/WXComponent+Layout.m | 31 +++++++++++++++++++-
ios/sdk/WeexSDK/Sources/Utility/WXConvert.h | 1 +
ios/sdk/WeexSDK/Sources/Utility/WXConvert.m | 14 +++++++++
ios/sdk/WeexSDKTests/WXConvertTests.m | 8 +++++
4 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------