remove legacy os code

This commit is contained in:
Pfeil, Scott Robert 2019-10-17 10:31:34 -04:00
parent 603ecccf35
commit bb51fba0e5
14 changed files with 62 additions and 144 deletions

View File

@ -83,11 +83,9 @@
self.enabled = YES; self.enabled = YES;
// Disable SmartQuotes // Disable SmartQuotes
if (@available(iOS 11.0, *)) { self.textField.smartQuotesType = UITextSmartQuotesTypeNo;
self.textField.smartQuotesType = UITextSmartQuotesTypeNo; self.textField.smartDashesType = UITextSmartDashesTypeNo;
self.textField.smartDashesType = UITextSmartDashesTypeNo; self.textField.smartInsertDeleteType = UITextSmartInsertDeleteTypeNo;
self.textField.smartInsertDeleteType = UITextSmartInsertDeleteTypeNo;
}
} }
} }

View File

@ -173,11 +173,10 @@
view.placeHolderLabel.textColor = [UIColor mfLightGrayColor]; view.placeHolderLabel.textColor = [UIColor mfLightGrayColor];
// Disable SmartQuotes // Disable SmartQuotes
if (@available(iOS 11.0, *)) { view.textView.smartQuotesType = UITextSmartQuotesTypeNo;
view.textView.smartQuotesType = UITextSmartQuotesTypeNo; view.textView.smartDashesType = UITextSmartDashesTypeNo;
view.textView.smartDashesType = UITextSmartDashesTypeNo; view.textView.smartInsertDeleteType = UITextSmartInsertDeleteTypeNo;
view.textView.smartInsertDeleteType = UITextSmartInsertDeleteTypeNo;
}
[view didSetFont:view.textView.font]; [view didSetFont:view.textView.font];
view.hideBorder = YES; view.hideBorder = YES;
return view; return view;

View File

