-
Notifications
You must be signed in to change notification settings - Fork 1
Google Auth - Implement Auth Components and Add Icon Assets (Part 2) #2
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
Changes from all commits
23d30a8
1229e38
e087ad3
48f957a
47a6554
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package com.cornellappdev.hustle.ui.components.general | ||
|
|
||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.width | ||
| import androidx.compose.material3.Card | ||
| import androidx.compose.material3.CardDefaults | ||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.IconButton | ||
| import androidx.compose.material3.MaterialTheme | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.cornellappdev.hustle.R | ||
|
|
||
| @Composable | ||
| fun ErrorMessage( | ||
| message: String, | ||
| onDismiss: () -> Unit, | ||
| modifier: Modifier = Modifier | ||
| ) { | ||
| Card( | ||
| modifier = modifier.fillMaxWidth(), | ||
| colors = CardDefaults.cardColors( | ||
| containerColor = MaterialTheme.colorScheme.errorContainer | ||
| ) | ||
| ) { | ||
| Row( | ||
| modifier = Modifier.padding(16.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Icon( | ||
| painter = painterResource(id = R.drawable.ic_warning), | ||
| contentDescription = null, | ||
| tint = MaterialTheme.colorScheme.onErrorContainer | ||
| ) | ||
|
|
||
| Spacer(modifier = Modifier.width(8.dp)) | ||
|
|
||
| Text( | ||
| text = message, | ||
| style = MaterialTheme.typography.bodyMedium, | ||
| color = MaterialTheme.colorScheme.onErrorContainer, | ||
| modifier = Modifier.weight(1f) | ||
| ) | ||
|
|
||
| IconButton(onClick = onDismiss) { | ||
| Icon( | ||
| painter = painterResource(id = R.drawable.ic_close), | ||
| contentDescription = "Dismiss", | ||
| tint = MaterialTheme.colorScheme.onErrorContainer | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun ErrorMessagePreview() { | ||
| ErrorMessage( | ||
| message = "Sign in with your Cornell email", | ||
| onDismiss = {} | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package com.cornellappdev.hustle.ui.components.onboarding | ||
|
|
||
| import androidx.compose.foundation.BorderStroke | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.CircularProgressIndicator | ||
| import androidx.compose.material3.Icon | ||
| 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.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import com.cornellappdev.hustle.R | ||
|
|
||
| @Composable | ||
| fun GoogleSignInButton( | ||
| onClick: () -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| isLoading: Boolean = false | ||
| ) { | ||
| OutlinedButton( | ||
| onClick = onClick, | ||
| enabled = !isLoading, | ||
| modifier = modifier | ||
| .fillMaxWidth() | ||
| .height(48.dp), | ||
| colors = ButtonDefaults.outlinedButtonColors( | ||
| containerColor = Color.White, | ||
| contentColor = Color.Black | ||
| ), | ||
| border = BorderStroke(1.dp, Color.Gray.copy(alpha = 0.3f)) | ||
| ) { | ||
| Row( | ||
| verticalAlignment = Alignment.CenterVertically, | ||
| horizontalArrangement = Arrangement.spacedBy(12.dp) | ||
| ) { | ||
| if (isLoading) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: if you want you could do an animated content with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like a great idea, and I would normally add this, but I think I will hold off for now just until I get the actual auth screen designs in case the button + loading state is different. |
||
| CircularProgressIndicator( | ||
| modifier = Modifier.size(20.dp), | ||
| strokeWidth = 2.dp | ||
| ) | ||
| } else { | ||
| Icon( | ||
| painter = painterResource(id = R.drawable.ic_google), | ||
| contentDescription = "Google Logo", | ||
| modifier = Modifier.size(20.dp), | ||
| tint = Color.Unspecified | ||
| ) | ||
| } | ||
|
|
||
| Text( | ||
| text = if (isLoading) "Signing in..." else "Continue with Google", | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun GoogleSignInButtonPreview() { | ||
| GoogleSignInButton(onClick = {}, isLoading = false) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960"> | ||
| <path | ||
| android:pathData="m256,760 l-56,-56 224,-224 -224,-224 56,-56 224,224 224,-224 56,56 -224,224 224,224 -56,56 -224,-224 -224,224Z" | ||
| android:fillColor="#e3e3e3"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="48dp" | ||
| android:height="48dp" | ||
| android:viewportWidth="48" | ||
| android:viewportHeight="48"> | ||
| <path | ||
| android:pathData="M43.611,20.083H42V20H24v8h11.303c-1.649,4.657 -6.08,8 -11.303,8c-6.627,0 -12,-5.373 -12,-12c0,-6.627 5.373,-12 12,-12c3.059,0 5.842,1.154 7.961,3.039l5.657,-5.657C34.046,6.053 29.268,4 24,4C12.955,4 4,12.955 4,24c0,11.045 8.955,20 20,20c11.045,0 20,-8.955 20,-20C44,22.659 43.862,21.35 43.611,20.083z" | ||
| android:fillColor="#FFC107"/> | ||
| <path | ||
| android:pathData="M6.306,14.691l6.571,4.819C14.655,15.108 18.961,12 24,12c3.059,0 5.842,1.154 7.961,3.039l5.657,-5.657C34.046,6.053 29.268,4 24,4C16.318,4 9.656,8.337 6.306,14.691z" | ||
| android:fillColor="#FF3D00"/> | ||
| <path | ||
| android:pathData="M24,44c5.166,0 9.86,-1.977 13.409,-5.192l-6.19,-5.238C29.211,35.091 26.715,36 24,36c-5.202,0 -9.619,-3.317 -11.283,-7.946l-6.522,5.025C9.505,39.556 16.227,44 24,44z" | ||
| android:fillColor="#4CAF50"/> | ||
| <path | ||
| android:pathData="M43.611,20.083H42V20H24v8h11.303c-0.792,2.237 -2.231,4.166 -4.087,5.571c0.001,-0.001 0.002,-0.001 0.003,-0.002l6.19,5.238C36.971,39.205 44,34 44,24C44,22.659 43.862,21.35 43.611,20.083z" | ||
| android:fillColor="#1976D2"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24"> | ||
| <group> | ||
| <clip-path | ||
| android:pathData="M0,0h24v24h-24z"/> | ||
| <path | ||
| android:pathData="M4,21V9L12,3L20,9V21H14V14H10V21H4Z" | ||
| android:fillColor="#469110"/> | ||
| </group> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="20dp" | ||
| android:height="16dp" | ||
| android:viewportWidth="20" | ||
| android:viewportHeight="16"> | ||
| <path | ||
| android:pathData="M2,16C1.45,16 0.979,15.804 0.587,15.413C0.196,15.021 0,14.55 0,14V2C0,1.45 0.196,0.979 0.587,0.587C0.979,0.196 1.45,0 2,0H18C18.55,0 19.021,0.196 19.413,0.587C19.804,0.979 20,1.45 20,2V14C20,14.55 19.804,15.021 19.413,15.413C19.021,15.804 18.55,16 18,16H2ZM10,9L2,4V14H18V4L10,9ZM10,7L18,2H2L10,7ZM2,4V2V14V4Z" | ||
| android:fillColor="#636161"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="16dp" | ||
| android:height="16dp" | ||
| android:viewportWidth="16" | ||
| android:viewportHeight="16"> | ||
| <path | ||
| android:pathData="M8,8C6.9,8 5.958,7.608 5.175,6.825C4.392,6.042 4,5.1 4,4C4,2.9 4.392,1.958 5.175,1.175C5.958,0.392 6.9,0 8,0C9.1,0 10.042,0.392 10.825,1.175C11.608,1.958 12,2.9 12,4C12,5.1 11.608,6.042 10.825,6.825C10.042,7.608 9.1,8 8,8ZM0,16V13.2C0,12.633 0.146,12.113 0.438,11.637C0.729,11.163 1.117,10.8 1.6,10.55C2.633,10.033 3.683,9.646 4.75,9.387C5.817,9.129 6.9,9 8,9C9.1,9 10.183,9.129 11.25,9.387C12.317,9.646 13.367,10.033 14.4,10.55C14.883,10.8 15.271,11.163 15.563,11.637C15.854,12.113 16,12.633 16,13.2V16H0ZM2,14H14V13.2C14,13.017 13.954,12.85 13.863,12.7C13.771,12.55 13.65,12.433 13.5,12.35C12.6,11.9 11.692,11.563 10.775,11.337C9.858,11.113 8.933,11 8,11C7.067,11 6.142,11.113 5.225,11.337C4.308,11.563 3.4,11.9 2.5,12.35C2.35,12.433 2.229,12.55 2.138,12.7C2.046,12.85 2,13.017 2,13.2V14ZM8,6C8.55,6 9.021,5.804 9.413,5.412C9.804,5.021 10,4.55 10,4C10,3.45 9.804,2.979 9.413,2.588C9.021,2.196 8.55,2 8,2C7.45,2 6.979,2.196 6.588,2.588C6.196,2.979 6,3.45 6,4C6,4.55 6.196,5.021 6.588,5.412C6.979,5.804 7.45,6 8,6Z" | ||
| android:fillColor="#636161"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="960" | ||
| android:viewportHeight="960"> | ||
| <path | ||
| android:pathData="m40,840 l440,-760 440,760L40,840ZM480,720q17,0 28.5,-11.5T520,680q0,-17 -11.5,-28.5T480,640q-17,0 -28.5,11.5T440,680q0,17 11.5,28.5T480,720ZM440,600h80v-200h-80v200Z" | ||
| android:fillColor="#e3e3e3"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||
| <resources> | ||||
| <string name="app_name">Hustle</string> | ||||
| <string name="default_web_client_id">1054767037583-oh008pkkqev5veggoa896b8lj3e4hd86.apps.googleusercontent.com</string> | ||||
|
||||
| <string name="default_web_client_id">1054767037583-oh008pkkqev5veggoa896b8lj3e4hd86.apps.googleusercontent.com</string> |
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.
Is fixed in related PR (part 1)
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.
Curious about why you need
ACCESS_NETWORK_STATE? Haven't seen this permission beforeThere 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.
Tbh, I thought it was just internet, but in their documentation https://developer.android.com/develop/connectivity/network-ops/connecting, they included access network state. I think it is mainly to allow us to check if the device is connected to the internet or not