Skip to content

Instantly share code, notes, and snippets.

@hassanabidpk
Created June 30, 2024 15:29
Show Gist options
  • Save hassanabidpk/80041460aa20884e6db18411f601a95a to your computer and use it in GitHub Desktop.
Save hassanabidpk/80041460aa20884e6db18411f601a95a to your computer and use it in GitHub Desktop.
LoginScreen created using Google AI Studio
package dev.hassanabid.ioextendedsg.studioui
import android.annotation.SuppressLint
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
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.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import dev.hassanabid.ioextendedsg.R
@SuppressLint("UnusedMaterial3Api")
@OptIn(ExperimentalMaterial3Api::class)
@Preview(showBackground = true)
@Composable
fun LoginScreen() {
val username = remember { mutableStateOf("") }
val password = remember { mutableStateOf("") }
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = R.drawable.belive_logo),
contentDescription = "App Logo",
modifier = Modifier.size(100.dp)
)
Spacer(modifier = Modifier.height(32.dp))
OutlinedTextField(
value = username.value,
onValueChange = { username.value = it },
label = { Text("Username") },
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = Color.LightGray, // Use focusedBorderColor
unfocusedBorderColor = Color.LightGray // Use unfocusedBorderColor
)
)
Spacer(modifier = Modifier.height(8.dp)) // Space between text fields
OutlinedTextField(
value = password.value,
onValueChange = { password.value = it },
label = { Text("Password") },
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
colors = TextFieldDefaults.outlinedTextFieldColors(
focusedBorderColor = Color.LightGray,
unfocusedBorderColor = Color.LightGray
)
)
Spacer(modifier = Modifier.height(16.dp))
Button(
onClick = { /*TODO*/ },
modifier = Modifier
.fillMaxWidth()
.height(56.dp),
shape = RoundedCornerShape(8.dp),
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFFD14279))
) {
Text(
text = "Login",
fontSize = 18.sp,
color = Color.White
)
}
}
}
@hassanabidpk
Copy link
Author

demo_1

Prompt : Act as an Android app developer. For the image provided, use Jetpack Compose to build the screen so that the Compose Preview is as close to this image as possible. Also make sure to include imports and use Material3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment