From 14e1adcf4c8ef2279701e4828b2bc8dadd5950c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Thu, 1 Feb 2024 16:59:28 +0100 Subject: [PATCH 1/5] feat: add visionos support --- RNReanimated.podspec | 2 +- apple/LayoutReanimation/REAAnimationsManager.m | 2 +- apple/LayoutReanimation/REASharedTransitionManager.m | 2 +- apple/LayoutReanimation/REASnapshot.m | 3 ++- apple/sensor/ReanimatedSensor.m | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/RNReanimated.podspec b/RNReanimated.podspec index 8e539f565d5..5d596d47d89 100644 --- a/RNReanimated.podspec +++ b/RNReanimated.podspec @@ -74,7 +74,7 @@ Pod::Spec.new do |s| s.homepage = "https://github.com/software-mansion/react-native-reanimated" s.license = "MIT" s.author = { "author" => "author@domain.cn" } - s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14" } + s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14", :visionos => "1.0" } s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" } s.source_files = [ diff --git a/apple/LayoutReanimation/REAAnimationsManager.m b/apple/LayoutReanimation/REAAnimationsManager.m index 19b85a99f09..e81f8ebe334 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.m +++ b/apple/LayoutReanimation/REAAnimationsManager.m @@ -250,7 +250,7 @@ - (void)setNewProps:(NSMutableDictionary *)newProps if (needsViewPositionUpdate) { CGPoint newCenter = CGPointMake(centerX, centerY); if (convertFromAbsolute) { - REAUIView *window = UIApplication.sharedApplication.keyWindow; + REAUIView *window = RCTKeyWindow(); CGPoint convertedCenter = [window convertPoint:newCenter toView:view.superview]; view.center = convertedCenter; } else { diff --git a/apple/LayoutReanimation/REASharedTransitionManager.m b/apple/LayoutReanimation/REASharedTransitionManager.m index 2102fbfe927..ecda9932f83 100644 --- a/apple/LayoutReanimation/REASharedTransitionManager.m +++ b/apple/LayoutReanimation/REASharedTransitionManager.m @@ -529,7 +529,7 @@ - (void)configureTransitionContainer { if (!_isSharedTransitionActive) { _isSharedTransitionActive = YES; - REAUIView *mainWindow = UIApplication.sharedApplication.keyWindow; + REAUIView *mainWindow = RCTKeyWindow(); if (_transitionContainer == nil) { _transitionContainer = [REAUIView new]; } diff --git a/apple/LayoutReanimation/REASnapshot.m b/apple/LayoutReanimation/REASnapshot.m index 02ba8dc1072..51df531faca 100644 --- a/apple/LayoutReanimation/REASnapshot.m +++ b/apple/LayoutReanimation/REASnapshot.m @@ -3,6 +3,7 @@ #import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -27,7 +28,7 @@ - (instancetype)initWithAbsolutePosition:(REAUIView *)view - (void)makeSnapshotForView:(REAUIView *)view useAbsolutePositionOnly:(BOOL)useAbsolutePositionOnly { - REAUIView *mainWindow = UIApplication.sharedApplication.keyWindow; + REAUIView *mainWindow = RCTKeyWindow(); CGPoint absolutePosition = [[view superview] convertPoint:view.center toView:nil]; _values = [NSMutableDictionary new]; #if TARGET_OS_OSX diff --git a/apple/sensor/ReanimatedSensor.m b/apple/sensor/ReanimatedSensor.m index b290ab1906d..863c788ea9a 100644 --- a/apple/sensor/ReanimatedSensor.m +++ b/apple/sensor/ReanimatedSensor.m @@ -1,6 +1,6 @@ #import -#if !TARGET_OS_TV && !TARGET_OS_OSX +#if !TARGET_OS_TV && !TARGET_OS_OSX && !TARGET_OS_VISION @implementation ReanimatedSensor - (instancetype)init:(ReanimatedSensorType)sensorType From ba8e58179f231eaa28cc9db30738f4507dc4dad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Fri, 2 Feb 2024 13:29:14 +0100 Subject: [PATCH 2/5] fix: add typecast --- apple/LayoutReanimation/REAAnimationsManager.m | 2 +- apple/LayoutReanimation/REASharedTransitionManager.m | 2 +- apple/LayoutReanimation/REASnapshot.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apple/LayoutReanimation/REAAnimationsManager.m b/apple/LayoutReanimation/REAAnimationsManager.m index e81f8ebe334..7eca632333a 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.m +++ b/apple/LayoutReanimation/REAAnimationsManager.m @@ -250,7 +250,7 @@ - (void)setNewProps:(NSMutableDictionary *)newProps if (needsViewPositionUpdate) { CGPoint newCenter = CGPointMake(centerX, centerY); if (convertFromAbsolute) { - REAUIView *window = RCTKeyWindow(); + REAUIView *window = (REAUIView* )RCTKeyWindow(); CGPoint convertedCenter = [window convertPoint:newCenter toView:view.superview]; view.center = convertedCenter; } else { diff --git a/apple/LayoutReanimation/REASharedTransitionManager.m b/apple/LayoutReanimation/REASharedTransitionManager.m index ecda9932f83..fce3f39d472 100644 --- a/apple/LayoutReanimation/REASharedTransitionManager.m +++ b/apple/LayoutReanimation/REASharedTransitionManager.m @@ -529,7 +529,7 @@ - (void)configureTransitionContainer { if (!_isSharedTransitionActive) { _isSharedTransitionActive = YES; - REAUIView *mainWindow = RCTKeyWindow(); + REAUIView *mainWindow = (REAUIView* )RCTKeyWindow(); if (_transitionContainer == nil) { _transitionContainer = [REAUIView new]; } diff --git a/apple/LayoutReanimation/REASnapshot.m b/apple/LayoutReanimation/REASnapshot.m index 51df531faca..d7cf1ddbffe 100644 --- a/apple/LayoutReanimation/REASnapshot.m +++ b/apple/LayoutReanimation/REASnapshot.m @@ -28,7 +28,7 @@ - (instancetype)initWithAbsolutePosition:(REAUIView *)view - (void)makeSnapshotForView:(REAUIView *)view useAbsolutePositionOnly:(BOOL)useAbsolutePositionOnly { - REAUIView *mainWindow = RCTKeyWindow(); + REAUIView *mainWindow = (REAUIView* )RCTKeyWindow(); CGPoint absolutePosition = [[view superview] convertPoint:view.center toView:nil]; _values = [NSMutableDictionary new]; #if TARGET_OS_OSX From c8adcc774c088abd7be533b3099370bfcada93d9 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Sun, 4 Feb 2024 01:25:42 +0100 Subject: [PATCH 3/5] Format iOS files --- apple/LayoutReanimation/REAAnimationsManager.m | 2 +- apple/LayoutReanimation/REASharedTransitionManager.m | 2 +- apple/LayoutReanimation/REASnapshot.m | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apple/LayoutReanimation/REAAnimationsManager.m b/apple/LayoutReanimation/REAAnimationsManager.m index 7eca632333a..05c2e9f2999 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.m +++ b/apple/LayoutReanimation/REAAnimationsManager.m @@ -250,7 +250,7 @@ - (void)setNewProps:(NSMutableDictionary *)newProps if (needsViewPositionUpdate) { CGPoint newCenter = CGPointMake(centerX, centerY); if (convertFromAbsolute) { - REAUIView *window = (REAUIView* )RCTKeyWindow(); + REAUIView *window = (REAUIView *)RCTKeyWindow(); CGPoint convertedCenter = [window convertPoint:newCenter toView:view.superview]; view.center = convertedCenter; } else { diff --git a/apple/LayoutReanimation/REASharedTransitionManager.m b/apple/LayoutReanimation/REASharedTransitionManager.m index fce3f39d472..659e3b53ce3 100644 --- a/apple/LayoutReanimation/REASharedTransitionManager.m +++ b/apple/LayoutReanimation/REASharedTransitionManager.m @@ -529,7 +529,7 @@ - (void)configureTransitionContainer { if (!_isSharedTransitionActive) { _isSharedTransitionActive = YES; - REAUIView *mainWindow = (REAUIView* )RCTKeyWindow(); + REAUIView *mainWindow = (REAUIView *)RCTKeyWindow(); if (_transitionContainer == nil) { _transitionContainer = [REAUIView new]; } diff --git a/apple/LayoutReanimation/REASnapshot.m b/apple/LayoutReanimation/REASnapshot.m index d7cf1ddbffe..4330238120e 100644 --- a/apple/LayoutReanimation/REASnapshot.m +++ b/apple/LayoutReanimation/REASnapshot.m @@ -1,9 +1,9 @@ #import #import #import +#import #import #import -#import NS_ASSUME_NONNULL_BEGIN @@ -28,7 +28,7 @@ - (instancetype)initWithAbsolutePosition:(REAUIView *)view - (void)makeSnapshotForView:(REAUIView *)view useAbsolutePositionOnly:(BOOL)useAbsolutePositionOnly { - REAUIView *mainWindow = (REAUIView* )RCTKeyWindow(); + REAUIView *mainWindow = (REAUIView *)RCTKeyWindow(); CGPoint absolutePosition = [[view superview] convertPoint:view.center toView:nil]; _values = [NSMutableDictionary new]; #if TARGET_OS_OSX From 6a2d4620e3100fbef71c7ca757bf29dd504c0570 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Wed, 7 Feb 2024 21:45:54 +0100 Subject: [PATCH 4/5] Fix MacOS compatibility --- MacOSExample/macos/Podfile.lock | 4 ++-- apple/LayoutReanimation/REAAnimationsManager.m | 6 +++++- apple/LayoutReanimation/REASharedTransitionManager.m | 4 ++++ apple/LayoutReanimation/REASnapshot.m | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/MacOSExample/macos/Podfile.lock b/MacOSExample/macos/Podfile.lock index 692b158be91..847a3706786 100644 --- a/MacOSExample/macos/Podfile.lock +++ b/MacOSExample/macos/Podfile.lock @@ -577,11 +577,11 @@ SPEC CHECKSUMS: ReactCommon: 6f2738740f0a5677dc3554112d49ce10d2b0a576 RNCAsyncStorage: c913ede1fa163a71cea118ed4670bbaaa4b511bb RNCPicker: 529d564911e93598cc399b56cc0769ce3675f8c8 - RNReanimated: 71dba8af3fcf22b055c801febf963fd3f3da6f73 + RNReanimated: ce7bb3c62611851fc282f079b8a4dd92b4dec414 RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396 SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: b01d8e70b1bc0e88b40040a7d9c50fdadb1054b9 PODFILE CHECKSUM: b964368aafa7380114b03271f85998831a6e0f0b -COCOAPODS: 1.14.2 +COCOAPODS: 1.14.3 diff --git a/apple/LayoutReanimation/REAAnimationsManager.m b/apple/LayoutReanimation/REAAnimationsManager.m index 05c2e9f2999..758bb1f7968 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.m +++ b/apple/LayoutReanimation/REAAnimationsManager.m @@ -250,7 +250,11 @@ - (void)setNewProps:(NSMutableDictionary *)newProps if (needsViewPositionUpdate) { CGPoint newCenter = CGPointMake(centerX, centerY); if (convertFromAbsolute) { - REAUIView *window = (REAUIView *)RCTKeyWindow(); +#if TARGET_OS_MAC + REAUIView *window = UIApplication.sharedApplication.keyWindow; +#else + REAUIView *window = RCTKeyWindow(); +#endif CGPoint convertedCenter = [window convertPoint:newCenter toView:view.superview]; view.center = convertedCenter; } else { diff --git a/apple/LayoutReanimation/REASharedTransitionManager.m b/apple/LayoutReanimation/REASharedTransitionManager.m index 659e3b53ce3..f5ac527c1b2 100644 --- a/apple/LayoutReanimation/REASharedTransitionManager.m +++ b/apple/LayoutReanimation/REASharedTransitionManager.m @@ -529,7 +529,11 @@ - (void)configureTransitionContainer { if (!_isSharedTransitionActive) { _isSharedTransitionActive = YES; +#if TARGET_OS_MAC + REAUIView *mainWindow = UIApplication.sharedApplication.keyWindow; +#else REAUIView *mainWindow = (REAUIView *)RCTKeyWindow(); +#endif if (_transitionContainer == nil) { _transitionContainer = [REAUIView new]; } diff --git a/apple/LayoutReanimation/REASnapshot.m b/apple/LayoutReanimation/REASnapshot.m index 4330238120e..ecdb4a520a5 100644 --- a/apple/LayoutReanimation/REASnapshot.m +++ b/apple/LayoutReanimation/REASnapshot.m @@ -28,7 +28,11 @@ - (instancetype)initWithAbsolutePosition:(REAUIView *)view - (void)makeSnapshotForView:(REAUIView *)view useAbsolutePositionOnly:(BOOL)useAbsolutePositionOnly { - REAUIView *mainWindow = (REAUIView *)RCTKeyWindow(); +#if TARGET_OS_MAC + REAUIView *mainWindow = UIApplication.sharedApplication.keyWindow; +#else + REAUIView *mainWindow = RCTKeyWindow(); +#endif CGPoint absolutePosition = [[view superview] convertPoint:view.center toView:nil]; _values = [NSMutableDictionary new]; #if TARGET_OS_OSX From 88f0423f0d2d9781f553c9b82654a4fa850d20a2 Mon Sep 17 00:00:00 2001 From: Krzysztof Piaskowy Date: Thu, 8 Feb 2024 09:52:56 +0100 Subject: [PATCH 5/5] Use TARGET_OS_OSX macro --- apple/LayoutReanimation/REAAnimationsManager.m | 2 +- apple/LayoutReanimation/REASharedTransitionManager.m | 2 +- apple/LayoutReanimation/REASnapshot.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apple/LayoutReanimation/REAAnimationsManager.m b/apple/LayoutReanimation/REAAnimationsManager.m index 758bb1f7968..0e626ddbafe 100644 --- a/apple/LayoutReanimation/REAAnimationsManager.m +++ b/apple/LayoutReanimation/REAAnimationsManager.m @@ -250,7 +250,7 @@ - (void)setNewProps:(NSMutableDictionary *)newProps if (needsViewPositionUpdate) { CGPoint newCenter = CGPointMake(centerX, centerY); if (convertFromAbsolute) { -#if TARGET_OS_MAC +#if TARGET_OS_OSX REAUIView *window = UIApplication.sharedApplication.keyWindow; #else REAUIView *window = RCTKeyWindow(); diff --git a/apple/LayoutReanimation/REASharedTransitionManager.m b/apple/LayoutReanimation/REASharedTransitionManager.m index f5ac527c1b2..3fc52c99ec2 100644 --- a/apple/LayoutReanimation/REASharedTransitionManager.m +++ b/apple/LayoutReanimation/REASharedTransitionManager.m @@ -529,7 +529,7 @@ - (void)configureTransitionContainer { if (!_isSharedTransitionActive) { _isSharedTransitionActive = YES; -#if TARGET_OS_MAC +#if TARGET_OS_OSX REAUIView *mainWindow = UIApplication.sharedApplication.keyWindow; #else REAUIView *mainWindow = (REAUIView *)RCTKeyWindow(); diff --git a/apple/LayoutReanimation/REASnapshot.m b/apple/LayoutReanimation/REASnapshot.m index ecdb4a520a5..832d3ea0f7b 100644 --- a/apple/LayoutReanimation/REASnapshot.m +++ b/apple/LayoutReanimation/REASnapshot.m @@ -28,7 +28,7 @@ - (instancetype)initWithAbsolutePosition:(REAUIView *)view - (void)makeSnapshotForView:(REAUIView *)view useAbsolutePositionOnly:(BOOL)useAbsolutePositionOnly { -#if TARGET_OS_MAC +#if TARGET_OS_OSX REAUIView *mainWindow = UIApplication.sharedApplication.keyWindow; #else REAUIView *mainWindow = RCTKeyWindow();