Открываю искуственный интелект:
kotlin jetpack code for food login page for mobile application
Kotlin
Файл MainActivity.kt
package com.evgproj.jetpack1
import android.graphics.drawable.Icon
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Lock
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
FoodLoginScreen()
}
}
}
@Preview(showBackground = true)
@Composable
fun ContentPreview() {
FoodLoginScreen()
}
// Theme Colors
val FoodPrimary = Color(0xFFFF5722) // Energetic Orange
val FoodBackground = Color(0xFFFAFAFA)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FoodLoginScreen(
onLoginClick: (String, String) -> Unit = { _, _ -> },
onSignUpClick: () -> Unit = {},
onForgotPasswordClick: () -> Unit = {}
) {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
var isPasswordVisible by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.fillMaxSize()
.background(FoodBackground)
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
// App Logo / Hero Visual
Surface(
modifier = Modifier
.size(100.dp)
.clip(CircleShape),
color = FoodPrimary.copy(alpha = 0.1f)
) {
Box(contentAlignment = Alignment.Center) {
Text(
text = "🍔",
fontSize = 48.sp
)
}
}
Spacer(modifier = Modifier.height(24.dp))
// Branding Header
Text(
text = "YumExpress",
fontSize = 32.sp,
fontWeight = FontWeight.Bold,
color = Color(0xFF212121)
)
Text(
text = "Delicious food delivered to your door",
fontSize = 14.sp,
color = Color.Gray,
modifier = Modifier.padding(top = 4.dp)
)
Spacer(modifier = Modifier.height(32.dp))
// Email Field
OutlinedTextField(
value = email,
onValueChange = { email = it },
label = { Text("Email Address") },
leadingIcon = {
Icon(Icons.Default.Email, contentDescription = "Email Icon", tint = FoodPrimary)
},
singleLine = true,
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Email,
imeAction = ImeAction.Next
),
shape = RoundedCornerShape(16.dp),
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = FoodPrimary,
focusedLabelColor = FoodPrimary
),
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
// Password Field
OutlinedTextField(
value = password,
onValueChange = { password = it },
label = { Text("Password") },
leadingIcon = {
Icon(Icons.Default.Lock, contentDescription = "Password Icon", tint = FoodPrimary)
},
trailingIcon = {
IconButton(onClick = { isPasswordVisible = !isPasswordVisible }) {
}
},
singleLine = true,
visualTransformation = if (isPasswordVisible) VisualTransformation.None else PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Password,
imeAction = ImeAction.Done
),
shape = RoundedCornerShape(16.dp),
colors = OutlinedTextFieldDefaults.colors(
focusedBorderColor = FoodPrimary,
focusedLabelColor = FoodPrimary
),
modifier = Modifier.fillMaxWidth()
)
// Forgot Password Action
TextButton(
onClick = onForgotPasswordClick,
modifier = Modifier.align(Alignment.End)
) {
Text(
text = "Forgot Password?",
color = FoodPrimary,
fontWeight = FontWeight.SemiBold
)
}
Spacer(modifier = Modifier.height(16.dp))
// Primary Login Button
Button(
onClick = { onLoginClick(email, password) },
modifier = Modifier
.fillMaxWidth()
.height(56.dp),
shape = RoundedCornerShape(16.dp),
colors = ButtonDefaults.buttonColors(containerColor = FoodPrimary)
) {
Text(
text = "Log In",
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
color = Color.White
)
}
Spacer(modifier = Modifier.height(24.dp))
// Sign Up Footer
Row(
verticalAlignment = Alignment.CenterVertically
) {
Text(text = "Don't have an account?", color = Color.Gray)
TextButton(onClick = onSignUpClick) {
Text(
text = "Sign Up",
color = FoodPrimary,
fontWeight = FontWeight.Bold
)
}
}
}
}
Создаем пустой проект Jetpack Compose на Kotlin в Android Studio ...
В проект доавляю
AI Google Gemini код.
Запускаю проект и вижу красивую Login страницу.