Skip to content

Commit

Permalink
Merge pull request #24 from firebase/mm-0.3.1
Browse files Browse the repository at this point in the history
Support for captive login portal, subspecs, and enums
  • Loading branch information
asciimike committed Dec 1, 2015
2 parents 5e00751 + d22dbb3 commit a45202b
Show file tree
Hide file tree
Showing 25 changed files with 837 additions and 281 deletions.
28 changes: 18 additions & 10 deletions FirebaseUI.podspec
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
Pod::Spec.new do |s|
s.name = "FirebaseUI"
s.version = "0.3.0"
s.version = "0.3.1"
s.summary = "UI binding libraries for Firebase."
s.homepage = "https://github.com/firebase/FirebaseUI-iOS"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Firebase" => "[email protected]" }
s.social_media_url = "https://twitter.com/firebase"
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.0' }
s.source_files = "FirebaseUI/**/*.{h,m}"
s.resources = "FirebaseUI/**/Resources/*"
s.dependency "Firebase", "~>2.2"
s.dependency "FBSDKCoreKit"
s.dependency "FBSDKLoginKit"
s.dependency "Google/SignIn"
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.1' }
s.platform = :ios
s.ios.deployment_target = "8.0"
s.ios.framework = "UIKit", "Accounts"
s.dependency "Firebase", "~>2.2"
s.ios.framework = "UIKit"
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Firebase"' }
s.requires_arc = true
end

s.subspec 'Core' do |core|
core.source_files = "FirebaseUI/{Core,Util}/**/*.{h,m}"
end

s.subspec 'Auth' do |auth|
auth.source_files = "FirebaseUI/Auth/**/*.{h,m}"
auth.resources = "FirebaseUI/Auth/Resources/*"
auth.dependency "FBSDKCoreKit"
auth.dependency "FBSDKLoginKit"
auth.dependency "Google/SignIn"
auth.ios.framework = "Accounts"
end
end
36 changes: 14 additions & 22 deletions FirebaseUI.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions FirebaseUI/Auth/API/FirebaseAuthConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,12 @@
#ifndef FirebaseAuthConstants_h
#define FirebaseAuthConstants_h

FOUNDATION_EXPORT NSString *const kFWPRequestType;

FOUNDATION_EXPORT NSString *const kTwitterAuthProvider;
FOUNDATION_EXPORT NSString *const kTwitterApiKey;

FOUNDATION_EXPORT NSString *const kFacebookAuthProvider;
FOUNDATION_EXPORT NSString *const kFacebookAppId;
FOUNDATION_EXPORT NSString *const kFacebookDisplayName;
FOUNDATION_EXPORT NSString *const kFacebookEmailScope;

FOUNDATION_EXPORT NSString *const kGoogleAuthProvider;

FOUNDATION_EXPORT NSString *const kPasswordAuthProvider;

FOUNDATION_EXPORT CGFloat const kHeaderWidth;
FOUNDATION_EXPORT CGFloat const kHeaderHeight;
FOUNDATION_EXPORT CGFloat const kHeaderSpace;
Expand All @@ -66,4 +58,11 @@ FOUNDATION_EXPORT CGFloat const kSeparatorWidth;
FOUNDATION_EXPORT CGFloat const kSeparatorHeight;
FOUNDATION_EXPORT CGFloat const kSeparatorSpace;

typedef NS_ENUM(NSInteger, FAuthProvider) {
FAuthProviderFacebook,
FAuthProviderGoogle,
FAuthProviderTwitter,
FAuthProviderPassword
};

#endif /* FirebaseAuthConstants_h */
File renamed without changes.
4 changes: 2 additions & 2 deletions FirebaseUI/Auth/API/FirebaseAuthProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
@property(strong, nonatomic) FAuthData *authData;

/**
* A string which represents the chosen authentication provider.
* An enum which represents the chosen authentication provider.
* See FAuthenticationConstants.h for a full list.
*/
@property(strong, nonatomic) NSString *provider;
@property(nonatomic) FAuthProvider provider;

