Skip to content

Commit d0b77b3

Browse files
authored
feat(ios): add support for visionOS (#797)
1 parent 7c30957 commit d0b77b3

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

ios/Fabric/RNCPagerViewComponentView.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ -(void)prepareForRecycle {
122122
}
123123

124124
- (void)shouldDismissKeyboard:(RNCViewPagerKeyboardDismissMode)dismissKeyboard {
125+
#if !TARGET_OS_VISION
125126
UIScrollViewKeyboardDismissMode dismissKeyboardMode = UIScrollViewKeyboardDismissModeNone;
126127
switch (dismissKeyboard) {
127128
case RNCViewPagerKeyboardDismissMode::None:
@@ -132,6 +133,7 @@ - (void)shouldDismissKeyboard:(RNCViewPagerKeyboardDismissMode)dismissKeyboard {
132133
break;
133134
}
134135
scrollView.keyboardDismissMode = dismissKeyboardMode;
136+
#endif
135137
}
136138

137139

ios/ReactNativePageView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ NS_ASSUME_NONNULL_BEGIN
1515
@property(nonatomic) NSInteger currentIndex;
1616
@property(nonatomic) NSInteger pageMargin;
1717
@property(nonatomic, readonly) BOOL scrollEnabled;
18+
#if !TARGET_OS_VISION
1819
@property(nonatomic, readonly) UIScrollViewKeyboardDismissMode dismissKeyboard;
20+
#endif
1921
@property(nonatomic) UIPageViewControllerNavigationOrientation orientation;
2022
@property(nonatomic, copy) RCTDirectEventBlock onPageSelected;
2123
@property(nonatomic, copy) RCTDirectEventBlock onPageScroll;

ios/ReactNativePageView.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher {
4141
_destinationIndex = -1;
4242
_orientation = UIPageViewControllerNavigationOrientationHorizontal;
4343
_currentIndex = 0;
44+
#if !TARGET_OS_VISION
4445
_dismissKeyboard = UIScrollViewKeyboardDismissModeNone;
46+
#endif
4547
_coalescingKey = 0;
4648
_eventDispatcher = eventDispatcher;
4749
_cachedControllers = [NSHashTable hashTableWithOptions:NSHashTableStrongMemory];
@@ -102,7 +104,9 @@ - (void)embed {
102104
for (UIView *subview in pageViewController.view.subviews) {
103105
if([subview isKindOfClass:UIScrollView.class]){
104106
((UIScrollView *)subview).delegate = self;
107+
#if !TARGET_OS_VISION
105108
((UIScrollView *)subview).keyboardDismissMode = _dismissKeyboard;
109+
#endif
106110
((UIScrollView *)subview).delaysContentTouches = YES;
107111
self.scrollView = (UIScrollView *)subview;
108112
}
@@ -128,9 +132,11 @@ - (void)shouldScroll:(BOOL)scrollEnabled {
128132
}
129133

130134
- (void)shouldDismissKeyboard:(NSString *)dismissKeyboard {
135+
#if !TARGET_OS_VISION
131136
_dismissKeyboard = [dismissKeyboard isEqual: @"on-drag"] ?
132137
UIScrollViewKeyboardDismissModeOnDrag : UIScrollViewKeyboardDismissModeNone;
133138
self.scrollView.keyboardDismissMode = _dismissKeyboard;
139+
#endif
134140
}
135141

136142
- (void)setupInitialController {

react-native-pager-view.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
1111
s.license = package["license"]
1212
s.authors = package["author"]
1313

14-
s.platforms = { :ios => "10.0" }
14+
s.platforms = { :ios => "10.0", :visionos => "1.0" }
1515
s.source = { :git => "https://github.com/callstack/react-native-pager-view.git", :tag => "#{s.version}" }
1616

1717
s.source_files = "ios/**/*.{h,m,mm}"

0 commit comments

Comments
 (0)