Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -532,23 +532,26 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

#if TARGET_OS_VISION
- (void) updateHoverEffect:(NSString*)hoverEffect withCornerRadius:(CGFloat)cornerRadius {
if (hoverEffect == nil || [hoverEffect isEqualToString:@""]) {
self.hoverStyle = nil;
return;
}

UIShape *shape = [UIShape rectShapeWithCornerRadius:cornerRadius];
id<UIHoverEffect> effect;

if ([hoverEffect isEqualToString:@"lift"]) {
effect = [UIHoverLiftEffect effect];
} else if ([hoverEffect isEqualToString:@"highlight"]) {
effect = [UIHoverHighlightEffect effect];
}

if (hoverEffect != nil) {
self.hoverStyle = [UIHoverStyle styleWithEffect:effect shape:shape];
}
if (hoverEffect == nil) {
self.hoverStyle = nil;
return;
}

UIShape *shape = [UIShape rectShapeWithCornerRadius:cornerRadius];
id<UIHoverEffect> effect;

if ([hoverEffect isEqualToString:@"lift"]) {
effect = [UIHoverLiftEffect effect];
} else if ([hoverEffect isEqualToString:@"highlight"]) {
effect = [UIHoverHighlightEffect effect];
}

if (effect == nil) {
self.hoverStyle = nil;
return;
}

self.hoverStyle = [UIHoverStyle styleWithEffect:effect shape:shape];
}
#endif

Expand Down
61 changes: 32 additions & 29 deletions packages/react-native/React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -669,36 +669,39 @@ - (UIEdgeInsets)bordersAsInsets

#if TARGET_OS_VISION
- (void)setHoverEffect:(NSString *)hoverEffect {
_hoverEffect = hoverEffect;

if (hoverEffect == nil) {
self.hoverStyle = nil;
return;
}

CGFloat cornerRadius = 0.0;
RCTCornerRadii cornerRadii = [self cornerRadii];

if (RCTCornerRadiiAreEqual(cornerRadii)) {
cornerRadius = cornerRadii.topLeft;

} else {
// TODO: Handle a case when corner radius is different for each corner.
cornerRadius = cornerRadii.topLeft;
}

UIShape *shape = [UIShape rectShapeWithCornerRadius:cornerRadius];
id<UIHoverEffect> effect;

if ([hoverEffect isEqualToString:@"lift"]) {
effect = [UIHoverLiftEffect effect];
} else if ([hoverEffect isEqualToString:@"highlight"]) {
effect = [UIHoverHighlightEffect effect];
}
_hoverEffect = hoverEffect;

if (hoverEffect == nil) {
self.hoverStyle = nil;
return;
}

CGFloat cornerRadius = 0.0;
RCTCornerRadii cornerRadii = [self cornerRadii];

if (RCTCornerRadiiAreEqual(cornerRadii)) {
cornerRadius = cornerRadii.topLeft;

if (hoverEffect != nil) {
self.hoverStyle = [UIHoverStyle styleWithEffect:effect shape:shape];
}
} else {
// TODO: Handle a case when corner radius is different for each corner.
cornerRadius = cornerRadii.topLeft;
}

UIShape *shape = [UIShape rectShapeWithCornerRadius:cornerRadius];
id<UIHoverEffect> effect;

if ([hoverEffect isEqualToString:@"lift"]) {
effect = [UIHoverLiftEffect effect];
} else if ([hoverEffect isEqualToString:@"highlight"]) {
effect = [UIHoverHighlightEffect effect];
}

if (effect == nil) {
self.hoverStyle = nil;
return;
}

self.hoverStyle = [UIHoverStyle styleWithEffect:effect shape:shape];
}
#endif

Expand Down