Skip to content

Commit 45c95fd

Browse files
authored
Merge pull request #872 from tidbeck/bug/apple_button_dark_mode
Make Sign in with Apple button white in dark mode
2 parents 49241ed + e4f33d6 commit 45c95fd

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

OAuth/FirebaseOAuthUI/FUIOAuth.m

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ @interface FUIOAuth () <ASAuthorizationControllerDelegate, ASAuthorizationContro
7979
*/
8080
@property(nonatomic, strong) UIColor *buttonBackgroundColor;
8181

82+
/** @property buttonTextColor
83+
@brief The text color that should be used for the sign in button of the provider.
84+
*/
85+
@property(nonatomic, readwrite) UIColor *buttonTextColor;
86+
8287
/** @property scopes
8388
@brief Array used to configure the OAuth scopes.
8489
*/
@@ -118,6 +123,7 @@ - (instancetype)initWithAuthUI:(FUIAuth *)authUI
118123
_signInLabel = buttonLabelText;
119124
_shortName = shortName;
120125
_buttonBackgroundColor = buttonColor;
126+
_buttonTextColor = [UIColor whiteColor];
121127
_icon = iconImage;
122128
_scopes = scopes;
123129
_customParameters = customParameters;
@@ -185,17 +191,26 @@ + (FUIOAuth *)yahooAuthProvider {
185191
}
186192

187193
+ (FUIOAuth *)appleAuthProvider {
194+
UIImage *iconImage = [FUIAuthUtils imageNamed:@"ic_apple"
195+
fromBundleNameOrNil:@"FirebaseOAuthUI"];
196+
UIColor *buttonColor = [UIColor blackColor];
197+
UIColor *buttonTextColor = [UIColor whiteColor];
198+
if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) {
199+
iconImage = [iconImage imageWithTintColor:[UIColor blackColor]];
200+
buttonColor = [UIColor whiteColor];
201+
buttonTextColor = [UIColor blackColor];
202+
}
188203
FUIOAuth *provider = [[FUIOAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]
189204
providerID:@"apple.com"
190205
buttonLabelText:@"Sign in with Apple"
191206
shortName:@"Apple"
192-
buttonColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]
193-
iconImage:[FUIAuthUtils imageNamed:@"ic_apple"
194-
fromBundleNameOrNil:@"FirebaseOAuthUI"]
207+
buttonColor:buttonColor
208+
iconImage:iconImage
195209
scopes:@[@"name", @"email"]
196210
customParameters:nil
197211
loginHintKey:nil];
198212
provider.buttonAlignment = FUIButtonAlignmentCenter;
213+
provider.buttonTextColor = buttonTextColor;
199214
return provider;
200215
}
201216

@@ -215,10 +230,6 @@ - (nullable NSString *)idToken {
215230
return nil;
216231
}
217232

218-
- (UIColor *)buttonTextColor {
219-
return [UIColor whiteColor];
220-
}
221-
222233
#pragma clang diagnostic push
223234
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
224235
- (void)signInWithEmail:(nullable NSString *)email

0 commit comments

Comments
 (0)