From 9b059b67092f4e7d568867a2b3a51dfd7c6f1db6 Mon Sep 17 00:00:00 2001 From: Ken Tominaga Date: Wed, 3 Nov 2021 09:04:13 -0700 Subject: [PATCH] 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 https://github.com/facebook/react-native/pull/32151 ## Changelog [iOS] [Changed] - Remove iOS 11 availability check Pull Request resolved: https://github.com/facebook/react-native/pull/32488 Reviewed By: yungsters Differential Revision: D32006312 Pulled By: ryancat fbshipit-source-id: 0ee6579e433a15d3d220a52d2ccd6931b0513971 --- .../RCTInputAccessoryContentView.mm | 21 +++++------------- .../ScrollView/RCTEnhancedScrollView.mm | 10 ++++----- .../ScrollView/RCTScrollViewComponentView.mm | 22 +++++++++---------- .../TextInput/RCTTextInputUtils.mm | 7 ++---- React/Views/ScrollView/RCTScrollView.m | 14 ++++-------- .../platform/ios/RCTPlatformColorUtils.mm | 18 +++++++-------- 6 files changed, 34 insertions(+), 58 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm b/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm index 1d112b51c1c..039d033984c 100644 --- a/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm +++ b/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryContentView.mm @@ -24,21 +24,12 @@ _heightConstraint = [_safeAreaContainer.heightAnchor constraintEqualToConstant:0]; _heightConstraint.active = YES; - if (@available(iOS 11.0, *)) { - [NSLayoutConstraint activateConstraints:@[ - [_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor], - [_safeAreaContainer.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor], - [_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor], - [_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor] - ]]; - } else { - [NSLayoutConstraint activateConstraints:@[ - [_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.bottomAnchor], - [_safeAreaContainer.topAnchor constraintEqualToAnchor:self.topAnchor], - [_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.leadingAnchor], - [_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.trailingAnchor] - ]]; - } + [NSLayoutConstraint activateConstraints:@[ + [_safeAreaContainer.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor], + [_safeAreaContainer.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor], + [_safeAreaContainer.leadingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leadingAnchor], + [_safeAreaContainer.trailingAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.trailingAnchor] + ]]; } return self; } diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm index 80514c2a54f..c1b8ce67aae 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm @@ -30,12 +30,10 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - if (@available(iOS 11.0, *)) { - // We set the default behavior to "never" so that iOS - // doesn't do weird things to UIScrollView insets automatically - // and keeps it as an opt-in behavior. - self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } + // We set the default behavior to "never" so that iOS + // doesn't do weird things to UIScrollView insets automatically + // and keeps it as an opt-in behavior. + self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; // We intentionally force `UIScrollView`s `semanticContentAttribute` to `LTR` here // because this attribute affects a position of vertical scrollbar; we don't want this diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index d1d8cc3f2ae..b94553b5abc 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -258,18 +258,16 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg } } - if (@available(iOS 11.0, *)) { - if (oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) { - auto const contentInsetAdjustmentBehavior = newScrollViewProps.contentInsetAdjustmentBehavior; - if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Never) { - scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Automatic) { - scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; - } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::ScrollableAxes) { - scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; - } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Always) { - scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways; - } + if (oldScrollViewProps.contentInsetAdjustmentBehavior != newScrollViewProps.contentInsetAdjustmentBehavior) { + auto const contentInsetAdjustmentBehavior = newScrollViewProps.contentInsetAdjustmentBehavior; + if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Never) { + scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Automatic) { + scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; + } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::ScrollableAxes) { + scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic; + } else if (contentInsetAdjustmentBehavior == ContentInsetAdjustmentBehavior::Always) { + scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAlways; } } diff --git a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm index a861c36c38a..5212f8b5857 100644 --- a/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm +++ b/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputUtils.mm @@ -210,13 +210,10 @@ UITextContentType RCTUITextContentTypeFromString(std::string const &contentType) @"streetAddressLine2" : UITextContentTypeStreetAddressLine2, @"sublocality" : UITextContentTypeSublocality, @"telephoneNumber" : UITextContentTypeTelephoneNumber, + @"username" : UITextContentTypeUsername, + @"password" : UITextContentTypePassword, } mutableCopy]; - if (@available(iOS 11.0, *)) { - [mutableContentTypeMap - addEntriesFromDictionary:@{@"username" : UITextContentTypeUsername, @"password" : UITextContentTypePassword}]; - } - if (@available(iOS 12.0, *)) { [mutableContentTypeMap addEntriesFromDictionary:@{ @"newPassword" : UITextContentTypeNewPassword, diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index eb8f90e1cd9..b60f3e9d42e 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -285,13 +285,10 @@ _scrollView.delegate = self; _scrollView.delaysContentTouches = NO; - // `contentInsetAdjustmentBehavior` is only available since iOS 11. // We set the default behavior to "never" so that iOS // doesn't do weird things to UIScrollView insets automatically // and keeps it as an opt-in behavior. - if ([_scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) { - _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; - } + _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; _automaticallyAdjustContentInsets = YES; _contentInset = UIEdgeInsetsZero; @@ -936,12 +933,9 @@ RCT_SET_AND_PRESERVE_OFFSET(setScrollIndicatorInsets, scrollIndicatorInsets, UIE - (void)setContentInsetAdjustmentBehavior:(UIScrollViewContentInsetAdjustmentBehavior)behavior { - // `contentInsetAdjustmentBehavior` is available since iOS 11. - if ([_scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) { - CGPoint contentOffset = _scrollView.contentOffset; - _scrollView.contentInsetAdjustmentBehavior = behavior; - _scrollView.contentOffset = contentOffset; - } + CGPoint contentOffset = _scrollView.contentOffset; + _scrollView.contentInsetAdjustmentBehavior = behavior; + _scrollView.contentOffset = contentOffset; } - (void)sendScrollEventWithName:(NSString *)eventName diff --git a/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm b/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm index baa232423a8..6143162af52 100644 --- a/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm +++ b/ReactCommon/react/renderer/graphics/platform/ios/RCTPlatformColorUtils.mm @@ -187,16 +187,14 @@ static inline facebook::react::ColorComponents _ColorComponentsFromUIColor(UICol facebook::react::ColorComponents RCTPlatformColorComponentsFromSemanticItems(std::vector &semanticItems) { for (const auto &semanticCString : semanticItems) { - if (@available(iOS 11.0, *)) { - NSString *semanticNSString = _NSStringFromCString(semanticCString); - UIColor *uiColor = [UIColor colorNamed:semanticNSString]; - if (uiColor != nil) { - return _ColorComponentsFromUIColor(uiColor); - } - uiColor = _UIColorFromSemanticString(semanticNSString); - if (uiColor != nil) { - return _ColorComponentsFromUIColor(uiColor); - } + NSString *semanticNSString = _NSStringFromCString(semanticCString); + UIColor *uiColor = [UIColor colorNamed:semanticNSString]; + if (uiColor != nil) { + return _ColorComponentsFromUIColor(uiColor); + } + uiColor = _UIColorFromSemanticString(semanticNSString); + if (uiColor != nil) { + return _ColorComponentsFromUIColor(uiColor); } }