@ -48,9 +48,7 @@
- (void)setAsMolecule { - (void)setAsMolecule {
self.translatesAutoresizingMaskIntoConstraints = NO; self.translatesAutoresizingMaskIntoConstraints = NO;
if (@available(iOS 11.0, *)) { self.insetsLayoutMarginsFromSafeArea = NO;
self.insetsLayoutMarginsFromSafeArea = NO;
}
} }
- (void)reset { - (void)reset {

View File

@ -61,12 +61,8 @@
tableView.separatorStyle = UITableViewCellSeparatorStyleNone; tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.delegate = self; tableView.delegate = self;
tableView.dataSource = self; tableView.dataSource = self;
if (@available(iOS 11.0, *)) { tableView.insetsContentViewsToSafeArea = NO;
tableView.insetsContentViewsToSafeArea = NO; tableView.cellLayoutMarginsFollowReadableWidth = NO;
}
if ([tableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) {
tableView.cellLayoutMarginsFollowReadableWidth = NO;
}
return tableView; return tableView;
} }

View File

@ -91,10 +91,7 @@ static NSTimeInterval const HandScrollAnimationTiming = 7.f;
- (void)viewDidLayoutSubviews { - (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews]; [super viewDidLayoutSubviews];
BOOL automaticInset = NO; BOOL automaticInset = self.navigationController && self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic;
if (@available(iOS 11.0, *)) {
automaticInset = self.navigationController && self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic;
}
// Takes into account the navigation bar. // Takes into account the navigation bar.
if (!automaticInset && (self.edgesForExtendedLayout & UIRectEdgeTop)) { if (!automaticInset && (self.edgesForExtendedLayout & UIRectEdgeTop)) {

View File

@ -190,13 +190,9 @@ open class ThreeLayerTableViewController: MFProgrammaticTableViewController {
footerView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true footerView.topAnchor.constraint(equalTo: tableView.bottomAnchor).isActive = true
footerView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true footerView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
view.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true view.rightAnchor.constraint(equalTo: footerView.rightAnchor).isActive = true
if #available(iOS 11.0, *) { view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true
view.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: view)
safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: view) safeAreaView?.backgroundColor = bottomView?.backgroundColor
safeAreaView?.backgroundColor = bottomView?.backgroundColor
} else {
view.bottomAnchor.constraint(equalTo: footerView.bottomAnchor).isActive = true
}
} else { } else {
bottomConstraint?.isActive = true bottomConstraint?.isActive = true
var y: CGFloat? var y: CGFloat?

View File

@ -45,7 +45,7 @@ open class ThreeLayerViewController: ProgrammaticScrollViewController {
return return
} }
if #available(iOS 11.0, *), scrollView.contentInsetAdjustmentBehavior == UIScrollView.ContentInsetAdjustmentBehavior.automatic { if scrollView.contentInsetAdjustmentBehavior == UIScrollView.ContentInsetAdjustmentBehavior.automatic {
heightConstraint?.constant = -scrollView.adjustedContentInset.top - scrollView.adjustedContentInset.bottom heightConstraint?.constant = -scrollView.adjustedContentInset.top - scrollView.adjustedContentInset.bottom
} else { } else {
heightConstraint?.constant = -scrollView.contentInset.top - scrollView.contentInset.bottom heightConstraint?.constant = -scrollView.contentInset.top - scrollView.contentInset.bottom
@ -233,14 +233,10 @@ extension ThreeLayerViewController {
view.topAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true view.topAnchor.constraint(equalTo: scrollView.bottomAnchor).isActive = true
NSLayoutConstraint.pinViewLeft(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true NSLayoutConstraint.pinViewLeft(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true
NSLayoutConstraint.pinViewRight(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true NSLayoutConstraint.pinViewRight(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true
if #available(iOS 11.0, *) { parentView.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
parentView.safeAreaLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true if let safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: parentView) {
if let safeAreaView = MVMCoreUICommonViewsUtility.getAndSetupSafeAreaView(on: parentView) { safeAreaView.backgroundColor = bottomView?.backgroundColor
safeAreaView.backgroundColor = bottomView?.backgroundColor self.safeAreaView = safeAreaView
self.safeAreaView = safeAreaView
}
} else {
NSLayoutConstraint.pinViewBottom(toSuperview: view, useMargins: useMargins, constant: 0).isActive = true
} }
} }
} }

View File

