-
Notifications
You must be signed in to change notification settings - Fork 1
Google Auth - Implement Basic Auth Screens (Part 3) #3
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a38acd3
Implement Basic Sign In Screen, Implement basic profile screen with s…
AndrewCheung360 6f7870c
Made updates to reflect new auth vm changes
AndrewCheung360 6dc1f56
Merge branch 'main' into andrew/auth-screens
AndrewCheung360 5e19c43
Addressed PR comments - Updated parameter names and user null type
AndrewCheung360 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/main/java/com/cornellappdev/hustle/ui/screens/onboarding/SignInScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package com.cornellappdev.hustle.ui.screens.onboarding | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.tooling.preview.PreviewParameter | ||
| import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
| import com.cornellappdev.hustle.ui.components.general.ErrorMessage | ||
| import com.cornellappdev.hustle.ui.components.onboarding.GoogleSignInButton | ||
|
|
||
| @Composable | ||
| fun SignInScreen( | ||
| onGoogleSignInButtonClick: () -> Unit, | ||
| isSignInLoading: Boolean, | ||
| errorMessage: String?, | ||
| onDismissError: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| ) { | ||
| Box(modifier = modifier.fillMaxSize()) { | ||
| Column( | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| verticalArrangement = Arrangement.Center, | ||
| modifier = Modifier.fillMaxSize() | ||
| ) { | ||
| GoogleSignInButton( | ||
| onClick = onGoogleSignInButtonClick, isLoading = isSignInLoading | ||
| ) | ||
| } | ||
| errorMessage?.let { error -> | ||
| ErrorMessage( | ||
| message = error, | ||
| onDismiss = onDismissError, | ||
| modifier = Modifier.align(Alignment.BottomCenter) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class SignInErrorMessageProvider : PreviewParameterProvider<String?> { | ||
| override val values = sequenceOf( | ||
| null, | ||
| "Sign in failed. Please sign in with your Cornell email" | ||
| ) | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun SignInScreenPreview( | ||
| @PreviewParameter(SignInErrorMessageProvider::class) errorMessage: String? | ||
| ) { | ||
| SignInScreen( | ||
| onGoogleSignInButtonClick = {}, | ||
| isSignInLoading = false, | ||
| errorMessage = errorMessage, | ||
| onDismissError = {}) | ||
| } | ||
83 changes: 83 additions & 0 deletions
83
app/src/main/java/com/cornellappdev/hustle/ui/screens/profile/ProfileScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package com.cornellappdev.hustle.ui.screens.profile | ||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.shape.CircleShape | ||
| import androidx.compose.material3.CircularProgressIndicator | ||
| import androidx.compose.material3.OutlinedButton | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.draw.clip | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import coil3.compose.AsyncImage | ||
| import com.cornellappdev.hustle.data.model.user.User | ||
|
|
||
| @Composable | ||
| fun ProfileScreen( | ||
| user: User, | ||
| onSignOut: () -> Unit, | ||
| isSignOutLoading: Boolean, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Column( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
| .padding(16.dp), | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| verticalArrangement = Arrangement.spacedBy(24.dp) | ||
| ) { | ||
| // User Info | ||
| AsyncImage( | ||
| model = user.photoUrl, | ||
| contentDescription = "Profile picture", | ||
| modifier = Modifier | ||
| .size(120.dp) | ||
| .clip(CircleShape) | ||
| ) | ||
|
|
||
| Text( | ||
| text = user.displayName ?: "Unknown User" | ||
| ) | ||
|
|
||
| Text( | ||
| text = user.email ?: "" | ||
| ) | ||
|
|
||
| // Sign Out Button | ||
| OutlinedButton( | ||
| onClick = onSignOut, | ||
| enabled = !isSignOutLoading, | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) { | ||
| if (isSignOutLoading) { | ||
| CircularProgressIndicator( | ||
| modifier = Modifier.size(20.dp), strokeWidth = 2.dp | ||
| ) | ||
| } else { | ||
| Text("Sign Out") | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun ProfileScreenPreview() { | ||
| ProfileScreen( | ||
| user = User( | ||
| firebaseUid = "1", | ||
| displayName = "John Doe", | ||
| email = "jd123@cornell.edu", | ||
| photoUrl = null | ||
| ), | ||
| onSignOut = {}, | ||
| isSignOutLoading = false | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes me happy to see you are using this!