diff --git a/apps/bare-expo/package.json b/apps/bare-expo/package.json index 457ea963f77c5..384f98ca0a5d6 100644 --- a/apps/bare-expo/package.json +++ b/apps/bare-expo/package.json @@ -79,7 +79,7 @@ }, "dependencies": { "@babel/runtime": "^7.5.5", - "@react-native-community/segmented-control": "^1.4.0", + "@react-native-community/segmented-control": "1.6.1", "@react-navigation/web": "2.0.0-alpha.0", "expo": "~37.0.6", "expo-image": "~1.0.0-alpha.0", diff --git a/apps/native-component-list/package.json b/apps/native-component-list/package.json index 791dbf1e20a52..a707599301aa5 100644 --- a/apps/native-component-list/package.json +++ b/apps/native-component-list/package.json @@ -16,7 +16,7 @@ "@react-native-community/datetimepicker": "2.2.2", "@react-native-community/masked-view": "0.1.6", "@react-native-community/netinfo": "5.5.0", - "@react-native-community/segmented-control": "^1.4.0", + "@react-native-community/segmented-control": "1.6.1", "@react-native-community/viewpager": "3.3.0", "@react-navigation/web": "2.0.0-alpha.0", "date-format": "^2.0.0", diff --git a/ios/Exponent.xcodeproj/project.pbxproj b/ios/Exponent.xcodeproj/project.pbxproj index 94128e04bdc13..06c016f2c176a 100644 --- a/ios/Exponent.xcodeproj/project.pbxproj +++ b/ios/Exponent.xcodeproj/project.pbxproj @@ -223,7 +223,6 @@ B2B492172462F5EF001576D8 /* EXScopedNotificationsEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B492162462F5EF001576D8 /* EXScopedNotificationsEmitter.m */; }; B236C4F324740C1E00D0CB66 /* EXScopedNotificationSchedulerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = B236C4F224740C1E00D0CB66 /* EXScopedNotificationSchedulerModule.m */; }; B23D9AA324758C6600D09AC8 /* EXScopedNotificationPresentationModule.m in Sources */ = {isa = PBXBuildFile; fileRef = B23D9AA224758C6600D09AC8 /* EXScopedNotificationPresentationModule.m */; }; - B2B492172462F5EF001576D8 /* EXScopedNotificationsEmitter.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B492162462F5EF001576D8 /* EXScopedNotificationsEmitter.m */; }; B2F7C02B246B09890060EE06 /* EXScopedNotificationsHandlerModule.m in Sources */ = {isa = PBXBuildFile; fileRef = B2F7C02A246B09890060EE06 /* EXScopedNotificationsHandlerModule.m */; }; B2F7C02E246B09AE0060EE06 /* EXScopedNotificationsUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = B2F7C02D246B09AE0060EE06 /* EXScopedNotificationsUtils.m */; }; B4FF3D8631BB48D290E44742 /* RNCConnectionState.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FE9493F87604B4B8CBB87C8 /* RNCConnectionState.m */; settings = {COMPILER_FLAGS = "-w"; }; }; @@ -343,6 +342,8 @@ F77DDB931E04AC1100624CA2 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F77DDB921E04AC1100624CA2 /* SafariServices.framework */; }; FA526593B78C87A7E1C34561 /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D8BAB8D6102FB06BE5BE10B /* libPods-Tests.a */; }; F581B81CB601426CB5658AEE /* RNSharedElementCornerRadii.m in Sources */ = {isa = PBXBuildFile; fileRef = 780F0BF062134A048B33344C /* RNSharedElementCornerRadii.m */; settings = {COMPILER_FLAGS = "-w"; }; }; + 97635343A010490BBF92C76F /* RNCSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = C5DF76A1DCE14D2F9460F314 /* RNCSegmentedControl.m */; settings = {COMPILER_FLAGS = "-w"; }; }; + E75397FDFB6B4FF780EA612A /* RNCSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F502F71E43A44658A6B20C26 /* RNCSegmentedControlManager.m */; settings = {COMPILER_FLAGS = "-w"; }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1047,6 +1048,10 @@ FA872B0AA66044B4B8C574F0 /* RNSScreenStack.h */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 4; includeInIndex = 0; lastKnownFileType = sourcecode.c.h; path = RNSScreenStack.h; sourceTree = ""; }; 57C7EC4AED92477D8C6743E0 /* RNSharedElementCornerRadii.h */ = {isa = PBXFileReference; name = "RNSharedElementCornerRadii.h"; path = "RNSharedElementCornerRadii.h"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; }; 780F0BF062134A048B33344C /* RNSharedElementCornerRadii.m */ = {isa = PBXFileReference; name = "RNSharedElementCornerRadii.m"; path = "RNSharedElementCornerRadii.m"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; }; + B1BEB7E458624CEBA53B3CE8 /* RNCSegmentedControl.h */ = {isa = PBXFileReference; name = "RNCSegmentedControl.h"; path = "RNCSegmentedControl.h"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; }; + C5DF76A1DCE14D2F9460F314 /* RNCSegmentedControl.m */ = {isa = PBXFileReference; name = "RNCSegmentedControl.m"; path = "RNCSegmentedControl.m"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; }; + 9F02F7D4DDFF4D76804115FF /* RNCSegmentedControlManager.h */ = {isa = PBXFileReference; name = "RNCSegmentedControlManager.h"; path = "RNCSegmentedControlManager.h"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; }; + F502F71E43A44658A6B20C26 /* RNCSegmentedControlManager.m */ = {isa = PBXFileReference; name = "RNCSegmentedControlManager.m"; path = "RNCSegmentedControlManager.m"; sourceTree = ""; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -2085,6 +2090,7 @@ E3BD4F6E1BF543B697AFB794 /* DateTimePicker */, 6999211AF26A46738FB9E106 /* MaskedView */, 69CAB43F632147D3A686A75B /* ViewPager */, + F10D02089BA74515B49FBBC2 /* SegmentedControl */, ); path = Components; sourceTree = ""; @@ -2356,6 +2362,18 @@ path = "Build-Phases"; sourceTree = ""; }; + F10D02089BA74515B49FBBC2 /* SegmentedControl */ = { + isa = PBXGroup; + children = ( + B1BEB7E458624CEBA53B3CE8 /* RNCSegmentedControl.h */, + C5DF76A1DCE14D2F9460F314 /* RNCSegmentedControl.m */, + 9F02F7D4DDFF4D76804115FF /* RNCSegmentedControlManager.h */, + F502F71E43A44658A6B20C26 /* RNCSegmentedControlManager.m */, + ); + name = SegmentedControl; + path = SegmentedControl; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -2967,6 +2985,8 @@ B75F881E8F9641B785F76CB0 /* RNSVGForeignObject.m in Sources */, C1A9EE2CB1DF4BD8936C3C7F /* RNSVGForeignObjectManager.m in Sources */, F581B81CB601426CB5658AEE /* RNSharedElementCornerRadii.m in Sources */, + 97635343A010490BBF92C76F /* RNCSegmentedControl.m in Sources */, + E75397FDFB6B4FF780EA612A /* RNCSegmentedControlManager.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControl.h b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControl.h similarity index 87% rename from ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControl.h rename to ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControl.h index f64aaff560b86..6c936c220f884 100644 --- a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControl.h +++ b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControl.h @@ -10,7 +10,7 @@ #import @interface RNCSegmentedControl : UISegmentedControl - +@property (nonatomic, copy) NSMutableDictionary *attributes; @property (nonatomic, assign) NSInteger selectedIndex; @property (nonatomic, copy) RCTBubblingEventBlock onChange; diff --git a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControl.m b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControl.m similarity index 74% rename from ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControl.m rename to ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControl.m index a883ff2402139..72eba44c01b61 100644 --- a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControl.m +++ b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControl.m @@ -19,6 +19,7 @@ - (instancetype)initWithFrame:(CGRect)frame _selectedIndex = self.selectedSegmentIndex; [self addTarget:self action:@selector(didChange) forControlEvents:UIControlEventValueChanged]; + _attributes = [[NSMutableDictionary alloc] init]; } return self; } @@ -38,6 +39,18 @@ - (void)setSelectedIndex:(NSInteger)selectedIndex super.selectedSegmentIndex = selectedIndex; } +- (void)setFontSize:(NSInteger)fontSize +{ + UIFont *font = [UIFont systemFontOfSize: fontSize]; + [_attributes setObject: font forKey:NSFontAttributeName]; + [self setTitleTextAttributes:_attributes + forState:UIControlStateNormal]; + UIFont *fontBold = [UIFont boldSystemFontOfSize: fontSize]; + [_attributes setObject: fontBold forKey:NSFontAttributeName]; + [self setTitleTextAttributes:_attributes + forState:UIControlStateSelected]; +} + - (void)setBackgroundColor:(UIColor *)backgroundColor { #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \ @@ -53,8 +66,9 @@ - (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]; + [_attributes setObject: textColor forKey:NSForegroundColorAttributeName]; + [self setTitleTextAttributes:_attributes + forState:UIControlStateNormal]; } #endif } @@ -64,7 +78,8 @@ - (void)setActiveTextColor:(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} + [_attributes setObject: textColor forKey:NSForegroundColorAttributeName]; + [self setTitleTextAttributes:_attributes forState:UIControlStateSelected]; } #endif @@ -77,8 +92,9 @@ - (void)setTintColor:(UIColor *)tintColor __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0 if (@available(iOS 13.0, *)) { [self setSelectedSegmentTintColor:tintColor]; - [self setTitleTextAttributes:@{NSForegroundColorAttributeName: tintColor} - forState:UIControlStateNormal]; + [_attributes setObject: tintColor forKey:NSForegroundColorAttributeName]; + [self setTitleTextAttributes:_attributes + forState:UIControlStateNormal]; } #endif } diff --git a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControlManager.h b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControlManager.h similarity index 100% rename from ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControlManager.h rename to ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControlManager.h diff --git a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControlManager.m b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControlManager.m similarity index 95% rename from ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControlManager.m rename to ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControlManager.m index 0e7ddbe70989c..1f1a50d648faf 100644 --- a/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNSegmentedControlManager.m +++ b/ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/RNCSegmentedControlManager.m @@ -25,6 +25,7 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(textColor, UIColor) +RCT_EXPORT_VIEW_PROPERTY(fontSize, NSInteger) RCT_EXPORT_VIEW_PROPERTY(activeTextColor, UIColor) RCT_EXPORT_VIEW_PROPERTY(momentary, BOOL) RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL) diff --git a/packages/expo/bundledNativeModules.json b/packages/expo/bundledNativeModules.json index 5b922268f1c1b..62bfa4cc5941a 100644 --- a/packages/expo/bundledNativeModules.json +++ b/packages/expo/bundledNativeModules.json @@ -90,7 +90,7 @@ "@react-native-community/datetimepicker": "2.2.2", "@react-native-community/masked-view": "0.1.6", "@react-native-community/viewpager": "3.3.0", - "@react-native-community/segmented-control": "1.4.0", + "@react-native-community/segmented-control": "1.6.1", "expo-error-recovery": "~1.1.0", "expo-module-template": "~8.2.0", "expo-image-loader": "~1.0.1", diff --git a/yarn.lock b/yarn.lock index 6be5aba7a4e1e..ea5d15a1155a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2414,7 +2414,7 @@ resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-5.5.0.tgz#7f1d2e301b8a1294da44fb44d7b3fd6ea4d40c8a" integrity sha512-9fdOk1dxR3Bt+T4OuQxhf7EjyfbI6qVbPcNfTvVjGgRrx798ixAbBcCC+k5wp3LloVChVicXkyblu+wXEGiCWw== -"@react-native-community/segmented-control@^1.4.0": +"@react-native-community/segmented-control@1.6.1": version "1.6.1" resolved "https://registry.yarnpkg.com/@react-native-community/segmented-control/-/segmented-control-1.6.1.tgz#47c5eb20664376e390c3412d9a7242c2df35cdb0" integrity sha512-6TCrkDHgchKU2RA0r+V49Uwvv9mMhLKCwx7sf6Jkj0D4RYs+qmxYFjoM82bOcaH2kOVF+cvRvABRn0Ai0my5LA==