Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirebaseUI Sign in with Apple , button label text color error. #845

Closed
fangyuxi opened this issue Mar 21, 2020 · 11 comments
Closed

FirebaseUI Sign in with Apple , button label text color error. #845

fangyuxi opened this issue Mar 21, 2020 · 11 comments
Assignees

Comments

@fangyuxi
Copy link

[REQUIRED] Step 1: Describe your environment

  • Xcode version: _11.3.1
  • Firebase SDK version: _____
  • Firebase Component: Auth___ (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: _____
  • Installation method: CocoaPods | Carthage | Zip file (select one)
  • Firebase/Analytics (6.16.0):
    • Firebase/Core
  • Firebase/Auth (6.16.0):
    • Firebase/CoreOnly
    • FirebaseAuth (~> 6.4.3)
  • Firebase/Core (6.16.0):
    • Firebase/CoreOnly
    • FirebaseAnalytics (= 6.2.2)
  • Firebase/CoreOnly (6.16.0):
    • FirebaseCore (= 6.6.1)
  • Firebase/Database (6.16.0):
    • Firebase/CoreOnly
    • FirebaseDatabase (~> 6.1.4)
  • Firebase/Firestore (6.16.0):
    • Firebase/CoreOnly
    • FirebaseFirestore (~> 1.10.0)
  • Firebase/Messaging (6.16.0):
    • Firebase/CoreOnly
    • FirebaseMessaging (~> 4.2.0)
  • Firebase/Performance (6.16.0):
    • Firebase/CoreOnly
    • FirebasePerformance (~> 3.1.9)
  • Firebase/RemoteConfig (6.16.0):
    • Firebase/CoreOnly
    • FirebaseRemoteConfig (~> 4.4.6)
  • Firebase/Storage (6.16.0):
    • Firebase/CoreOnly
    • FirebaseStorage (~> 3.5.0)
  • FirebaseABTesting (3.1.2):
    • FirebaseAnalyticsInterop (~> 1.3)
    • FirebaseCore (~> 6.1)
    • Protobuf (>= 3.9.2, ~> 3.9)
  • FirebaseAnalytics (6.2.2):
    • FirebaseCore (~> 6.6)
    • FirebaseInstanceID (~> 4.3)
    • GoogleAppMeasurement (= 6.2.2)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.0)
    • GoogleUtilities/MethodSwizzler (~> 6.0)
    • GoogleUtilities/Network (~> 6.0)
    • "GoogleUtilities/NSData+zlib (~> 6.0)"
    • nanopb (= 0.3.9011)
  • FirebaseAnalyticsInterop (1.5.0)
  • FirebaseAuth (6.4.3):
    • FirebaseAuthInterop (~> 1.0)
    • FirebaseCore (~> 6.6)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.5)
    • GoogleUtilities/Environment (~> 6.5)
    • GTMSessionFetcher/Core (~> 1.1)
  • FirebaseAuthInterop (1.0.0)
  • FirebaseCore (6.6.1):
    • FirebaseCoreDiagnostics (~> 1.2)
    • FirebaseCoreDiagnosticsInterop (~> 1.2)
    • GoogleUtilities/Environment (~> 6.5)
    • GoogleUtilities/Logger (~> 6.5)
  • FirebaseCoreDiagnostics (1.2.0):
    • FirebaseCoreDiagnosticsInterop (~> 1.2)
    • GoogleDataTransportCCTSupport (~> 1.3)
    • GoogleUtilities/Environment (~> 6.5)
    • GoogleUtilities/Logger (~> 6.5)
    • nanopb (~> 0.3.901)
  • FirebaseCoreDiagnosticsInterop (1.2.0)
  • FirebaseDatabase (6.1.4):
    • FirebaseAuthInterop (~> 1.0)
    • FirebaseCore (~> 6.0)
    • leveldb-library (~> 1.22)
  • FirebaseFirestore (1.10.1):
    • abseil/algorithm (= 0.20190808)
    • abseil/base (= 0.20190808)
    • abseil/memory (= 0.20190808)
    • abseil/meta (= 0.20190808)
    • abseil/strings/strings (= 0.20190808)
    • abseil/time (= 0.20190808)
    • abseil/types (= 0.20190808)
    • FirebaseAuthInterop (~> 1.0)
    • FirebaseCore (~> 6.2)
    • "gRPC-C++ (= 0.0.9)"
    • leveldb-library (~> 1.22)
    • nanopb (~> 0.3.901)
  • FirebaseInstallations (1.1.0):
    • FirebaseCore (~> 6.6)
    • GoogleUtilities/UserDefaults (~> 6.5)
    • PromisesObjC (~> 1.2)
  • FirebaseInstanceID (4.3.0):
    • FirebaseCore (~> 6.6)
    • FirebaseInstallations (~> 1.0)
    • GoogleUtilities/Environment (~> 6.5)
    • GoogleUtilities/UserDefaults (~> 6.5)
  • FirebaseMessaging (4.2.0):
    • FirebaseAnalyticsInterop (~> 1.5)
    • FirebaseCore (~> 6.6)
    • FirebaseInstanceID (~> 4.3)
    • GoogleUtilities/AppDelegateSwizzler (~> 6.5)
    • GoogleUtilities/Environment (~> 6.5)
    • GoogleUtilities/Reachability (~> 6.5)
    • GoogleUtilities/UserDefaults (~> 6.5)
    • Protobuf (>= 3.9.2, ~> 3.9)
  • FirebasePerformance (3.1.9):
    • FirebaseCore (~> 6.6)
    • FirebaseInstanceID (~> 4.3)
    • FirebaseRemoteConfig (~> 4.4)
    • GoogleToolboxForMac/Logger (~> 2.1)
    • "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
    • GoogleUtilities/Environment (~> 6.2)
    • GoogleUtilities/ISASwizzler (~> 6.2)
    • GoogleUtilities/MethodSwizzler (~> 6.2)
    • GTMSessionFetcher/Core (~> 1.1)
    • Protobuf (~> 3.9)
  • FirebaseRemoteConfig (4.4.6):
    • FirebaseABTesting (~> 3.1)
    • FirebaseAnalyticsInterop (~> 1.4)
    • FirebaseCore (~> 6.2)
    • FirebaseInstanceID (~> 4.2)
    • GoogleUtilities/Environment (~> 6.2)
    • "GoogleUtilities/NSData+zlib (~> 6.2)"
    • Protobuf (>= 3.9.2, ~> 3.9)
  • FirebaseStorage (3.5.0):
    • FirebaseAuthInterop (~> 1.0)
    • FirebaseCore (~> 6.0)
    • GTMSessionFetcher/Core (~> 1.1)
  • FirebaseUI (8.4.1):
    • FirebaseUI/Anonymous (= 8.4.1)
    • FirebaseUI/Auth (= 8.4.1)
    • FirebaseUI/Database (= 8.4.1)
    • FirebaseUI/Email (= 8.4.1)
    • FirebaseUI/Facebook (= 8.4.1)
    • FirebaseUI/Firestore (= 8.4.1)
    • FirebaseUI/Google (= 8.4.1)
    • FirebaseUI/OAuth (= 8.4.1)
    • FirebaseUI/Phone (= 8.4.1)
    • FirebaseUI/Storage (= 8.4.1)
  • FirebaseUI/Anonymous (8.4.1):
    • FirebaseUI/Auth
  • FirebaseUI/Auth (8.4.1):
    • Firebase/Auth (~> 6.0)
    • GoogleUtilities/UserDefaults
  • FirebaseUI/Database (8.4.1):
    • Firebase/Database (~> 6.0)
  • FirebaseUI/Email (8.4.1):
    • FirebaseUI/Auth
  • FirebaseUI/Facebook (8.4.1):
    • FBSDKLoginKit (~> 5.0)
    • FirebaseUI/Auth
  • FirebaseUI/Firestore (8.4.1):
    • Firebase/Firestore
  • FirebaseUI/Google (8.4.1):
    • FirebaseUI/Auth
    • GoogleSignIn (~> 5.0)
  • FirebaseUI/OAuth (8.4.1):
    • FirebaseUI/Auth
  • FirebaseUI/Phone (8.4.1):
    • FirebaseUI/Auth
  • FirebaseUI/Storage (8.4.1):
    • Firebase/Storage (~> 6.0)