/**
* FirebaseAuthDelegate delegate to handle all login, logout, and error events
Expand Down
8 changes: 4 additions & 4 deletions FirebaseUI/Auth/API/FirebaseLoginButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
@interface FirebaseLoginButton : UIButton

/**
* A string representing a valid identity provider (see FirebaseAuthConstants.h for a full list).
* An enum representing a valid identity provider (see FirebaseAuthConstants.h for a full list).
*/
@property(strong, nonatomic) NSString *provider;
@property(nonatomic) FAuthProvider provider;

/**
* Creates a button styled for the appropriate provider.
* @param provider A string representing the desired identity provider to log in with
* @param provider An enum representing the desired identity provider to log in with
* @return FirebaseLoginButton
*/
- (instancetype)initWithProvider:(NSString *)provider;
- (instancetype)initWithProvider:(FAuthProvider)provider;

@end
17 changes: 15 additions & 2 deletions FirebaseUI/Auth/API/FirebaseLoginViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
*/
@property(weak, nonatomic) IBOutlet NSLayoutConstraint *totalHeightConstraint;

/**
* Dismissal callback on success or failure.
*/
@property (nonatomic, copy) void (^dismissCallback)(FAuthData *user, NSError *error);

/**
* The Firebase database reference which to authenticate against.
*/
Expand Down Expand Up @@ -157,10 +162,18 @@

/**
* Enables a given identity provider and allows for login and logout actions against it.
* @param provider A string representing the desired identity provider to log in with
* @param provider An enum representing the desired identity provider to log in with
* @return FirebaseLoginViewController
*/
- (instancetype)enableProvider:(NSString *)provider;
- (instancetype)enableProvider:(FAuthProvider)provider;

/**
* Callback that fires when after the controller is dismissed (either on success or on failure).
* If successful, the user field will be populated; if an error occurred the error field will be populated.
* @param callback A block that returns a user on success or an error on failure.
* @return void
*/
- (void)didDismissWithBlock:(void (^)(FAuthData *user, NSError *error))callback;

