Skip to content

Commit

Permalink
Make Sign in with Apple button white in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tidbeck committed Jun 9, 2020
1 parent 49241ed commit 2e96ba2
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions OAuth/FirebaseOAuthUI/FUIOAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ @interface FUIOAuth () <ASAuthorizationControllerDelegate, ASAuthorizationContro
*/
@property(nonatomic, strong) UIColor *buttonBackgroundColor;

/** @property buttonTextColor
@brief The text color that should be used for the sign in button of the provider.
*/
@property(nonatomic, readwrite) UIColor *buttonTextColor;

/** @property scopes
@brief Array used to configure the OAuth scopes.
*/
Expand Down Expand Up @@ -118,6 +123,7 @@ - (instancetype)initWithAuthUI:(FUIAuth *)authUI
_signInLabel = buttonLabelText;
_shortName = shortName;
_buttonBackgroundColor = buttonColor;
_buttonTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
_icon = iconImage;
_scopes = scopes;
_customParameters = customParameters;
Expand Down Expand Up @@ -185,17 +191,26 @@ + (FUIOAuth *)yahooAuthProvider {
}

+ (FUIOAuth *)appleAuthProvider {
UIImage *iconImage = [FUIAuthUtils imageNamed:@"ic_apple"
fromBundleNameOrNil:@"FirebaseOAuthUI"];
UIColor *buttonColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
UIColor *buttonTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
iconImage = [iconImage imageWithTintColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]];
buttonColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
buttonTextColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
}
FUIOAuth *provider = [[FUIOAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]
providerID:@"apple.com"
buttonLabelText:@"Sign in with Apple"
shortName:@"Apple"
buttonColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]
iconImage:[FUIAuthUtils imageNamed:@"ic_apple"
fromBundleNameOrNil:@"FirebaseOAuthUI"]
buttonColor:buttonColor
iconImage:iconImage
scopes:@[@"name", @"email"]
customParameters:nil
loginHintKey:nil];
provider.buttonAlignment = FUIButtonAlignmentCenter;
provider.buttonTextColor = buttonTextColor;
return provider;
}

Expand All @@ -215,10 +230,6 @@ - (nullable NSString *)idToken {
return nil;
}

- (UIColor *)buttonTextColor {
return [UIColor whiteColor];
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
- (void)signInWithEmail:(nullable NSString *)email
Expand Down

0 comments on commit 2e96ba2

Please sign in to comment.