diff --git a/apple/RNCWebView.mm b/apple/RNCWebView.mm index cf7f6a5db..78dd8389d 100644 --- a/apple/RNCWebView.mm +++ b/apple/RNCWebView.mm @@ -303,6 +303,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & REMAP_WEBVIEW_PROP(directionalLockEnabled) REMAP_WEBVIEW_PROP(showsHorizontalScrollIndicator) REMAP_WEBVIEW_PROP(showsVerticalScrollIndicator) + REMAP_WEBVIEW_PROP(forceLightScrollIndicators) REMAP_WEBVIEW_PROP(keyboardDisplayRequiresUserAction) #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */ diff --git a/apple/RNCWebViewImpl.h b/apple/RNCWebViewImpl.h index be285ef1f..fc635e08e 100644 --- a/apple/RNCWebViewImpl.h +++ b/apple/RNCWebViewImpl.h @@ -93,6 +93,7 @@ shouldStartLoadForRequest:(NSMutableDictionary *)request @property (nonatomic, assign) BOOL allowsLinkPreview; @property (nonatomic, assign) BOOL showsHorizontalScrollIndicator; @property (nonatomic, assign) BOOL showsVerticalScrollIndicator; +@property (nonatomic, assign) BOOL forceLightScrollIndicators; @property (nonatomic, assign) BOOL directionalLockEnabled; @property (nonatomic, assign) BOOL ignoreSilentHardwareSwitch; @property (nonatomic, copy) NSString * _Nullable allowingReadAccessToURL; diff --git a/apple/RNCWebViewImpl.m b/apple/RNCWebViewImpl.m index baade1760..bd04f7d40 100644 --- a/apple/RNCWebViewImpl.m +++ b/apple/RNCWebViewImpl.m @@ -165,6 +165,7 @@ - (instancetype)initWithFrame:(CGRect)frame _scrollEnabled = YES; _showsHorizontalScrollIndicator = YES; _showsVerticalScrollIndicator = YES; + _forceLightScrollIndicators = NO; _directionalLockEnabled = YES; _automaticallyAdjustContentInsets = YES; _autoManageStatusBarEnabled = YES; @@ -497,6 +498,12 @@ - (void)didMoveToWindow _webView.scrollView.bounces = _pullToRefreshEnabled || _bounces; _webView.scrollView.showsHorizontalScrollIndicator = _showsHorizontalScrollIndicator; _webView.scrollView.showsVerticalScrollIndicator = _showsVerticalScrollIndicator; + if(_forceLightScrollIndicators){ + _webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; + } + else{ + _webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleDefault; + } _webView.scrollView.directionalLockEnabled = _directionalLockEnabled; #endif // !TARGET_OS_OSX _webView.allowsLinkPreview = _allowsLinkPreview; @@ -1023,6 +1030,19 @@ - (void)setShowsVerticalScrollIndicator:(BOOL)showsVerticalScrollIndicator _showsVerticalScrollIndicator = showsVerticalScrollIndicator; _webView.scrollView.showsVerticalScrollIndicator = showsVerticalScrollIndicator; } + + +- (void)setForceLightScrollIndicators:(BOOL)forceLightScrollIndicators +{ + _forceLightScrollIndicators = forceLightScrollIndicators; + + if(_forceLightScrollIndicators){ + _webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; + } + else{ + _webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleDefault; + } +} #endif // !TARGET_OS_OSX - (void)postMessage:(NSString *)message diff --git a/apple/RNCWebViewManager.mm b/apple/RNCWebViewManager.mm index bb2f91301..09edcd274 100644 --- a/apple/RNCWebViewManager.mm +++ b/apple/RNCWebViewManager.mm @@ -171,6 +171,10 @@ - (RNCView *)view view.showsVerticalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json]; } +RCT_CUSTOM_VIEW_PROPERTY(forceLightScrollIndicators, BOOL, RNCWebViewImpl) { + view.forceLightScrollIndicators = json == nil ? true : [RCTConvert BOOL: json]; +} + RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWebViewImpl) { view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json]; } diff --git a/src/RNCWebViewNativeComponent.ts b/src/RNCWebViewNativeComponent.ts index 9eccbc1d3..0c34bcc59 100644 --- a/src/RNCWebViewNativeComponent.ts +++ b/src/RNCWebViewNativeComponent.ts @@ -243,6 +243,7 @@ export interface NativeProps extends ViewProps { onShouldStartLoadWithRequest: DirectEventHandler; showsHorizontalScrollIndicator?: boolean; showsVerticalScrollIndicator?: boolean; + forceLightScrollIndicators?: boolean; newSource: Readonly<{ uri?: string method?: string; diff --git a/src/WebViewTypes.ts b/src/WebViewTypes.ts index 2bf2a734d..5cc97e9e0 100644 --- a/src/WebViewTypes.ts +++ b/src/WebViewTypes.ts @@ -315,6 +315,7 @@ export interface CommonNativeWebViewProps extends ViewProps { onShouldStartLoadWithRequest: (event: ShouldStartLoadRequestEvent) => void; showsHorizontalScrollIndicator?: boolean; showsVerticalScrollIndicator?: boolean; + forceLightScrollIndicators?: boolean; // TODO: find a better way to type this. // eslint-disable-next-line @typescript-eslint/no-explicit-any source: any; @@ -1261,6 +1262,13 @@ export interface WebViewSharedProps extends ViewProps { */ showsVerticalScrollIndicator?: boolean; + /** + * Boolean value that determines whether a light scrollbar is + * shown in the `WebView`. The default value is `false`. + * @platform ios + */ + forceLightScrollIndicators?: boolean; + /** * Boolean that determines whether HTML5 audio and video requires the user * to tap them before they start playing. The default value is `true`.