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

No localization support, and cannot edit the buttonTextColor #1210

Open
jmquint00 opened this issue Oct 13, 2024 · 2 comments
Open

No localization support, and cannot edit the buttonTextColor #1210

jmquint00 opened this issue Oct 13, 2024 · 2 comments

Comments

@jmquint00
Copy link

It looks like Localization is not supported?

simulator_screenshot_020D1CF2-86D2-4F49-8F54-E2ED190759F0

So I thought I would just do custom auth provider. See below...

class LocalizedAppleAuthProvider: FUIOAuth {
    init() {
        let buttonLabelText = NSLocalizedString("AuthSignInWithApple", comment: "")
        let shortName = NSLocalizedString("AuthProviderApple", comment: "")
        let buttonColor = UIColor.appleInverse
        let iconImage = UIImage(systemName: "applelogo")?.withTintColor(.apple, renderingMode: .alwaysOriginal) ??UIImage().withTintColor(.apple, renderingMode: .alwaysOriginal)
        //let (iconImage, buttonColor, buttonTextColor) = LocalizedAppleAuthProvider.appearanceForCurrentStyle()
        let textColor = UIColor.black
        super.init(
            authUI: FUIAuth.defaultAuthUI()!,
            providerID: "apple.com",
            buttonLabelText: buttonLabelText,
            shortName: shortName,
            buttonColor: buttonColor,
            iconImage: iconImage,
            scopes: [],
            customParameters: [:],
            loginHintKey: nil
        )
    self.buttonAlignment = .center
    }
}

...but cannot seem to be able to modify the color of the text on the button. So, on dark mode, I end up with

simulator_screenshot_4C1AD038-0A61-40BA-B5EB-EE2ED995E756

Thanks for the help,

J.

@jmquint00
Copy link
Author

jmquint00 commented Oct 13, 2024

I am looking at the FirebaseOauthUI pod and I see...

- (instancetype)initWithAuthUI:(FUIAuth *)authUI
                    providerID:(NSString *)providerID
               buttonLabelText:(NSString *)buttonLabelText
                     shortName:(NSString *)shortName
                   buttonColor:(UIColor *)buttonColor
                     iconImage:(UIImage *)iconImage
                        scopes:(nullable NSArray<NSString *> *)scopes
              customParameters:(nullable NSDictionary<NSString *, NSString*> *)customParameters
                  loginHintKey:(nullable NSString *)loginHintKey {
  if (self = [super init]) {
    _authUI = authUI;
    _providerID = providerID;
    _signInLabel = buttonLabelText;
    _shortName = shortName;
    _buttonBackgroundColor = buttonColor;
    _buttonTextColor = [UIColor whiteColor]; <---I think this should no be set here??
    _icon = iconImage;
    _scopes = scopes;
    _customParameters = customParameters;
    _loginHintKey = loginHintKey;
    if ((_authUI.isEmulatorEnabled || ![_providerID isEqualToString:@"apple.com"]) && ![_providerID isEqualToString:@"facebook.com"]) {
      _provider = [FIROAuthProvider providerWithProviderID:self.providerID auth:_authUI.auth];
    }
  }
  return self;
}

and

(FUIOAuth *)appleAuthProviderWithAuthUI:(FUIAuth *)authUI
                       userInterfaceStyle:(UIUserInterfaceStyle)userInterfaceStyle {
  UIImage *iconImage = [FUIAuthUtils imageNamed:@"ic_apple"
                                     fromBundle:[FUIOAuth bundle]];
  UIColor *buttonColor = [UIColor blackColor];
  UIColor *buttonTextColor = [UIColor whiteColor];
  if (userInterfaceStyle == UIUserInterfaceStyleDark) {
    iconImage = [iconImage imageWithTintColor:[UIColor blackColor]];
    buttonColor = [UIColor whiteColor];
    buttonTextColor = [UIColor blackColor];
  } else if (userInterfaceStyle == UIUserInterfaceStyleLight) {
    iconImage = [iconImage imageWithTintColor:[UIColor whiteColor]];
    buttonColor = [UIColor blackColor];
    buttonTextColor = [UIColor whiteColor];
  } else {
    iconImage = [iconImage imageWithTintColor:[UIColor whiteColor]];
  }
  FUIOAuth *provider = [[FUIOAuth alloc] initWithAuthUI:authUI
                                             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;
}

I dont know where I could make a change to fix the text color for now.

@jmquint00
Copy link
Author

switched it to --> _buttonTextColor = [UIColor colorNamed:@"Apple"];

Seems to be working, but that has to be a bug right?

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

1 participant