Skip to content

Commit

Permalink
Merge pull request #577 from Simperium/develop
Browse files Browse the repository at this point in the history
Simperium Mar 0.8.22
  • Loading branch information
jleandroperez authored Jun 18, 2019
2 parents 69435da + ed11d37 commit 3dcbe1a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode7.3
osx_image: xcode10.2
language: objective-c
xcode_project: Simperium.xcodeproj
xcode_scheme: Simperium iOS
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
simperium-ios
=============
[![Build Status](http://img.shields.io/travis/Simperium/simperium-ios.svg?branch=develop&style=flat)](https://travis-ci.org/Simperium/simperium-ios)
[![Pod Version](http://img.shields.io/cocoapods/v/Simperium.svg?style=flat)](http://www.github.com/Simperium/simperium-ios)
[![Pod Platform](http://img.shields.io/cocoapods/p/Simperium.svg?style=flat)](http://www.simperium.com)
[![Pod Platform](http://img.shields.io/cocoapods/p/Simperium-OSX.svg?style=flat)](http://www.simperium.com)
Expand Down
110 changes: 65 additions & 45 deletions Simperium-iOS/SPAuthenticationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ @interface SPAuthenticationViewController() <UITableViewDelegate, UITableViewDat

@property (nonatomic, assign) BOOL editing;

#pragma mark - Layout Constraints
@property (nonatomic, strong) NSLayoutConstraint *logoTopConstraint;
@property (nonatomic, strong) NSLayoutConstraint *tableLeadingConstraint;
@property (nonatomic, strong) NSLayoutConstraint *tableTrailingConstraint;
@property (nonatomic, strong) NSLayoutConstraint *tableCenterConstraint;
@property (nonatomic, strong) NSLayoutConstraint *tableWidthConstraint;

- (void)earthquake:(UIView*)itemView;
- (void)changeAction:(id)sender;

Expand Down Expand Up @@ -160,6 +167,7 @@ - (void)viewDidLoad {
_tableView.separatorColor = lightGreyColor;
_tableView.clipsToBounds = NO;
_tableView.scrollEnabled = NO;
_tableView.translatesAutoresizingMaskIntoConstraints = false;
[self.view addSubview:_tableView];

if (self.view.bounds.size.height <= 480.0) {
Expand Down Expand Up @@ -265,6 +273,7 @@ - (void)viewDidLoad {
self.logoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, logo.size.width, logo.size.height)];
_logoView.image = logo;
_logoView.contentMode = UIViewContentModeCenter;
_logoView.translatesAutoresizingMaskIntoConstraints = false;
[self.view addSubview:_logoView];

// Setup TableView's Footer
Expand All @@ -288,27 +297,66 @@ - (void)viewDidLoad {

// Refresh Buttons
[self refreshButtons];

[self configureViewConstraints];
}

- (void)configureViewConstraints {
NSLayoutAnchor *topAnchor = self.view.topAnchor;
if (@available(iOS 11, *)) {
topAnchor = self.view.safeAreaLayoutGuide.topAnchor;
}

NSLayoutConstraint *logoTopConstraint = [_logoView.topAnchor constraintEqualToAnchor:topAnchor];
NSLayoutConstraint *tableWidthConstraint = [_tableView.widthAnchor constraintEqualToConstant:SPAuthenticationTableWidthMax];
NSLayoutConstraint *tableLeadingConstraint = [_tableView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor];
NSLayoutConstraint *tableCenterConstraint = [_tableView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor];
NSLayoutConstraint *tableTrailingConstraint = [_tableView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor];

tableWidthConstraint.priority = UILayoutPriorityDefaultHigh;

[NSLayoutConstraint activateConstraints:@[
logoTopConstraint,
[_logoView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
[_tableView.topAnchor constraintEqualToAnchor:_logoView.bottomAnchor],
[_tableView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
tableLeadingConstraint,
tableCenterConstraint,
tableTrailingConstraint,
]];

self.logoTopConstraint = logoTopConstraint;
self.tableLeadingConstraint = tableLeadingConstraint;
self.tableCenterConstraint = tableCenterConstraint;
self.tableTrailingConstraint = tableTrailingConstraint;
self.tableWidthConstraint = tableWidthConstraint;
}

- (void)updateViewConstraints {
BOOL isRegulardByRegular = [self isRegulardByRegularSizeClass];

self.logoTopConstraint.constant = [self logoPaddingTop];
self.tableLeadingConstraint.active = !isRegulardByRegular;
self.tableTrailingConstraint.active = !isRegulardByRegular;
self.tableCenterConstraint.active = isRegulardByRegular;
self.tableWidthConstraint.active = isRegulardByRegular;

[super updateViewConstraints];
}

- (CGFloat)topInset {
CGFloat navigationBarHeight = self.navigationController.navigationBar.frame.size.height + self.navigationController.navigationBar.frame.origin.y;
return navigationBarHeight > 0 ? navigationBarHeight : 20.0; // 20.0 refers to the status bar height
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

CGSize toSize = self.view.bounds.size;
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
toSize = CGSizeMake(MAX(toSize.width, toSize.height), MIN(toSize.width, toSize.height));
}

[self layoutViewsForTargetSize:toSize];
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[self layoutViewsForTargetSize:size];
[self.view setNeedsUpdateConstraints];
}

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
[self.view setNeedsUpdateConstraints];
}

- (BOOL)shouldAutorotate {
Expand All @@ -326,9 +374,6 @@ - (void)viewWillAppear:(BOOL)animated {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];

// Layout please!
[self layoutViewsForTargetSize:self.viewSizeForCurrentOrientation];
}

- (void)viewWillDisappear:(BOOL)animated {
Expand All @@ -343,37 +388,13 @@ - (void)viewWillDisappear:(BOOL)animated {

#pragma mark - Layout Helpers

- (void)layoutViewsForTargetSize:(CGSize)targetSize {
BOOL isPad = [UIDevice sp_isPad];

// Logo
CGSize logoSize = _logoView.frame.size;
CGFloat topPadding = isPad ? SPAuthenticationRegularPaddingY : SPAuthenticationCompactPaddingY;

_logoView.frame = CGRectIntegral(CGRectMake((targetSize.width - logoSize.width) * 0.5,
topPadding + self.topInset,
logoSize.width,
logoSize.height));

// Table
CGFloat tableViewOriginY = CGRectGetMaxY(_logoView.frame);
CGFloat tableViewWidth = isPad ? MIN(SPAuthenticationTableWidthMax, targetSize.width) : targetSize.width;

_tableView.frame = CGRectIntegral(CGRectMake((targetSize.width - tableViewWidth) * 0.5,
tableViewOriginY,
tableViewWidth,
self.view.frame.size.height - tableViewOriginY));

[self.view sendSubviewToBack:_logoView];
- (CGFloat)logoPaddingTop {
return [self isRegulardByRegularSizeClass] ? SPAuthenticationRegularPaddingY : SPAuthenticationCompactPaddingY;
}

- (CGSize)viewSizeForCurrentOrientation {
CGSize size = self.view.bounds.size;
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
return CGSizeMake(MAX(size.width, size.height), MIN(size.width, size.height));
}

return CGSizeMake(MIN(size.width, size.height), MAX(size.width, size.height));
- (BOOL)isRegulardByRegularSizeClass {
return self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular &&
self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassRegular;
}


Expand Down Expand Up @@ -680,7 +701,6 @@ - (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
return YES;
}


- (UITextField *)textFieldWithPlaceholder:(NSString *)placeholder secure:(BOOL)secure {
CGRect textFieldFrame = CGRectMake(0.0f, 0.0f, SPAuthenticationFieldWidth, SPAuthenticationFieldHeight);
UITextField *newTextField = [[UITextField alloc] initWithFrame:textFieldFrame];
Expand Down
2 changes: 1 addition & 1 deletion Simperium/SPEnvironment.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#endif

// TODO: Update this automatically via a script that looks at current git tag
NSString* const SPLibraryVersion = @"0.8.21";
NSString* const SPLibraryVersion = @"0.8.22";

/// SSL Pinning
///
Expand Down

0 comments on commit 3dcbe1a

Please sign in to comment.