@@ -8,10 +8,14 @@ import androidx.compose.foundation.layout.fillMaxSize
88import androidx.compose.foundation.layout.fillMaxWidth
99import androidx.compose.foundation.layout.height
1010import androidx.compose.foundation.layout.padding
11+ import androidx.compose.foundation.layout.size
1112import androidx.compose.foundation.text.KeyboardOptions
1213import androidx.compose.material3.Button
1314import androidx.compose.material3.CircularProgressIndicator
15+ import androidx.compose.material3.HorizontalDivider
16+ import androidx.compose.material3.Icon
1417import androidx.compose.material3.MaterialTheme
18+ import androidx.compose.material3.OutlinedButton
1519import androidx.compose.material3.OutlinedTextField
1620import androidx.compose.material3.Text
1721import androidx.compose.material3.TextButton
@@ -22,22 +26,83 @@ import androidx.compose.runtime.saveable.rememberSaveable
2226import androidx.compose.runtime.setValue
2327import androidx.compose.ui.Alignment
2428import androidx.compose.ui.Modifier
29+ import androidx.compose.ui.graphics.Color
30+ import androidx.compose.ui.graphics.vector.ImageVector
31+ import androidx.compose.ui.graphics.vector.path
2532import androidx.compose.ui.text.input.KeyboardType
2633import androidx.compose.ui.text.input.PasswordVisualTransformation
2734import androidx.compose.ui.tooling.preview.Preview
2835import androidx.compose.ui.unit.dp
2936import com.company.template.ui.theme.TemplateTheme
3037
38+ // Google "G" logo as a vector — colours from the brand guidelines
39+ private val GoogleIcon: ImageVector
40+ get() = ImageVector.Builder(
41+ name = "GoogleIcon",
42+ defaultWidth = 24.dp,
43+ defaultHeight = 24.dp,
44+ viewportWidth = 24f,
45+ viewportHeight = 24f
46+ ).apply {
47+ path(fill = androidx.compose.ui.graphics.SolidColor(Color(0xFF4285F4))) {
48+ moveTo(22.56f, 12.25f)
49+ curveToRelative(0f, -0.78f, -0.07f, -1.53f, -0.2f, -2.25f)
50+ horizontalLineTo(12f)
51+ verticalLineToRelative(4.26f)
52+ horizontalLineToRelative(5.92f)
53+ curveToRelative(-0.26f, 1.37f, -1.04f, 2.53f, -2.21f, 3.31f)
54+ verticalLineToRelative(2.77f)
55+ horizontalLineToRelative(3.57f)
56+ curveToRelative(2.08f, -1.92f, 3.28f, -4.74f, 3.28f, -8.09f)
57+ close()
58+ }
59+ path(fill = androidx.compose.ui.graphics.SolidColor(Color(0xFF34A853))) {
60+ moveTo(12f, 23f)
61+ curveToRelative(2.97f, 0f, 5.46f, -0.98f, 7.28f, -2.66f)
62+ lineToRelative(-3.57f, -2.77f)
63+ curveToRelative(-0.98f, 0.66f, -2.23f, 1.06f, -3.71f, 1.06f)
64+ curveToRelative(-2.86f, 0f, -5.29f, -1.93f, -6.16f, -4.53f)
65+ horizontalLineTo(2.18f)
66+ verticalLineToRelative(2.84f)
67+ curveTo(3.99f, 20.53f, 7.7f, 23f, 12f, 23f)
68+ close()
69+ }
70+ path(fill = androidx.compose.ui.graphics.SolidColor(Color(0xFFFBBC05))) {
71+ moveTo(5.84f, 14.09f)
72+ curveToRelative(-0.22f, -0.66f, -0.35f, -1.36f, -0.35f, -2.09f)
73+ reflectiveCurveToRelative(0.13f, -1.43f, 0.35f, -2.09f)
74+ verticalLineTo(7.07f)
75+ horizontalLineTo(2.18f)
76+ curveTo(1.43f, 8.55f, 1f, 10.22f, 1f, 12f)
77+ reflectiveCurveToRelative(0.43f, 3.45f, 1.18f, 4.93f)
78+ lineToRelative(2.85f, -2.22f)
79+ lineToRelative(0.81f, -0.62f)
80+ close()
81+ }
82+ path(fill = androidx.compose.ui.graphics.SolidColor(Color(0xFFEA4335))) {
83+ moveTo(12f, 5.38f)
84+ curveToRelative(1.62f, 0f, 3.06f, 0.56f, 4.21f, 1.64f)
85+ lineToRelative(3.15f, -3.15f)
86+ curveTo(17.45f, 2.09f, 14.97f, 1f, 12f, 1f)
87+ curveTo(7.7f, 1f, 3.99f, 3.47f, 2.18f, 7.07f)
88+ lineToRelative(3.66f, 2.84f)
89+ curveToRelative(0.87f, -2.6f, 3.3f, -4.53f, 6.16f, -4.53f)
90+ close()
91+ }
92+ }.build()
93+
3194@Composable
3295fun LoginScreen(
3396 uiState: AuthUiState,
3497 onSignIn: (email: String, password: String) -> Unit,
98+ onSignInWithGoogle: () -> Unit,
3599 onNavigateToRegister: () -> Unit,
36100 onClearError: () -> Unit,
37101 modifier: Modifier = Modifier
38102) {
39103 var email by rememberSaveable { mutableStateOf("") }
40104 var password by rememberSaveable { mutableStateOf("") }
105+ val isLoading = uiState is AuthUiState.Loading
41106
42107 Column(
43108 modifier = modifier
@@ -52,6 +117,34 @@ fun LoginScreen(
52117 color = MaterialTheme.colorScheme.primary
53118 )
54119 Spacer(modifier = Modifier.height(32.dp))
120+ OutlinedButton(
121+ onClick = onSignInWithGoogle,
122+ enabled = !isLoading,
123+ modifier = Modifier.fillMaxWidth()
124+ ) {
125+ Icon(
126+ imageVector = GoogleIcon,
127+ contentDescription = null,
128+ tint = Color.Unspecified,
129+ modifier = Modifier.size(18.dp)
130+ )
131+ Spacer(modifier = Modifier.size(8.dp))
132+ Text(text = "Continue with Google")
133+ }
134+ Spacer(modifier = Modifier.height(20.dp))
135+ Row(
136+ verticalAlignment = Alignment.CenterVertically,
137+ modifier = Modifier.fillMaxWidth()
138+ ) {
139+ HorizontalDivider(modifier = Modifier.weight(1f))
140+ Text(
141+ text = " or ",
142+ style = MaterialTheme.typography.bodySmall,
143+ color = MaterialTheme.colorScheme.outline
144+ )
145+ HorizontalDivider(modifier = Modifier.weight(1f))
146+ }
147+ Spacer(modifier = Modifier.height(20.dp))
55148 OutlinedTextField(
56149 value = email,
57150 onValueChange = {
@@ -85,7 +178,7 @@ fun LoginScreen(
85178 )
86179 }
87180 Spacer(modifier = Modifier.height(24.dp))
88- if (uiState is AuthUiState.Loading ) {
181+ if (isLoading ) {
89182 CircularProgressIndicator()
90183 } else {
91184 Button(
@@ -120,6 +213,7 @@ fun LoginScreenPreview() {
120213 LoginScreen(
121214 uiState = AuthUiState.Idle,
122215 onSignIn = { _, _ -> },
216+ onSignInWithGoogle = {},
123217 onNavigateToRegister = {},
124218 onClearError = {}
125219 )
@@ -133,6 +227,7 @@ fun LoginScreenErrorPreview() {
133227 LoginScreen(
134228 uiState = AuthUiState.Error("Invalid credentials"),
135229 onSignIn = { _, _ -> },
230+ onSignInWithGoogle = {},
136231 onNavigateToRegister = {},
137232 onClearError = {}
138233 )
0 commit comments