[REQUIRED] Step 2: Describe the problem

WechatIMG100

@google-oss-bot

This comment has been minimized.

@fangyuxi
Copy link
Author

I can't create a FUIOAuth use custom text button color.

@fangyuxi
Copy link
Author

fangyuxi commented Mar 21, 2020

So I have to use the following code to fix this UI problem so that I can adapt to the dark mode. UGLY CODE

1011584768824_ pic_hd

Without correction, my app will not pass the review. The reason is as follows.

9da1e9be-83c8-43bb-9676-14c2b1bcc3d0

@ryanwilson ryanwilson transferred this issue from firebase/firebase-ios-sdk Mar 23, 2020
@ryanwilson
Copy link
Member

@fangyuxi I transferred this to the FirebaseUI repo itself since it's related here. This is also related to #823

@ryanwilson
Copy link
Member

We should be using ASAuthorizationAppleIDButton since it's the button provided by Apple and will always conform to proper UI guidelines.

@fangyuxi
Copy link
Author

We should be using ASAuthorizationAppleIDButton since it's the button provided by Apple and will always conform to proper UI guidelines.

We don't have to use the button provided by Apple. At some point, you need to customize this button, and Apple also provides a ui guide to guide us how to customize.

@Casey10110
Copy link

How do you customize it?

