package com.example.loginpage
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.*
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.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.foundation.shape.RoundedCornerShape
@Composable
fun LoginScreen() {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Spacer(modifier = Modifier.height(40.dp))
Image(
painter = painterResource(id = R.drawable.login_image),
contentDescription = "Login Illustration",
modifier = Modifier
.height(200.dp)
.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
Text("Welcome Back", style = MaterialTheme.typography.bodyLarge)
Text("Login to your account", style = MaterialTheme.typography.bodyMedium)
Spacer(modifier = Modifier.height(24.dp))
OutlinedTextField(
value = email,
onValueChange = { email = it },
label = { Text("Email address") },
singleLine = true,
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(12.dp))
OutlinedTextField(
value = password,
onValueChange = { password = it },
label = { Text("Password") },
singleLine = true,
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
Button(
onClick = { /* handle login */ },
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
shape = RoundedCornerShape(24.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF7C4DFF))
) {
Text("Login", color = Color.White)
}
Spacer(modifier = Modifier.height(8.dp))
TextButton(onClick = { /* forgot password */ }) {
Text("Forgot Password?")
}
Spacer(modifier = Modifier.height(8.dp))
Text("Or sign in with", fontSize = 14.sp)
Spacer(modifier = Modifier.height(12.dp))
Row(
horizontalArrangement = Arrangement.SpaceEvenly,
modifier = Modifier.fillMaxWidth()
) {
IconButton(onClick = { /* Facebook login */ }) {
Image(
painter = painterResource(id = R.drawable.ic_facebook),
contentDescription = "Facebook",
modifier = Modifier.size(40.dp)
)
}
IconButton(onClick = { /* Google login */ }) {
Image(
painter = painterResource(id = R.drawable.ic_google),
contentDescription = "Google",
modifier = Modifier.size(40.dp)
)
}
IconButton(onClick = { /* Other login */ }) {
Image(
painter = painterResource(id = R.drawable.ic_github),
contentDescription = "Other",
modifier = Modifier.size(40.dp)
)
}
}
}
}
Komentar
Posting Komentar