From 2653b421869b50afcb396a77909510534b8d51ae Mon Sep 17 00:00:00 2001 From: Tomasz Sapeta <1714764+tsapeta@users.noreply.github.com> Date: Fri, 22 May 2020 20:03:46 +0200 Subject: [PATCH] [segmented-control] Upgrade @react-native-community/segmented-control to 1.6.1 (#8441) --- CHANGELOG.md | 1 + apps/bare-expo/package.json | 2 +- apps/native-component-list/package.json | 2 +- ios/Exponent.xcodeproj/project.pbxproj | 22 +++++++++++++++- ...gmentedControl.h => RNCSegmentedControl.h} | 2 +- ...gmentedControl.m => RNCSegmentedControl.m} | 26 +++++++++++++++---- ...Manager.h => RNCSegmentedControlManager.h} | 0 ...Manager.m => RNCSegmentedControlManager.m} | 1 + packages/expo/bundledNativeModules.json | 2 +- yarn.lock | 2 +- 10 files changed, 49 insertions(+), 11 deletions(-) rename ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/{RNSegmentedControl.h => RNCSegmentedControl.h} (87%) rename ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/{RNSegmentedControl.m => RNCSegmentedControl.m} (74%) rename ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/{RNSegmentedControlManager.h => RNCSegmentedControlManager.h} (100%) rename ios/Exponent/Versioned/Core/Api/Components/SegmentedControl/{RNSegmentedControlManager.m => RNCSegmentedControlManager.m} (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 014aa4ef348cf..12833ffd5f525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Package-specific changes not released in any SDK will be added here just before ### 🎉 New features - Initial release of **`expo-notifications`** 🥳 +- Added `@react-native-community/segmented-control` in version `1.6.1`. ([#8038](https://github.com/expo/expo/pull/8038) by [@marchenk0va](https://github.com/marchenk0va) and [#8441](https://github.com/expo/expo/pull/8441) by [@tsapeta](https://github.com/tsapeta)) - **`expo-apple-authentication`** - Add 'Sign up with Apple' option (available as of iOS 13.2). ([#7471](https://github.com/expo/expo/pull/7471) by [@IjzerenHein](https://github.com/IjzerenHein)) - **`expo-file-system`** diff --git a/apps/bare-expo/package.json b/apps/bare-expo/package.json index dc1053df33284..93db78a712322 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 5e94d3f2102ea..b643c2edc1c99 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.9.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 7d530a33401ab..a3d6dd2300e0b 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 2f365cc2a762f..bdac1236179f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2414,7 +2414,7 @@ resolved "https://registry.yarnpkg.com/@react-native-community/netinfo/-/netinfo-5.9.0.tgz#8bf2b96ce66ecaacab5a1f6f88b41526c9331481" integrity sha512-rzchLeRkJRXw7ILO4OAMqVP33hEJ754FN2qf85+V1th9ozelXezh4DX90lmxk0PgJpZMwHXUNqS2ltsrzmahXg== -"@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==