/**
* Logs the currently authenticated user out of both Firebase and the currently logged in identity
Expand Down
8 changes: 1 addition & 7 deletions FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,f
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
Expand All @@ -32,18 +32,12 @@

#import "FirebaseAuthConstants.h"

NSString *const kTwitterAuthProvider = @"twitter";
NSString *const kTwitterApiKey = @"TwitterApiKey";

NSString *const kFacebookAuthProvider = @"facebook";
NSString *const kFacebookAppId = @"FacebookAppID";
NSString *const kFacebookDisplayName = @"FacebookDisplayName";
NSString *const kFacebookEmailScope = @"email";

NSString *const kGoogleAuthProvider = @"google";

NSString *const kPasswordAuthProvider = @"password";

CGFloat const kHeaderWidth = 258.0f;
CGFloat const kHeaderHeight = 60.0f;
CGFloat const kHeaderSpace = 10.0f;
Expand Down
4 changes: 2 additions & 2 deletions FirebaseUI/Auth/Implementation/FirebaseFacebookAuthProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ @implementation FirebaseFacebookAuthProvider {
- (instancetype)initWithRef:(Firebase *)ref authDelegate:(id<FirebaseAuthDelegate>)authDelegate {
self = [super initWithRef:ref authDelegate:authDelegate];
if (self) {
self.provider = kFacebookAuthProvider;
self.provider = FAuthProviderFacebook;
[self configureProvider];
}
return self;
Expand Down Expand Up @@ -77,7 +77,7 @@ - (void)login {
NSString *accessToken =
[[FBSDKAccessToken currentAccessToken] tokenString];

[self.ref authWithOAuthProvider:kFacebookAuthProvider
[self.ref authWithOAuthProvider:@"facebook"
token:accessToken
withCompletionBlock:^(NSError *error, FAuthData *authData) {
if (error) {
Expand Down
4 changes: 2 additions & 2 deletions FirebaseUI/Auth/Implementation/FirebaseGoogleAuthProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (instancetype)initWithRef:(Firebase *)ref
uiDelegate:(UIViewController<GIDSignInUIDelegate> *)uiDelegate {
self = [super initWithRef:ref authDelegate:authDelegate];
if (self) {
self.provider = kGoogleAuthProvider;
self.provider = FAuthProviderGoogle;
[self configureProvider];
[GIDSignIn sharedInstance].delegate = self;
[GIDSignIn sharedInstance].uiDelegate = uiDelegate;
Expand Down Expand Up @@ -79,7 +79,7 @@ - (void)logout {
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error {
[self.ref authWithOAuthProvider:kGoogleAuthProvider
[self.ref authWithOAuthProvider:@"google"
token:user.authentication.accessToken
withCompletionBlock:^(NSError *error, FAuthData *authData) {
if (error) {
Expand Down
90 changes: 55 additions & 35 deletions FirebaseUI/Auth/Implementation/FirebaseLoginButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

@implementation FirebaseLoginButton

- (instancetype)initWithProvider:(NSString *)provider {
- (instancetype)initWithProvider:(FAuthProvider)provider {
self = [super initWithFrame:CGRectZero];
if (self) {
self.provider = provider;
Expand All @@ -45,43 +45,63 @@ - (instancetype)initWithProvider:(NSString *)provider {
return self;
}

- (UIColor *)backgroundColorForProvider:(NSString *)provider {
if ([provider isEqualToString:kGoogleAuthProvider]) {
return [UIColor colorWithRed:221.0f / 255.0f
green:75.0f / 255.0f
blue:57.0f / 255.0f
alpha:255.0f / 255.0f];
} else if ([provider isEqualToString:kFacebookAuthProvider]) {
return [UIColor colorWithRed:59.0f / 255.0f
green:89.0f / 255.0f
blue:152.0f / 255.0f
alpha:255.0f / 255.0f];
} else if ([provider isEqualToString:kTwitterAuthProvider]) {
return [UIColor colorWithRed:0.0f / 255.0f
green:172.0f / 255.0f
blue:237.0f / 255.0f
alpha:255.0f / 255.0f];
} else if ([provider isEqualToString:kPasswordAuthProvider]) {
return [UIColor colorWithRed:22.0f / 255.0f
green:150.0f / 255.0f
blue:243.0f / 255.0f
alpha:255.0f / 255.0f];
} else {
return [UIColor blackColor];
- (UIColor *)backgroundColorForProvider:(FAuthProvider)provider {
switch (provider) {
case FAuthProviderFacebook:
return [UIColor colorWithRed:59.0f / 255.0f
green:89.0f / 255.0f
blue:152.0f / 255.0f
alpha:255.0f / 255.0f];
break;

case FAuthProviderGoogle:
return [UIColor colorWithRed:221.0f / 255.0f
green:75.0f / 255.0f
blue:57.0f / 255.0f
alpha:255.0f / 255.0f];
break;

case FAuthProviderTwitter:
return [UIColor colorWithRed:0.0f / 255.0f
green:172.0f / 255.0f
blue:237.0f / 255.0f
alpha:255.0f / 255.0f];
break;

case FAuthProviderPassword:
return [UIColor colorWithRed:22.0f / 255.0f
green:150.0f / 255.0f
blue:243.0f / 255.0f
alpha:255.0f / 255.0f];
break;

default:
return [UIColor blackColor];
break;
}
}

- (NSString *)titleForProvider:(NSString *)provider {
if ([provider isEqualToString:kGoogleAuthProvider]) {
return @"Google";
} else if ([provider isEqualToString:kFacebookAuthProvider]) {
return @"Facebook";
} else if ([provider isEqualToString:kTwitterAuthProvider]) {
return @"Twitter";
} else if ([provider isEqualToString:kPasswordAuthProvider]) {
return @"Login";
} else {
return @"Unknown Provider";
- (NSString *)titleForProvider:(FAuthProvider)provider {
switch (provider) {
case FAuthProviderFacebook:
return @"Facebook";
break;

case FAuthProviderGoogle:
return @"Google";
break;

case FAuthProviderTwitter:
return @"Twitter";
break;

case FAuthProviderPassword:
return @"Log In";
break;

default:
return @"Unknown Provider";
break;
}
}

Expand Down
Loading

0 comments on commit a45202b

Please sign in to comment.