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

feat: init SwiftUI library for FirebaseAuthSwiftUI #1237

Draft
wants to merge 76 commits into
base: main
Choose a base branch
from

Conversation

russellwheatley
Copy link
Member

@russellwheatley russellwheatley commented Feb 18, 2025

Work in progress, no functionality at the moment. Just setting up the project:

  • Setup a separate directory for SwiftUI libraries.
  • Created two libraries; FirebaseAuthSwiftUI (this has some basic types/class which will be needed later) & FirebaseAuthEmailSwiftUI for email provider functionality.
  • Created a SwiftUI example app in samples/swiftui which pulls in the above libraries for developing.

Copy link
Contributor

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Had one architecture question for consideration.

func onCredentialReceived(_ credential: AuthCredential)
func onCredentialLinked(_ credential: AuthCredential)
// func onMFARequired(_ resolver: MultiFactorResolver)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're targeting this toward SwiftUI users, what do you think of adding a @StateObject that tracks the auth state so consumers can use it directly instead of having to set up their own wrapper? This could be the auth provider itself or a separate object that's managed by the auth provider, or a default implementation of the AuthListenerProtocol.

Copy link
Member Author

@russellwheatley russellwheatley Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @morganchen12 - sorry for the lates response, I was on holiday last week, and this week I wanted something more concrete to show you so we can agree on top level API design/flow. I still need to refactor a few things, but I'm hoping by the end of the day tomorrow I can provide how it works and see if you think it is reasonable. Also - agree on the point of having some form of a state object the user can consume for auth events 👍


public init(configuration: AuthPickerViewConfiguration = AuthPickerViewConfiguration()) {
public init(configuration: AuthPickerViewConfiguration = AuthPickerViewConfiguration(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration would probably be either a view modifier, or better yet, a style.

public var frameWidth: CGFloat
public var frameHeight: CGFloat

public init(warningMessage: String = "Incorrect email address",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these should be view modifiers.

}

public class EmailAuthButtonConfiguration {
public var buttonText: String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In SwiftUI, you configure views by using view modifiers. They allow for a much more scalable configuration of views.

@EnvironmentObject var authFUI: FUIAuth

public var body: some View {
if invalidEmailWarning {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

3 participants