Skip to content

Instantly share code, notes, and snippets.

@ramonrabello
Last active November 28, 2023 14:19
Show Gist options
  • Save ramonrabello/dba8f5928e4a59443de5ac4f5b7abb21 to your computer and use it in GitHub Desktop.
Save ramonrabello/dba8f5928e4a59443de5ac4f5b7abb21 to your computer and use it in GitHub Desktop.
LoginScreen.kt - Accelerating the mobile legacy modernization: Migrate to Compose 10x faster using StackSpot AI
@Composable
fun LoginScreen() {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
var rememberMe by remember { mutableStateOf(true) }
Column(
) {
Image(
painter = painterResource(id = R.mipmap.ic_launcher),
contentDescription = null // Provide a proper content description for accessibility
)
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email)
)
Spacer(modifier = Modifier.height(8.dp))
OutlinedTextField(
visualTransformation = PasswordVisualTransformation()
)
Spacer(modifier = Modifier.height(16.dp))
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(
checked = rememberMe,
onCheckedChange = { rememberMe = it }
)
Text(
text = "Remember Me",
modifier = Modifier.padding(start = 8.dp)
)
Spacer(modifier = Modifier.weight(1f))
Text(
text = "Forgot Password?",
modifier = Modifier.clickable { /* Handle forgot password */ }
)
}
Spacer(modifier = Modifier.height(10.dp))
Button(
onClick = { /* Handle login */ },
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 10.dp)
) {
Text("Log In")
}
Button(
onClick = { /* Handle sign up */ },
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 10.dp)
) {
Text("Sign Up")
}
}
}
@Preview(showBackground = true)
@Composable
fun LoginScreenPreview() {
// Here you can define a theme, if you're using one, or simply call LoginScreen directly.
// If you're using a theme, switch 'Theme' to the name of your Theme.
// Theme {
// LoginScreen()
// }
LoginScreen()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment