Skip to content

Commit

Permalink
Merge pull request auth0#61 from auth0/bugfix-social-only-layout
Browse files Browse the repository at this point in the history
Social only layout height is zero
  • Loading branch information
hzalaz committed Dec 16, 2014
2 parents 68b4db4 + 77d9c46 commit f8f0bed
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Pod/Assets/A0ChangePasswordViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="A0ChangePasswordViewController">
Expand Down
4 changes: 2 additions & 2 deletions Pod/Assets/A0DatabaseLoginViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="A0DatabaseLoginViewController">
Expand Down
8 changes: 5 additions & 3 deletions Pod/Assets/A0ServiceTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -19,18 +19,20 @@
<constraint firstAttribute="height" constant="46" id="bWD-ZY-kZ2"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<inset key="titleEdgeInsets" minX="55" minY="0.0" maxX="0.0" maxY="0.0"/>
<inset key="titleEdgeInsets" minX="65" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="GgJ-cH-XPz" secondAttribute="trailing" id="YLp-RR-aak"/>
<constraint firstAttribute="centerY" secondItem="GgJ-cH-XPz" secondAttribute="centerY" id="ajy-C9-DVI"/>
<constraint firstItem="GgJ-cH-XPz" firstAttribute="leading" secondItem="Yyl-ni-OY9" secondAttribute="leading" id="byd-Qu-jw5"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<outlet property="button" destination="GgJ-cH-XPz" id="1t5-wn-6zM"/>
</connections>
Expand Down
8 changes: 4 additions & 4 deletions Pod/Assets/A0SocialLoginViewController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="A0SocialLoginViewController">
Expand All @@ -17,14 +17,14 @@
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" style="plain" separatorStyle="none" rowHeight="55" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="HI8-Yt-8Ez">
<rect key="frame" x="20" y="0.0" width="280" height="350"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="-1" id="ezC-zN-ZRy"/>
<outlet property="delegate" destination="-1" id="7x0-ed-Xf1"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="HI8-Yt-8Ez" firstAttribute="top" secondItem="C9R-dC-ggy" secondAttribute="top" id="1OI-tv-mOE"/>
<constraint firstItem="HI8-Yt-8Ez" firstAttribute="leading" secondItem="C9R-dC-ggy" secondAttribute="leading" constant="20" id="5J6-ms-1wu"/>
Expand Down
6 changes: 6 additions & 0 deletions Pod/Classes/UI/A0ContainerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@

@class A0NavigationView;

typedef NS_ENUM(NSInteger, A0ContainerLayoutVertical) {
A0ContainerLayoutVerticalCenter = 0,
A0ContainerLayoutVerticalFill
};

@interface A0ContainerViewController : UIViewController

- (A0NavigationView *)navigationView;

- (void)displayController:(UIViewController<A0KeyboardEnabledView> *)controller;
- (void)displayController:(UIViewController<A0KeyboardEnabledView> *)controller layout:(A0ContainerLayoutVertical)layout;

@end
24 changes: 20 additions & 4 deletions Pod/Classes/UI/A0ContainerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,39 @@ - (void)viewDidDisappear:(BOOL)animated {
[self.keyboardHandler stop];
}