@ -283,16 +283,6 @@
// So we will update titles. // So we will update titles.
[self newDataBuildScreen]; [self newDataBuildScreen];
// Fix for right bar button item with custom view which disappears when user navigates to top tabbar page controller
if (@available(iOS 11.0, *)) {
} else {
NSMutableArray *buttonItems = [[NSMutableArray alloc] init];
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:self action:nil];
[buttonItems addObject:space];
[buttonItems addObjectsFromArray:self.navigationItem.rightBarButtonItems];
self.navigationItem.rightBarButtonItems = buttonItems;
}
} }
- (void)viewWillDisappear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated {

View File

@ -325,19 +325,13 @@
NSLayoutConstraint *bottomViewTop = [NSLayoutConstraint constraintWithItem:footerView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:tableView attribute:NSLayoutAttributeBottom multiplier:1 constant:0]; NSLayoutConstraint *bottomViewTop = [NSLayoutConstraint constraintWithItem:footerView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:tableView attribute:NSLayoutAttributeBottom multiplier:1 constant:0];
bottomViewTop.active = YES; bottomViewTop.active = YES;
NSLayoutConstraint *bottomViewBot = nil; NSLayoutConstraint *bottomViewBot = [self.view.safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:footerView.bottomAnchor];
if (@available(iOS 11.0, *)) { bottomViewBot.priority = 900;
bottomViewBot = [self.view.safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:footerView.bottomAnchor]; bottomViewBot.active = YES;
UIView *safeAreaView = [MVMCoreUICommonViewsUtility getAndSetupSafeAreaViewOnView:self.view]; UIView *safeAreaView = [MVMCoreUICommonViewsUtility getAndSetupSafeAreaViewOnView:self.view];
safeAreaView.backgroundColor = footerView.backgroundColor; safeAreaView.backgroundColor = footerView.backgroundColor;
self.safeAreaView = safeAreaView; self.safeAreaView = safeAreaView;
} else {
// Fallback on earlier versions
bottomViewBot = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:footerView attribute:NSLayoutAttributeBottom multiplier:1 constant:0];
}
bottomViewBot.priority = 900;
bottomViewBot.active = YES;
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[footerView]-0@900-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(footerView)]]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[footerView]-0@900-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(footerView)]];
} else { } else {

View File

@ -272,13 +272,8 @@
- (void)updateViewConstraints { - (void)updateViewConstraints {
[super updateViewConstraints]; [super updateViewConstraints];
// Updates for ios 11 if (self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic) {
if (@available(iOS 11.0, *)) { self.heightConstraint.constant = -self.scrollView.adjustedContentInset.top - self.scrollView.adjustedContentInset.bottom;
if (self.scrollView.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic) {
self.heightConstraint.constant = -self.scrollView.adjustedContentInset.top - self.scrollView.adjustedContentInset.bottom;
} else {
self.heightConstraint.constant = -self.scrollView.contentInset.top - self.scrollView.contentInset.bottom;
}
} else { } else {
self.heightConstraint.constant = -self.scrollView.contentInset.top - self.scrollView.contentInset.bottom; self.heightConstraint.constant = -self.scrollView.contentInset.top - self.scrollView.contentInset.bottom;
} }
@ -322,17 +317,13 @@
[self.view addSubview:bottomView]; [self.view addSubview:bottomView];
UIScrollView *scrollview = self.scrollView; UIScrollView *scrollview = self.scrollView;
if (@available(iOS 11.0, *)) { [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[scrollview]-0-[bottomView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(scrollview,bottomView)]];
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[scrollview]-0-[bottomView]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(scrollview,bottomView)]]; [self.view.safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:bottomView.bottomAnchor].active = YES;
[self.view.safeAreaLayoutGuide.bottomAnchor constraintEqualToAnchor:bottomView.bottomAnchor].active = YES;
UIView *safeAreaView = [MVMCoreUICommonViewsUtility getAndSetupSafeAreaViewOnView:self.view];
UIView *safeAreaView = [MVMCoreUICommonViewsUtility getAndSetupSafeAreaViewOnView:self.view]; safeAreaView.backgroundColor = bottomView.backgroundColor;
safeAreaView.backgroundColor = bottomView.backgroundColor; self.safeAreaView = safeAreaView;
self.safeAreaView = safeAreaView;
} else {
// Fallback on earlier versions
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[scrollview]-0-[bottomView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(scrollview,bottomView)]];
}
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[bottomView]-0@900-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(bottomView)]]; [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[bottomView]-0@900-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(bottomView)]];
} }

View File

@ -37,11 +37,9 @@ open class MoleculeCollectionViewCell: UICollectionViewCell, MVMCoreUIMoleculeVi
} }
isAccessibilityElement = false isAccessibilityElement = false
contentView.isAccessibilityElement = false contentView.isAccessibilityElement = false
if #available(iOS 11.0, *) { insetsLayoutMarginsFromSafeArea = false
insetsLayoutMarginsFromSafeArea = false contentView.insetsLayoutMarginsFromSafeArea = false
contentView.insetsLayoutMarginsFromSafeArea = false contentView.preservesSuperviewLayoutMargins = false
contentView.preservesSuperviewLayoutMargins = false
}
// Covers the card when peaking. // Covers the card when peaking.
peakingCover.backgroundColor = .white peakingCover.backgroundColor = .white

View File

