Skip to content

Commit

Permalink
fix(macOS): Don't include iOS pull-to-refresh control (react-native-w…
Browse files Browse the repository at this point in the history
…ebview#1636)

* Update RNCWebView.h

Limit methods relating to pull to refresh to only iOS

* Update RNCWebView.m

Block methods relating to pull to refresh when the target is macOS as macOS does not have the UIRefreshControl

Co-authored-by: Eloy Durán <[email protected]>
  • Loading branch information
bralax and alloy authored Oct 5, 2020
1 parent f204195 commit dbf4659
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions apple/RNCWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
@property (nonatomic, assign) BOOL ignoreSilentHardwareSwitch;
@property (nonatomic, copy) NSString * _Nullable allowingReadAccessToURL;
@property (nonatomic, assign) BOOL pullToRefreshEnabled;
#if !TARGET_OS_OSX
@property (nonatomic, weak) UIRefreshControl * refreshControl;
#endif

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* iOS 13 */
@property (nonatomic, assign) WKContentMode contentMode;
Expand All @@ -78,7 +80,9 @@
- (void)goBack;
- (void)reload;
- (void)stopLoading;
#if !TARGET_OS_OSX
- (void)addPullToRefreshControl;
- (void)pullToRefresh:(UIRefreshControl *)refreshControl;
#endif

@end
4 changes: 2 additions & 2 deletions apple/RNCWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ - (void)reload
[_webView reload];
}
}

#if !TARGET_OS_OSX
- (void)addPullToRefreshControl
{
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
Expand All @@ -1151,7 +1151,7 @@ - (void)pullToRefresh:(UIRefreshControl *)refreshControl
[refreshControl endRefreshing];
}

#if !TARGET_OS_OSX

- (void)setPullToRefreshEnabled:(BOOL)pullToRefreshEnabled
{
_pullToRefreshEnabled = pullToRefreshEnabled;
Expand Down

0 comments on commit dbf4659

Please sign in to comment.