Skip to content

Commit 9b059b6

Browse files
ken0nekfacebook-github-bot
authored andcommitted
Remove iOS 11 availability check (#32488)
Summary: This pull request aims to remove iOS 11 availability check which is no longer needed. The minimum iOS deployment target for React Native is iOS 11 but we still have iOS 11 version check like below. ``` if (available(iOS 11.0, *)) { ``` This is a continuation pull request of #32151 ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Changed] - Remove iOS 11 availability check Pull Request resolved: #32488 Reviewed By: yungsters Differential Revision: D32006312 Pulled By: ryancat fbshipit-source-id: 0ee6579e433a15d3d220a52d2ccd6931b0513971
1 parent b25d9e4 commit 9b059b6

File tree

6 files changed

+34
-58
lines changed

6 files changed

+34
-58
lines changed

React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm

+6-15
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,12 @@ - (instancetype)init
2424
_heightConstraint = [_safeAreaContainer.heightAnchor constraintEqualToConstant:0];
2525
_heightConstraint.active = YES;
2626

27-
if (@available(iOS 11.0, *)) {
28-
[NSLayoutConstraint activateConstraints:@[
29-
[_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor],
30-
[_safeAreaContainer.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor],
31-
[_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor],
32-
[_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor]
33-
]];
34-
} else {
35-
[NSLayoutConstraint activateConstraints:@[
36-
[_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
37-
[_safeAreaContainer.topAnchor constraintEqualToAnchor:self.topAnchor],
38-
[_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
39-
[_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.trailingAnchor]
40-
]];
41-
}
27+
[NSLayoutConstraint activateConstraints:@[
28+
[_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor],
29+
[_safeAreaContainer.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor],
30+
[_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor],
31+
[_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor]
32+
]];
4233
}
4334
return self;
4435
}

React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm

+4-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key
3030
- (instancetype)initWithFrame:(CGRect)frame
3131
{
3232
if (self = [super initWithFrame:frame]) {
33-
if (@available(iOS 11.0, *)) {
34-
// We set the default behavior to "never" so that iOS
35-
// doesn't do weird things to UIScrollView insets automatically
36-
// and keeps it as an opt-in behavior.
37-
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
38-
}
33+
// We set the default behavior to "never" so that iOS
34+
// doesn't do weird things to UIScrollView insets automatically
35+
// and keeps it as an opt-in behavior.
36+
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
3937

4038
// We intentionally force `UIScrollView`s `semanticContentAttribute` to `LTR` here
4139
// because this attribute affects a position of vertical scrollbar; we don't want this

React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

+10-12
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,16 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
258258
}
259259
}
260260

261-
if (@available(iOS 11.0, *)) {
262-
if (oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) {
263-
auto const contentInsetAdjustmentBehavior = newScrollViewProps.contentInsetAdjustmentBehavior;
264-
if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Never) {
265-
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
266-
} else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Automatic) {
267-
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
268-
} else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::ScrollableAxes) {
269-
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
270-
} else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Always) {
271-
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
272-
}
261+
if (oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) {
262+
auto const contentInsetAdjustmentBehavior = newScrollViewProps.contentInsetAdjustmentBehavior;
263+
if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Never) {
264+
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
265+
} else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Automatic) {
266+
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
267+
} else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::ScrollableAxes) {
268+
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
269+
} else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Always) {
270+
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways;
273271
}
274272
}
275273

React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm

+2-5
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,10 @@ UITextContentType RCTUITextContentTypeFromString(std::string const &contentType)
210210
@"streetAddressLine2" : UITextContentTypeStreetAddressLine2,
211211
@"sublocality" : UITextContentTypeSublocality,
212212
@"telephoneNumber" : UITextContentTypeTelephoneNumber,
213+
@"username" : UITextContentTypeUsername,
214+
@"password" : UITextContentTypePassword,
213215
} mutableCopy];
214216

215-
if (@available(iOS 11.0, *)) {
216-
[mutableContentTypeMap
217-
addEntriesFromDictionary:@{@"username" : UITextContentTypeUsername, @"password" : UITextContentTypePassword}];
218-
}
219-
220217
if (@available(iOS 12.0, *)) {
221218
[mutableContentTypeMap addEntriesFromDictionary:@{
222219
@"newPassword" : UITextContentTypeNewPassword,

React/Views/ScrollView/RCTScrollView.m

+4-10
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,10 @@ - (instancetype)initWithEventDispatcher:(id<RCTEventDispatcherProtocol>)eventDis
285285
_scrollView.delegate = self;
286286
_scrollView.delaysContentTouches = NO;
287287

288-
// `contentInsetAdjustmentBehavior` is only available since iOS 11.
289288
// We set the default behavior to "never" so that iOS
290289
// doesn't do weird things to UIScrollView insets automatically
291290
// and keeps it as an opt-in behavior.
292-
if ([_scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
293-
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
294-
}
291+
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
295292

296293
_automaticallyAdjustContentInsets = YES;
297294
_contentInset = UIEdgeInsetsZero;
@@ -936,12 +933,9 @@ - (void)setAutomaticallyAdjustsScrollIndicatorInsets:(BOOL)automaticallyAdjusts
936933

937934
- (void)setContentInsetAdjustmentBehavior:(UIScrollViewContentInsetAdjustmentBehavior)behavior
938935
{
939-
// `contentInsetAdjustmentBehavior` is available since iOS 11.
940-
if ([_scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
941-
CGPoint contentOffset = _scrollView.contentOffset;
942-
_scrollView.contentInsetAdjustmentBehavior = behavior;
943-
_scrollView.contentOffset = contentOffset;
944-
}
936+
CGPoint contentOffset = _scrollView.contentOffset;
937+
_scrollView.contentInsetAdjustmentBehavior = behavior;
938+
_scrollView.contentOffset = contentOffset;
945939
}
946940

947941
- (void)sendScrollEventWithName:(NSString *)eventName

ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm

+8-10
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,14 @@
187187
facebook::react::ColorComponents RCTPlatformColorComponentsFromSemanticItems(std::vector<std::string> &semanticItems)
188188
{
189189
for (const auto &semanticCString : semanticItems) {
190-
if (@available(iOS 11.0, *)) {
191-
NSString *semanticNSString = _NSStringFromCString(semanticCString);
192-
UIColor *uiColor = [UIColor colorNamed:semanticNSString];
193-
if (uiColor != nil) {
194-
return _ColorComponentsFromUIColor(uiColor);
195-
}
196-
uiColor = _UIColorFromSemanticString(semanticNSString);
197-
if (uiColor != nil) {
198-
return _ColorComponentsFromUIColor(uiColor);
199-
}
190+
NSString *semanticNSString = _NSStringFromCString(semanticCString);
191+
UIColor *uiColor = [UIColor colorNamed:semanticNSString];
192+
if (uiColor != nil) {
193+
return _ColorComponentsFromUIColor(uiColor);
194+
}
195+
uiColor = _UIColorFromSemanticString(semanticNSString);
196+
if (uiColor != nil) {
197+
return _ColorComponentsFromUIColor(uiColor);
200198
}
201199
}
202200

0 commit comments

Comments
 (0)