diff --git a/ios/Fabric/RNCPagerViewComponentView.mm b/ios/Fabric/RNCPagerViewComponentView.mm index 8efd1baf..440f65e4 100644 --- a/ios/Fabric/RNCPagerViewComponentView.mm +++ b/ios/Fabric/RNCPagerViewComponentView.mm @@ -122,6 +122,7 @@ -(void)prepareForRecycle { } - (void)shouldDismissKeyboard:(RNCViewPagerKeyboardDismissMode)dismissKeyboard { +#if !TARGET_OS_VISION UIScrollViewKeyboardDismissMode dismissKeyboardMode = UIScrollViewKeyboardDismissModeNone; switch (dismissKeyboard) { case RNCViewPagerKeyboardDismissMode::None: @@ -132,6 +133,7 @@ - (void)shouldDismissKeyboard:(RNCViewPagerKeyboardDismissMode)dismissKeyboard { break; } scrollView.keyboardDismissMode = dismissKeyboardMode; +#endif } diff --git a/ios/ReactNativePageView.h b/ios/ReactNativePageView.h index 8887fd22..5f9fa8cb 100644 --- a/ios/ReactNativePageView.h +++ b/ios/ReactNativePageView.h @@ -15,7 +15,9 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic) NSInteger currentIndex; @property(nonatomic) NSInteger pageMargin; @property(nonatomic, readonly) BOOL scrollEnabled; +#if !TARGET_OS_VISION @property(nonatomic, readonly) UIScrollViewKeyboardDismissMode dismissKeyboard; +#endif @property(nonatomic) UIPageViewControllerNavigationOrientation orientation; @property(nonatomic, copy) RCTDirectEventBlock onPageSelected; @property(nonatomic, copy) RCTDirectEventBlock onPageScroll; diff --git a/ios/ReactNativePageView.m b/ios/ReactNativePageView.m index d7b6c3a4..01e7f8eb 100644 --- a/ios/ReactNativePageView.m +++ b/ios/ReactNativePageView.m @@ -41,7 +41,9 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher { _destinationIndex = -1; _orientation = UIPageViewControllerNavigationOrientationHorizontal; _currentIndex = 0; +#if !TARGET_OS_VISION _dismissKeyboard = UIScrollViewKeyboardDismissModeNone; +#endif _coalescingKey = 0; _eventDispatcher = eventDispatcher; _cachedControllers = [NSHashTable hashTableWithOptions:NSHashTableStrongMemory]; @@ -102,7 +104,9 @@ - (void)embed { for (UIView *subview in pageViewController.view.subviews) { if([subview isKindOfClass:UIScrollView.class]){ ((UIScrollView *)subview).delegate = self; +#if !TARGET_OS_VISION ((UIScrollView *)subview).keyboardDismissMode = _dismissKeyboard; +#endif ((UIScrollView *)subview).delaysContentTouches = YES; self.scrollView = (UIScrollView *)subview; } @@ -128,9 +132,11 @@ - (void)shouldScroll:(BOOL)scrollEnabled { } - (void)shouldDismissKeyboard:(NSString *)dismissKeyboard { +#if !TARGET_OS_VISION _dismissKeyboard = [dismissKeyboard isEqual: @"on-drag"] ? UIScrollViewKeyboardDismissModeOnDrag : UIScrollViewKeyboardDismissModeNone; self.scrollView.keyboardDismissMode = _dismissKeyboard; +#endif } - (void)setupInitialController { diff --git a/react-native-pager-view.podspec b/react-native-pager-view.podspec index 82e16c59..879a39fc 100644 --- a/react-native-pager-view.podspec +++ b/react-native-pager-view.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.license = package["license"] s.authors = package["author"] - s.platforms = { :ios => "10.0" } + s.platforms = { :ios => "10.0", :visionos => "1.0" } s.source = { :git => "https://github.com/callstack/react-native-pager-view.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm}"