@fangyuxi
Copy link
Author

@Casey10110 I can show some code for you.

@fangyuxi
Copy link
Author

fangyuxi commented Sep 27, 2020

@Casey10110 here is the code that customize apple sign in button.

The @"applelogo" image, is provided by Apple.

NSMutableArray<id <FUIAuthProvider>> *providers = @[].mutableCopy;
    if (@available(iOS 13.0, *)) {
        FUIOAuth *apple =  [[FUIOAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]
                                                    providerID:@"apple.com"
                                               buttonLabelText:@"Sign in with Apple"
                                                     shortName:@"Apple"
                                                   buttonColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]
                                                     iconImage:[UIImage imageNamed:@"applelogo"]
                                                        scopes:@[@"name", @"email"]
                                              customParameters:nil
                                                  loginHintKey:nil];
        [providers addObject:apple];
    }
    
    [providers addObject:[FUIFacebookAuth new]];
    [providers addObject:[FUIGoogleAuth new]];
    [providers addObject:[FUIEmailAuth new]];

- (void)reviseAppleSignInButtonUI:(UIView *)rootView {
    for (UIView *subView in [rootView subviews]){
        if (!rootView.subviews.count) {
            return;
        }
        if ([subView isKindOfClass:[UIButton class]]) {
            if ([subView respondsToSelector:@selector(providerUI)]) {
                id<FUIAuthProvider> provider = [subView performSelector:@selector(providerUI)];
                if ([provider.providerID isEqualToString:@"apple.com"]) {
                    self.appleLoginButton = (UIButton *)subView;
                    
                    //revise button ui
                    if (@available(iOS 13.0, *)){
                        
                        self.appleLoginButton.titleLabel.font = [UIFont systemFontOfSize:19.0f];
                        self.appleLoginButton.height = 44;
                       [self.appleLoginButton setTitleColor:[UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trait) {
                           if (trait.userInterfaceStyle == UIUserInterfaceStyleDark) {
                               return [UIColor blackColor];
                           } else {
                               return [UIColor whiteColor];
                           }
                        }] forState:UIControlStateNormal];
                        
                        [self.appleLoginButton setBackgroundColor:[UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trait) {
                           if (trait.userInterfaceStyle == UIUserInterfaceStyleDark) {
                               return [UIColor whiteColor];
                           } else {
                               return [UIColor blackColor];
                           }
                        }]];
                    }
                    return;
                }
            }
        }
        [self reviseAppleSignInButtonUI:subView];
    }
}

The method 'reviseAppleSignInButtonUI' defined in the controller whose super class controller is FUIAuthPickerViewController.

#import <UIKit/UIKit.h>
@import FirebaseUI;

NS_ASSUME_NONNULL_BEGIN

@interface ENLoginController : FUIAuthPickerViewController<FIRAuthUIDelegate>

@end

NS_ASSUME_NONNULL_END

image

@Casey10110
Copy link

Right on, thank you. I just modified the file in the FirebaseUI and recompiled: + (FUIOAuth *)appleAuthProvider { UIImage *iconImage = [FUIAuthUtils imageNamed:@"ic_apple" fromBundleNameOrNil:@"FirebaseOAuthUI"]; UIColor *buttonColor = [UIColor blackColor]; UIColor *buttonTextColor = [UIColor whiteColor]; if (UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleLight) { iconImage = [iconImage imageWithTintColor:[UIColor whiteColor]]; buttonColor = [UIColor blackColor]; buttonTextColor = [UIColor whiteColor]; } FUIOAuth *provider = [[FUIOAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI] providerID:@"apple.com" buttonLabelText:@"Sign in with Apple" shortName:@"Apple" buttonColor:buttonColor iconImage:iconImage scopes:@[@"name", @"email"] customParameters:nil loginHintKey:nil]; //provider.buttonAlignment = FUIButtonAlignmentCenter; provider.buttonTextColor = buttonTextColor; return provider; }

@morganchen12
Copy link
Contributor

This should be fixed in the latest version of FirebaseUI. Please let me know if that's not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants