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

Update SignInView.swift #404

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

movsianikov
Copy link

Fix issue with declaration of GoogleSignInButtonViewModel variable. Switching to @StateObject from @ObservedObject allows to customize the button using constructor, otherwise - the customization doesn't work.

Fix issue with declaration of GoogleSignInButtonViewModel variable. Switching to @StateObject from @ObservedObject allows to customize the button using constructor, otherwise - the customization doesn't work.
Copy link

google-cla bot commented May 2, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mdmathias
Copy link
Collaborator

Can you clarify what you mean by "allows to customize the button using constructor, otherwise - the customization doesn't work?" I am not sure what you're fixing.

@movsianikov
Copy link
Author

movsianikov commented May 2, 2024

Can you clarify what you mean by "allows to customize the button using constructor, otherwise - the customization doesn't work?" I am not sure what you're fixing.

Hi @mdmathias , of course! Here you go:

  1. With the current approach this customization does NOT work:
    @ObservedObject private var vm = GoogleSignInButtonViewModel(scheme: .dark, style: .wide, state: .normal)
  2. In order to make it work (workaround), I've customized it in the init() method like this:
    init() {
        vm.style = .wide
        vm.scheme = .dark
    }
  1. But the correct way, since the instance of the GoogleSignInButtonViewModel created in the SignInView, would be to declare it as @StateObject, then the customization will work fine without init() method:
    @ObservedObject private var vm = GoogleSignInButtonViewModel(scheme: .dark, style: .wide, state: .normal)

Please let me know if you have any questions, comments, or concerns.

Thank you!

Best regards,
MAKSYM OVSIANIKOV

@mdmathias
Copy link
Collaborator

@movsianikov I'm sorry! I still don't understand what you mean by the "customization" not working. In SignInView.swift, if you create the vm with a different scheme (e.g., .dark), then the button will be drawn with the dark blue background.

struct SignInView: View {
  @EnvironmentObject var authViewModel: AuthenticationViewModel
  @ObservedObject var vm = GoogleSignInButtonViewModel(scheme: .dark)
...
Screenshot 2024-05-03 at 9 17 49 AM

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

Successfully merging this pull request may close these issues.

None yet

2 participants