Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

* [WEEX-313][iOS]fix RTL issue #1134

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Component/WXTextComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@

+ (void)setRenderUsingCoreText:(BOOL)usingCoreText;
- (BOOL)useCoreText;

@end
4 changes: 2 additions & 2 deletions ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ - (NSMutableAttributedString *)buildCTAttributeString
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];

// handle text direction style, default ltr
if ([_direction isEqualToString:@"rtl"]) {
if (_cssNode->layout.direction == CSS_DIRECTION_RTL) {
if (0 == _textAlign) {
//force text right-align if don't specified any align.
_textAlign = NSTextAlignmentRight;
Expand Down Expand Up @@ -563,7 +563,7 @@ - (NSAttributedString *)buildAttributeString
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];

// handle text direction style, default ltr
if ([_direction isEqualToString:@"rtl"]) {
if (_cssNode->layout.direction == CSS_DIRECTION_RTL) {
if (0 == _textAlign) {
//force text right-align if don't specified any align.
_textAlign = NSTextAlignmentRight;
Expand Down
2 changes: 2 additions & 0 deletions ios/sdk/WeexSDK/Sources/Layout/Layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,4 +1324,6 @@ void resetNodeLayout(css_node_t *node) {
node->layout.dimensions[CSS_HEIGHT] = CSS_UNDEFINED;
node->layout.position[CSS_LEFT] = 0;
node->layout.position[CSS_TOP] = 0;
node->layout.position[CSS_RIGHT] = 0;
node->layout.position[CSS_BOTTOM] = 0;
}
38 changes: 2 additions & 36 deletions ios/sdk/WeexSDK/Sources/Layout/WXComponent+Layout.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,13 @@ @implementation WXComponent (Layout)

- (void)setNeedsLayout
{
_isLayoutDirty = YES;
WXComponent *supercomponent = [self supercomponent];
if (self->_virtualComponentId || self->_templateComponent) {
// we will generate a virtualComponentId for recycleList virtual component or templateComponent for recycleList component template.
// as for recyclelist component, it depends on the input data, not the new layout, here will not try to clear slibling child layout.
_isLayoutDirty = YES;
if(supercomponent){
[supercomponent setNeedsLayout];
} else {
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;
Expand Down Expand Up @@ -234,23 +217,6 @@ - (void)_layoutDidFinish
[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];\
Expand Down