├── .idea ├── .gitignore ├── vcs.xml ├── misc.xml └── modules.xml ├── README.md ├── SignUpWithGoogle-Button-JetpackCompose.iml ├── ic_google_logo.xml └── GoogleButton.kt /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sign Up with Google Button - JetpackCompose | Kotlin 2 | 3 |

4 | YouTube Video Tutorial 5 |

6 |

7 | 8 |

9 | 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SignUpWithGoogle-Button-JetpackCompose.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ic_google_logo.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /GoogleButton.kt: -------------------------------------------------------------------------------- 1 | import androidx.compose.animation.animateContentSize 2 | import androidx.compose.animation.core.LinearOutSlowInEasing 3 | import androidx.compose.animation.core.tween 4 | import androidx.compose.foundation.BorderStroke 5 | import androidx.compose.foundation.clickable 6 | import androidx.compose.foundation.layout.Arrangement 7 | import androidx.compose.foundation.layout.Row 8 | import androidx.compose.foundation.layout.Spacer 9 | import androidx.compose.foundation.layout.height 10 | import androidx.compose.foundation.layout.padding 11 | import androidx.compose.foundation.layout.width 12 | import androidx.compose.material3.CircularProgressIndicator 13 | import androidx.compose.material3.Icon 14 | import androidx.compose.material3.MaterialTheme 15 | import androidx.compose.material3.Surface 16 | import androidx.compose.material3.Text 17 | import androidx.compose.runtime.Composable 18 | import androidx.compose.runtime.getValue 19 | import androidx.compose.runtime.mutableStateOf 20 | import androidx.compose.runtime.remember 21 | import androidx.compose.runtime.setValue 22 | import androidx.compose.ui.Alignment 23 | import androidx.compose.ui.Modifier 24 | import androidx.compose.ui.graphics.Color 25 | import androidx.compose.ui.graphics.Shape 26 | import androidx.compose.ui.res.painterResource 27 | import androidx.compose.ui.unit.dp 28 | 29 | @Composable 30 | fun GoogleButton( 31 | modifier: Modifier = Modifier, 32 | text: String = "Sign Up with Google", 33 | loadingText: String = "Creating Account...", 34 | icon: Int = R.drawable.ic_google_logo, 35 | shape: Shape = MaterialTheme.shapes.medium, 36 | borderColor: Color = Color.LightGray, 37 | backgroundColor: Color = MaterialTheme.colorScheme.surface, 38 | progressIndicatorColor: Color = MaterialTheme.colorScheme.primary, 39 | onClicked: () -> Unit, 40 | ) { 41 | var clicked by remember { mutableStateOf(false) } 42 | Surface( 43 | modifier = modifier 44 | .clip(MaterialTheme.shapes.medium) 45 | .clickable { 46 | clicked = !clicked 47 | onClicked() 48 | }, 49 | shape = shape, 50 | border = BorderStroke(width = 1.dp, color = borderColor), 51 | color = backgroundColor 52 | ) { 53 | Row( 54 | modifier = Modifier 55 | .padding( 56 | start = 12.dp, 57 | end = 16.dp, 58 | top = 12.dp, 59 | bottom = 12.dp 60 | ) 61 | .animateContentSize( 62 | animationSpec = tween( 63 | durationMillis = 300, 64 | easing = LinearOutSlowInEasing 65 | ) 66 | ), 67 | verticalAlignment = Alignment.CenterVertically, 68 | horizontalArrangement = Arrangement.Center 69 | ) { 70 | Icon( 71 | painter = painterResource(id = icon), 72 | contentDescription = "Google Button", 73 | tint = Color.Unspecified 74 | ) 75 | Spacer(modifier = Modifier.width(8.dp)) 76 | Text(text = if (clicked) loadingText else text) 77 | if (clicked) { 78 | Spacer(modifier = Modifier.width(16.dp)) 79 | CircularProgressIndicator( 80 | modifier = Modifier 81 | .height(16.dp) 82 | .width(16.dp), 83 | strokeWidth = 2.dp, 84 | color = progressIndicatorColor 85 | ) 86 | } 87 | } 88 | } 89 | } 90 | --------------------------------------------------------------------------------