From b84f5fb6c9db79f378eed26c19e299d87c4852bf Mon Sep 17 00:00:00 2001 From: Jean Regisser Date: Wed, 27 Jan 2016 10:16:10 -0800 Subject: [PATCH] Added iOS indicatorStyle prop to ScrollView Summary: Hi, The doc wording was adapted from https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/#//apple_ref/doc/c_ref/UIScrollViewIndicatorStyle Note that the iOS doc is misleading, and `UIScrollViewIndicatorStyleDefault` is the same as `UIScrollViewIndicatorStyleBlack` (since iOS 7 I think). Let me know what you think. Closes https://github.com/facebook/react-native/pull/5583 Reviewed By: svcscm Differential Revision: D2870011 Pulled By: nicklockwood fb-gh-sync-id: d28a96e1a2d4610cbeaee0ae70108ab9d9f05fdb --- Libraries/Components/ScrollView/ScrollView.js | 13 +++++++++++++ React/Views/RCTScrollView.m | 1 + React/Views/RCTScrollViewManager.m | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 7556e9c71..fb8d1452c 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -141,6 +141,18 @@ var ScrollView = React.createClass({ * instead of vertically in a column. The default value is false. */ horizontal: PropTypes.bool, + /** + * The style of the scroll indicators. + * - `default` (the default), same as `black`. + * - `black`, scroll indicator is black. This style is good against a white content background. + * - `white`, scroll indicator is white. This style is good against a black content background. + * @platform ios + */ + indicatorStyle: PropTypes.oneOf([ + 'default', // default + 'black', + 'white', + ]), /** * When true, the ScrollView will try to lock to only vertical or horizontal * scrolling while dragging. The default value is false. @@ -524,6 +536,7 @@ var validAttributes = { contentOffset: {diff: pointsDiffer}, decelerationRate: true, horizontal: true, + indicatorStyle: true, keyboardDismissMode: true, keyboardShouldPersistTaps: true, maximumZoomScale: true, diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index de9bcb273..c69aabb19 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -838,6 +838,7 @@ RCT_SET_AND_PRESERVE_OFFSET(setBouncesZoom, BOOL) RCT_SET_AND_PRESERVE_OFFSET(setCanCancelContentTouches, BOOL) RCT_SET_AND_PRESERVE_OFFSET(setDecelerationRate, CGFloat) RCT_SET_AND_PRESERVE_OFFSET(setDirectionalLockEnabled, BOOL) +RCT_SET_AND_PRESERVE_OFFSET(setIndicatorStyle, UIScrollViewIndicatorStyle) RCT_SET_AND_PRESERVE_OFFSET(setKeyboardDismissMode, UIScrollViewKeyboardDismissMode) RCT_SET_AND_PRESERVE_OFFSET(setMaximumZoomScale, CGFloat) RCT_SET_AND_PRESERVE_OFFSET(setMinimumZoomScale, CGFloat) diff --git a/React/Views/RCTScrollViewManager.m b/React/Views/RCTScrollViewManager.m index 549bc1fac..2d48c0cb6 100644 --- a/React/Views/RCTScrollViewManager.m +++ b/React/Views/RCTScrollViewManager.m @@ -29,6 +29,12 @@ RCT_ENUM_CONVERTER(UIScrollViewKeyboardDismissMode, (@{ @"onDrag": @(UIScrollViewKeyboardDismissModeOnDrag), }), UIScrollViewKeyboardDismissModeNone, integerValue) +RCT_ENUM_CONVERTER(UIScrollViewIndicatorStyle, (@{ + @"default": @(UIScrollViewIndicatorStyleDefault), + @"black": @(UIScrollViewIndicatorStyleBlack), + @"white": @(UIScrollViewIndicatorStyleWhite), +}), UIScrollViewIndicatorStyleDefault, integerValue) + @end @implementation RCTScrollViewManager @@ -49,6 +55,7 @@ RCT_EXPORT_VIEW_PROPERTY(centerContent, BOOL) RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL) RCT_EXPORT_VIEW_PROPERTY(decelerationRate, CGFloat) RCT_EXPORT_VIEW_PROPERTY(directionalLockEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(indicatorStyle, UIScrollViewIndicatorStyle) RCT_EXPORT_VIEW_PROPERTY(keyboardDismissMode, UIScrollViewKeyboardDismissMode) RCT_EXPORT_VIEW_PROPERTY(maximumZoomScale, CGFloat) RCT_EXPORT_VIEW_PROPERTY(minimumZoomScale, CGFloat)