Skip to content

Commit

Permalink
[segmented-control] Upgrade @react-native-community/segmented-control…
Browse files Browse the repository at this point in the history
… to 1.6.1
  • Loading branch information
tsapeta committed May 22, 2020
1 parent c695f89 commit d9a3253
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/bare-expo/package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/native-component-list/package.json
Expand Up @@ -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",
Expand Down
22 changes: 21 additions & 1 deletion ios/Exponent.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -10,7 +10,7 @@
#import <React/RCTComponent.h>

@interface RNCSegmentedControl : UISegmentedControl

@property (nonatomic, copy) NSMutableDictionary *attributes;
@property (nonatomic, assign) NSInteger selectedIndex;
@property (nonatomic, copy) RCTBubblingEventBlock onChange;

Expand Down
Expand Up @@ -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;
}
Expand All @@ -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) && \
Expand All @@ -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
}
Expand All @@ -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
Expand All @@ -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
}
Expand Down
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion packages/expo/bundledNativeModules.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -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==
Expand Down

0 comments on commit d9a3253

Please sign in to comment.