- (void)displayController:(UIViewController<A0KeyboardEnabledView> *)controller {
[self layoutController:controller inContainer:self.containerView];
- (void)displayController:(UIViewController<A0KeyboardEnabledView> *)controller layout:(A0ContainerLayoutVertical)layout {
[self layoutController:controller inContainer:self.containerView layout:layout];
}

#pragma mark - Container methods

- (UIViewController<A0KeyboardEnabledView> *)layoutController:(UIViewController<A0KeyboardEnabledView> *)controller inContainer:(UIView *)containerView {
- (void)displayController:(UIViewController<A0KeyboardEnabledView> *)controller {
[self displayController:controller layout:A0ContainerLayoutVerticalCenter];
}

- (UIViewController<A0KeyboardEnabledView> *)layoutController:(UIViewController<A0KeyboardEnabledView> *)controller inContainer:(UIView *)containerView layout:(A0ContainerLayoutVertical)layout {
UIViewController *from = self.childViewControllers.firstObject;
controller.view.translatesAutoresizingMaskIntoConstraints = NO;
[self.keyboardHandler handleForView:controller inView:self.view];
[from willMoveToParentViewController:nil];
[self addChildViewController:controller];
[self layoutAuthView:controller.view centeredInContainerView:containerView];
if (layout == A0ContainerLayoutVerticalFill) {
[self layoutAuthView:controller.view toFillInContainerView:containerView];
} else {
[self layoutAuthView:controller.view centeredInContainerView:containerView];
}
[self animateFromViewController:from toViewController:controller];
return controller;
}

- (void)layoutAuthView:(UIView *)authView toFillInContainerView:(UIView *)containerView {
containerView.translatesAutoresizingMaskIntoConstraints = NO;
[containerView addSubview:authView];
NSDictionary *views = NSDictionaryOfVariableBindings(authView);
[containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[authView]|" options:0 metrics:nil views:views]];
[containerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[authView]|" options:0 metrics:nil views:views]];
}

- (void)layoutAuthView:(UIView *)authView centeredInContainerView:(UIView *)containerView {
containerView.translatesAutoresizingMaskIntoConstraints = NO;
[containerView addSubview:authView];
Expand Down
4 changes: 3 additions & 1 deletion Pod/Classes/UI/A0LockViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ - (void)layoutRootControllerForApplication:(A0Application *)application {
A0Strategy *ad = application.activeDirectoryStrategy;
A0Connection *connection = database.connections.firstObject;
[self.navigationView removeAll];
A0ContainerLayoutVertical layout = A0ContainerLayoutVerticalCenter;
if ((hasDB && hasSocial) || (hasSocial && hasEnterprise && !hasAD)) {
A0FullLoginViewController *controller = [self newFullLoginViewController:onAuthSuccessBlock];
controller.application = application;
Expand All @@ -190,6 +191,7 @@ - (void)layoutRootControllerForApplication:(A0Application *)application {
A0SocialLoginViewController *controller = [self newSocialLoginViewController:onAuthSuccessBlock];
controller.application = application;
rootController = controller;
layout = A0ContainerLayoutVerticalFill;
}
if (hasSocial && hasAD && !hasDB) {
A0FullActiveDirectoryViewController *controller = [self newFullADLoginViewController:onAuthSuccessBlock];
Expand All @@ -207,7 +209,7 @@ - (void)layoutRootControllerForApplication:(A0Application *)application {
rootController = controller;
}
rootController.parameters = [self copyAuthenticationParameters];
[self displayController:rootController];
[self displayController:rootController layout:layout];
}

- (A0SocialLoginViewController *)newSocialLoginViewController:(void(^)(A0UserProfile *, A0Token *))success {
Expand Down
8 changes: 4 additions & 4 deletions Pod/Classes/UI/Private/A0ServiceTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ - (void)awakeFromNib {
[self.button addSubview:label];
label.translatesAutoresizingMaskIntoConstraints = NO;
NSDictionary *views = NSDictionaryOfVariableBindings(label);
[self.button addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(0)-[label]-(0)-|"
options:0
metrics:nil
views:views]];
[self.button addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(0)-[label(width)]"
options:0
metrics:@{ @"width": @(self.bounds.size.height) }
views:views]];
[self.button addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(0)-[label]-(0)-|"
options:0
metrics:nil
Expand Down
12 changes: 12 additions & 0 deletions Pod/Classes/UI/Private/A0SocialLoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ - (CGRect)rectToKeepVisibleInView:(UIView *)view {

- (void)hideKeyboard {}

#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return (tableView.bounds.size.height - tableView.rowHeight * self.activeServices.count) / 2;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *headerView = [[UIView alloc] init];
headerView.backgroundColor = [UIColor clearColor];
return headerView;
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
Expand Down

0 comments on commit f8f0bed

Please sign in to comment.