diff --git a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js index 405ab500acc589..8923582c394f74 100644 --- a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +++ b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js @@ -33,6 +33,8 @@ type NativeProps = $ReadOnly<{| selectedIndex?: WithDefault, enabled?: WithDefault, tintColor?: ?ColorValue, + textColor?: ?ColorValue, + backgroundColor?: ?ColorValue, momentary?: WithDefault, // Events diff --git a/React/Views/RCTSegmentedControl.m b/React/Views/RCTSegmentedControl.m index 5df69e71468933..6c1f1b9f47ad2e 100644 --- a/React/Views/RCTSegmentedControl.m +++ b/React/Views/RCTSegmentedControl.m @@ -39,6 +39,27 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex super.selectedSegmentIndex = selectedIndex; } +- (void)setBackgroundColor:(UIColor *)backgroundColor +{ + #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) { + [super setBackgroundColor:backgroundColor]; + } + #endif +} + +- (void)setTextColor:(UIColor *)textColor +{ + #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 + if (@available(iOS 13.0, *)) { + [self setTitleTextAttributes:@{NSForegroundColorAttributeName: textColor} + forState:UIControlStateNormal]; + } + #endif +} + - (void)setTintColor:(UIColor *)tintColor { [super setTintColor:tintColor]; diff --git a/React/Views/RCTSegmentedControlManager.m b/React/Views/RCTSegmentedControlManager.m index 8b3573ab485ec6..a5e921d3c1e4f1 100644 --- a/React/Views/RCTSegmentedControlManager.m +++ b/React/Views/RCTSegmentedControlManager.m @@ -23,6 +23,8 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(values, NSArray) RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger) RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor) +RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor) +RCT_EXPORT_VIEW_PROPERTY(textColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL) RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock) diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java index e3c7505a86b9f7..f79e5189d97275 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerDelegate.java @@ -35,6 +35,12 @@ public void setProperty(T view, String propName, @Nullable Object value) { case "tintColor": mViewManager.setTintColor(view, value == null ? null : ((Double) value).intValue()); break; + case "textColor": + mViewManager.setTextColor(view, value == null ? null : ((Double) value).intValue()); + break; + case "backgroundColor": + mViewManager.setBackgroundColor(view, value == null ? null : ((Double) value).intValue()); + break; case "momentary": mViewManager.setMomentary(view, value == null ? false : (boolean) value); break; diff --git a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java index e6c50357616b50..0ee9d56850941d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java +++ b/ReactAndroid/src/main/java/com/facebook/react/viewmanagers/SegmentedControlManagerInterface.java @@ -18,5 +18,7 @@ public interface SegmentedControlManagerInterface { void setSelectedIndex(T view, int value); void setEnabled(T view, boolean value); void setTintColor(T view, @Nullable Integer value); + void setTextColor(T view, @Nullable Integer value); + void setBackgroundColor(T view, @Nullable Integer value); void setMomentary(T view, boolean value); }