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

SignIn Screen, in SwiftUI #544

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

krugerk
Copy link
Contributor

@krugerk krugerk commented Dec 6, 2024

Summary

The app has been bumped to min iOS 17 and much, if not all of the app, can be in SwiftUI. This MR can be a first step, the Sign In screen in SwiftUI.

screenshots of before and after

before

before - horizontal - signin - dark
before - horizontal - signin - light
before - signin - dark
before - signin - invalid credentials - dark
before - signin - light
before - signin - missing uesrname or password - dark

after

after - horizontal - sign in - dark
after - horizontal - sign in - light
after - signin - dark
after - signin - light
after - signing in - dark
after - signing in - invalid credentials - dark
after - signing in - missing username or password

Validation

  • built the app in Xcode locally
  • launched the app on the simulator
  • logged in and out and with valid credentials and with invalid ones
  • viewed in both light to dark modes
  • viewed in iPhone Simulator in both landscape and portrait
  • brought app into foreground both in both logged in and logged out states

Notes

Would render #543 obsolete.

@krugerk krugerk force-pushed the feature/swiftui-signin-screen branch from cbd3487 to 9b7c83e Compare December 6, 2024 13:41
}
.background(Color.gray)
.cornerRadius(8)
.disabled(viewModel.isLoading)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • black background, yellow border, yellow text when dark mode
  • gray background, no border, black text when light mode

BeeSwift/SignInView.swift Outdated Show resolved Hide resolved
@krugerk krugerk force-pushed the feature/swiftui-signin-screen branch from 98bcd41 to 960796d Compare December 16, 2024 22:47
Copy link
Collaborator

@theospears theospears left a comment

Choose a reason for hiding this comment

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

Overall this looks good. Apple seems to be investing heavily enough in SwiftUI that it makes sense to start moving BeeSwift in that direction, and I agree the login screen is a good first candidate.

I added a bunch of comments inline. The ones tagged as [Do] are blocking for merge.

try await Task.sleep(nanoseconds: 3_000_000_000)
} catch {
print("canceled early")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is code you added to test the loading state but shouldn't be merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The min process time was intentional so as to provide for a better user experience, actually. When tapping the button to trigger a sign in, it is usually a very quick process and one hardly has a chance to notice the progress indicator or the network activity indicator. If we are to show these, then they should be shown long enough for the user to have had a chance to recognize them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Plus when the user logs in, the endpoint returns a user object completed with a list of goal names. It could be that the app then presents a loading state of the gallery with the data it has while it continues fetching each goal and filling in the cells.



private func presentSignInScreen() {
let shallPresentSignIn = presentedViewController == nil || !isSignInViewBeingPresented
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Nit] Isn't presentedViewController == nil duplicative with the rules in isSignInViewBeingPresented?


let hostingVC = UIHostingController(rootView: SignInView())
hostingVC.modalPresentationStyle = .fullScreen
self.present(hostingVC, animated: true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

No action: Medium term I'd like to move to having GalleryView only exist when logged in, and have a higher level view decide if the user is logged in or not, and present it or the sign in screen appropriately. That's definitely not something for this PR though.

.stroke(.clear)
}
}
// .cornerRadius(4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Nit] Either uncomment or delete


var body: some View {
Button(action: action) {
Label("Sign In", systemImage: "iphone.and.arrow.forward.inward")
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Nit] I don't think this image actually renders anywhere?


}
.alert("Could not sign in", isPresented: $showingFailedSignInAlert) {
Button("OK", role: .cancel) { }
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do these interact? Does clicking the OK button clear the variable?

struct SignInView: View {
@StateObject private var viewModel = SignInViewModel()
@State private var showingFailedSignInAlert = false
@State private var showingMissingDataAlert = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious how you decided what state should be in the ViewModel vs what should live directly in the view?


Spacer()
Spacer()
Spacer()
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Nit] This is a surprising pattern. I'm guessing it's to result in the overall login being positioned vertically offset from center. I wonder if there is a way to do that directly via e.g. different weights for top and bottom padding? If not, let's add a comment.

SecureField("Password", text: $viewModel.password)
.textFieldStyle(RoundedBorderTextFieldStyle())
.textInputAutocapitalization(.never)
.submitLabel(.done)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Consider] I confirmed using a password manager will auto-fill these fields. Can we make it auto-trigger the login after filling too?

}
}

private func signIn() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would have guessed this method is allowed to be async (and thus not need the task)

took the opportunity to modernize the screen a bit
background color of yellow, loading indicator
and twaek the version shown in dark mode
@krugerk krugerk force-pushed the feature/swiftui-signin-screen branch from 960796d to de9c2a4 Compare December 28, 2024 11:09
@krugerk krugerk requested a review from a team as a code owner December 28, 2024 11:09
@krugerk krugerk requested review from theospears and removed request for a team December 28, 2024 11:09
BeeSwift/SignInButton.swift Outdated Show resolved Hide resolved
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.

2 participants