@ -87,29 +87,16 @@ import UIKit
// MARK: - MFViewProtocol // MARK: - MFViewProtocol
public func updateView(_ size: CGFloat) { public func updateView(_ size: CGFloat) {
MFStyler.setMarginsFor(self, size: size, defaultHorizontal: updateViewHorizontalDefaults, top: topMarginPadding, bottom: bottomMarginPadding) MFStyler.setMarginsFor(self, size: size, defaultHorizontal: updateViewHorizontalDefaults, top: topMarginPadding, bottom: bottomMarginPadding)
if #available(iOS 11.0, *) { if accessoryView != nil {
if accessoryView != nil { // Smaller left margin if accessory view.
// Smaller left margin if accessory view. var margin = directionalLayoutMargins
var margin = directionalLayoutMargins margin.trailing = 16
margin.trailing = 16 contentView.directionalLayoutMargins = margin
contentView.directionalLayoutMargins = margin
} else {
contentView.directionalLayoutMargins = directionalLayoutMargins
}
topSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
bottomSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
} else { } else {
if accessoryView != nil { contentView.directionalLayoutMargins = directionalLayoutMargins
// Smaller left margin if accessory view.
var margin = layoutMargins
margin.right = 16
contentView.layoutMargins = margin
} else {
contentView.layoutMargins = layoutMargins
}
topSeparatorView?.setLeftAndRightPinConstant(layoutMargins.left)
bottomSeparatorView?.setLeftAndRightPinConstant(layoutMargins.left)
} }
topSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
bottomSeparatorView?.setLeftAndRightPinConstant(directionalLayoutMargins.leading)
molecule?.updateView(size) molecule?.updateView(size)
if let _ = accessoryView, let caretView = caretView, let widthObject = caretViewWidthSizeObject, let heightObject = caretViewHeightSizeObject { if let _ = accessoryView, let caretView = caretView, let widthObject = caretViewWidthSizeObject, let heightObject = caretViewHeightSizeObject {
@ -121,11 +108,9 @@ import UIKit
public func setupView() { public func setupView() {
selectionStyle = .none selectionStyle = .none
if #available(iOS 11.0, *) { insetsLayoutMarginsFromSafeArea = false
insetsLayoutMarginsFromSafeArea = false contentView.insetsLayoutMarginsFromSafeArea = false
contentView.insetsLayoutMarginsFromSafeArea = false contentView.preservesSuperviewLayoutMargins = false
contentView.preservesSuperviewLayoutMargins = false
}
} }
// MARK: - MVMCoreUIMoleculeViewProtocol // MARK: - MVMCoreUIMoleculeViewProtocol

View File

@ -198,13 +198,8 @@ static const CGFloat VertialShadowOffset = 6;
[view.rightAnchor constraintEqualToAnchor:button.rightAnchor constant:PaddingTwo].active = YES; [view.rightAnchor constraintEqualToAnchor:button.rightAnchor constant:PaddingTwo].active = YES;
[view.centerYAnchor constraintEqualToAnchor:button.centerYAnchor].active = YES; [view.centerYAnchor constraintEqualToAnchor:button.centerYAnchor].active = YES;
} else { } else {
if (@available(iOS 11.0, *)) { [button.topAnchor constraintEqualToAnchor:view.safeAreaLayoutGuide.topAnchor constant:PaddingOne].active = YES;
[button.topAnchor constraintEqualToAnchor:view.safeAreaLayoutGuide.topAnchor constant:PaddingOne].active = YES; [view.safeAreaLayoutGuide.trailingAnchor constraintEqualToAnchor:button.trailingAnchor constant:PaddingTwo].active = YES;
[view.safeAreaLayoutGuide.trailingAnchor constraintEqualToAnchor:button.trailingAnchor constant:PaddingTwo].active = YES;
} else {
[NSLayoutConstraint constraintPinSubview:button pinTop:YES topConstant:PaddingOne pinBottom:NO bottomConstant:0 pinLeft:NO leftConstant:0 pinRight:YES rightConstant:PaddingTwo];
}
} }
} }
return button; return button;
@ -249,16 +244,12 @@ static const CGFloat VertialShadowOffset = 6;
} }
+ (nullable UIView *)getAndSetupSafeAreaViewOnView:(nonnull UIView *)view { + (nullable UIView *)getAndSetupSafeAreaViewOnView:(nonnull UIView *)view {
if (@available(iOS 11.0, *)) { UIView *safeAreaView = [MVMCoreUICommonViewsUtility commonView];
UIView *safeAreaView = [MVMCoreUICommonViewsUtility commonView]; [view addSubview:safeAreaView];
[view addSubview:safeAreaView]; [safeAreaView.topAnchor constraintEqualToAnchor:view.safeAreaLayoutGuide.bottomAnchor].active = YES;
[safeAreaView.topAnchor constraintEqualToAnchor:view.safeAreaLayoutGuide.bottomAnchor].active = YES; [view.bottomAnchor constraintEqualToAnchor:safeAreaView.bottomAnchor].active = YES;
[view.bottomAnchor constraintEqualToAnchor:safeAreaView.bottomAnchor].active = YES; [NSLayoutConstraint constraintPinSubview:safeAreaView pinTop:NO topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0];
[NSLayoutConstraint constraintPinSubview:safeAreaView pinTop:NO topConstant:0 pinBottom:NO bottomConstant:0 pinLeft:YES leftConstant:0 pinRight:YES rightConstant:0]; return safeAreaView;
return safeAreaView;
} else {
return nil;
}
} }
#pragma mark - shadows #pragma mark - shadows

