[ 
https://issues.apache.org/jira/browse/WEEX-653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16686306#comment-16686306
 ] 

ASF GitHub Bot commented on WEEX-653:
-------------------------------------

YorkShen commented on a change in pull request #1664: 
[WEEX-653][android][iOS][core] Total platform support rtl direction by CSS 
"direction:rtl"
URL: https://github.com/apache/incubator-weex/pull/1664#discussion_r233380323
 
 

 ##########
 File path: weex_core/Source/core/layout/layout.cpp
 ##########
 @@ -645,21 +645,39 @@ namespace WeexCore {
 
   void WXCoreLayoutNode::onLayout(const float left, const float top, const 
float right, const float bottom,
                                   WXCoreLayoutNode *const absoulteItem, 
WXCoreFlexLine *const flexLine) {
-    switch (mCssStyle->mFlexDirection) {
-      case kFlexDirectionRow:
-        layoutHorizontal(false, left, top, right, bottom, absoulteItem, 
flexLine);
-        break;
-      case kFlexDirectionRowReverse:
-        layoutHorizontal(true, left, top, right, bottom, absoulteItem, 
flexLine);
-        break;
-      case kFlexDirectionColumnReverse:
-        layoutVertical(mCssStyle->mFlexWrap == kWrapReverse, true, left, top, 
right, bottom, absoulteItem, flexLine);
-        break;
-      case kFlexDirectionColumn:
-      default:
-        layoutVertical(mCssStyle->mFlexWrap == kWrapReverse, false, left, top, 
right, bottom, absoulteItem, flexLine);
-        break;
-    }
+      // determin direction
+      if (mLayoutResult->mLayoutDirection == kDirectionInherit) {
+          if(mCssStyle->mDirection == kDirectionInherit) {
+              // default direction in css is inherit, inherit direction from 
parent node
+              mLayoutResult->mLayoutDirection = NULL == mParent ? 
WEEXCORE_CSS_DEFAULT_DIRECTION : mParent->getLayoutDirection();
+          } else {
+              // specific direction in current Node's style
+              mLayoutResult->mLayoutDirection = mCssStyle->mDirection;
+          }
+      }
+      
+      bool verticalRTL = false;
+      if (mLayoutResult->mLayoutDirection == kDirectionRTL) {
+          verticalRTL = mCssStyle->mFlexWrap != kWrapReverse;
+      } else {
+          verticalRTL = mCssStyle->mFlexWrap == kWrapReverse;
+      }
+      
+      switch (mCssStyle->mFlexDirection) {
+        case kFlexDirectionRow:
+            layoutHorizontal(mLayoutResult->mLayoutDirection == kDirectionRTL 
? true : false, left, top, right, bottom, absoulteItem, flexLine);
+            break;
+        case kFlexDirectionRowReverse:
+            layoutHorizontal(mLayoutResult->mLayoutDirection == kDirectionRTL 
? false : true, left, top, right, bottom, absoulteItem, flexLine);
 
 Review comment:
   Change `mLayoutResult->mLayoutDirection == kDirectionRTL ? false : true` to 
`mLayoutResult->mLayoutDirection != kDirectionRTL`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> feature for Rtl layout
> ----------------------
>
>                 Key: WEEX-653
>                 URL: https://issues.apache.org/jira/browse/WEEX-653
>             Project: Weex
>          Issue Type: New Feature
>          Components: Android, iOS, Web Renderer
>    Affects Versions: 0.18
>            Reporter: Kai Tian
>            Assignee: YorkShen
>            Priority: Major
>             Fix For: 0.18
>
>
> [android][ios][core] Whole platform support rtl direction by CSS 
> "direction:rtl"
> [core] Update the new layout engine to support inheritable CSS 
> "direction:rtl".
> [ios][android] Update component layer, to support list, slide, scroller RTL 
> direction. Update WXEnvironment, now we can get system layout direction by 
> WXEnvironment.layoutDirection. Update WXDomModule, now we can get element 
> layout direction by getLayoutDirection(ref,callback)
> Few languages such as Arabic, Hebrew, or Persian are written from Right to 
> Left, but weex not support RTL layouts. To handle them. Since this PR merged, 
> we can use weex for RTL languages in both android and ios. And Scroller 
> performance like native, layout and scroll direction will be reverse.
>  
> There are some test Demos: 
> Div+Scroller http://dotwe.org/vue/9c3ee9824dd49111a87a93ea6513039a
> Horizontal Scroller http://dotwe.org/vue/0dd282e3183c2384ec38a465c915ce41
> Scroller (ScrollToElement) 
> http://dotwe.org/vue/a24001978199df6e981673e9460598c8
> Slider http://dotwe.org/vue/7e45bcf71ad396032944bc51541d6350
> Animation http://dotwe.org/vue/b578facdbb623f6922f0905ae09b7e49
> envDirection + getLayoutDirection 
> http://dotwe.org/vue/d6c5cf7a2a907c33cf4ba25fea6e6ef4



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to