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

[Auth] Convert LoginView to SwiftUI #13628

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

[Auth] Convert LoginView to SwiftUI #13628

wants to merge 17 commits into from

Conversation

ncooke3
Copy link
Member

@ncooke3 ncooke3 commented Sep 11, 2024

#no-changelog

@ncooke3 ncooke3 marked this pull request as draft September 11, 2024 21:29
accentColor: .white,
backgroundColor: .orange
) {
Task {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd refactor the code in this closure into a function on the view. Or maybe even into a view model.

Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored out into a function on the view. I'll leave this thread open to consider doing a view model. For now, I'll focus on refactoring the UI bits..

}
}
.alert("Enter one time passcode.", isPresented: $showingAlert) {
TextField("Verification Code", text: $onetimePasscode)
Copy link
Contributor

Choose a reason for hiding this comment

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

To keep the view's body readable, this should probably be a standalone view or a view builder function on the surrounding view

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, sorry could you explain this a little bit more? I'm not fully following.

createAccountButton.centerXAnchor.constraint(equalTo: centerXAnchor),
createAccountButton.topAnchor.constraint(equalTo: loginButton.bottomAnchor, constant: 5),
])
// TODO(ncooke3): Use view modifiers?
Copy link
Contributor

Choose a reason for hiding this comment

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

Or implement a custom button style.

Copy link
Member Author

@ncooke3 ncooke3 Oct 14, 2024

Choose a reason for hiding this comment

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

Yes, a button style sounds good. When I tried to create a very simple button style, the custom style lost the button's default ability to change text color on tap. I feel like I'm not doing something right if I have to reimplement basic button effects.

private struct MyButtonStyle : ButtonStyle {
  func makeBody(configuration: Configuration) -> some View {
    configuration.label
  }
}

#Preview {
  Button("Hello") {}
  .buttonStyle(MyButtonStyle())
}
Screenshot 2024-10-14 at 12 59 42 PM

Should I leave this as is? What's the most idiomatic pattern?

Copy link
Member Author

Choose a reason for hiding this comment

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

Current render:
Screenshot 2024-10-14 at 1 03 50 PM

Any feedback welcome.

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

Successfully merging this pull request may close these issues.

3 participants