View File

@ -58,21 +58,13 @@
} }
+ (UIEdgeInsets)getMarginsForView:(nullable UIView *)view { + (UIEdgeInsets)getMarginsForView:(nullable UIView *)view {
if (@available(iOS 11.0, *)) { return UIEdgeInsetsMake(view.directionalLayoutMargins.top, view.directionalLayoutMargins.leading, view.directionalLayoutMargins.bottom, view.directionalLayoutMargins.trailing)
return UIEdgeInsetsMake(view.directionalLayoutMargins.top, view.directionalLayoutMargins.leading, view.directionalLayoutMargins.bottom, view.directionalLayoutMargins.trailing);
} else {
return view.layoutMargins;
}
} }
#pragma mark - Setters #pragma mark - Setters
+ (void)setMarginsForView:(nullable UIView *)view leading:(CGFloat)leading top:(CGFloat)top trailing:(CGFloat)trailing bottom:(CGFloat)bottom { + (void)setMarginsForView:(nullable UIView *)view leading:(CGFloat)leading top:(CGFloat)top trailing:(CGFloat)trailing bottom:(CGFloat)bottom {
if (@available(iOS 11.0, *)) { view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(top, leading, bottom, trailing);
view.directionalLayoutMargins = NSDirectionalEdgeInsetsMake(top, leading, bottom, trailing);
} else {
view.layoutMargins = UIEdgeInsetsMake(top, leading, bottom, trailing);
}
} }
#pragma mark - Formatting #pragma mark - Formatting
@ -152,12 +144,9 @@
CGFloat topInset = scrollview.contentInset.top; CGFloat topInset = scrollview.contentInset.top;
CGFloat bottomInset = scrollview.contentInset.bottom; CGFloat bottomInset = scrollview.contentInset.bottom;
// Updates for ios 11 if (scrollview.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic) {
if (@available(iOS 11.0, *)) { topInset = scrollview.adjustedContentInset.top;
if (scrollview.contentInsetAdjustmentBehavior == UIScrollViewContentInsetAdjustmentAutomatic) { bottomInset = scrollview.adjustedContentInset.bottom;
topInset = scrollview.adjustedContentInset.top;
bottomInset = scrollview.adjustedContentInset.bottom;
}
} }
CGFloat remainingSpace = frameHeight - contentSizeHeight - topInset - bottomInset; CGFloat remainingSpace = frameHeight - contentSizeHeight - topInset - bottomInset;