Skip to content

Commit

Permalink
fix(ios): update visibility available now
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonelmy authored and zoomchan-cxj committed Sep 10, 2021
1 parent d28f693 commit 988106c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions ios/sdk/component/view/HippyShadowView.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ typedef void (^HippyApplierVirtualBlock)(NSDictionary<NSNumber *, HippyVirtualNo
@property (nonatomic, weak) HippyBridge *bridge;
@property (nonatomic, assign) MTTDirection layoutDirection;
@property (nonatomic, copy) NSString *visibility;
@property (nonatomic, assign) BOOL visibilityChanged;

/**
* isNewView - Used to track the first time the view is introduced into the hierarchy. It is initialized YES, then is
Expand Down
14 changes: 12 additions & 2 deletions ios/sdk/component/view/HippyShadowView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ @implementation HippyShadowView {
- (void)applyLayoutNode:(MTTNodeRef)node
viewsWithNewFrame:(NSMutableSet<HippyShadowView *> *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition {
if (!MTTNodeHasNewLayout(node)) {
if (!MTTNodeHasNewLayout(node) && !_visibilityChanged) {
return;
}
MTTNodesetHasNewLayout(node, false);
Expand All @@ -170,9 +170,11 @@ - (void)applyLayoutNode:(MTTNodeRef)node
},
{ HippyRoundPixelValue(absoluteBottomRight.x - absoluteTopLeft.x), HippyRoundPixelValue(absoluteBottomRight.y - absoluteTopLeft.y) } };

if (!CGRectEqualToRect(frame, _frame)) {
if (!CGRectEqualToRect(frame, _frame) ||
_visibilityChanged) {
_frame = frame;
[viewsWithNewFrame addObject:self];
_visibilityChanged = NO;
}

absolutePosition.x += MTTNodeLayoutGetLeft(node);
Expand Down Expand Up @@ -414,6 +416,14 @@ - (BOOL)isHidden {
return _hidden || [_visibility isEqualToString:@"hidden"];
}

- (void)setVisibility:(NSString *)visibility {
if (![_visibility isEqualToString:visibility]) {
_visibility = visibility;
_visibilityChanged = YES;
MTTNodeMarkDirty(self.nodeRef);
}
}

- (void)insertHippySubview:(HippyShadowView *)subview atIndex:(NSInteger)atIndex {
[_hippySubviews insertObject:subview atIndex:atIndex];
if (![self isCSSLeafNode]) {
Expand Down

0 comments on commit 988106c

Please sign in to comment.