// CustomerDetailsApp
package com.example.customerdetailsapp
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
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.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.customerdetailsapp.ui.theme.CustomerDetailsAppTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
CustomerDetailsAppTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Details(
modifier = Modifier.padding(innerPadding)
)
}
}
}
}
}
@Composable
fun Details(modifier: Modifier = Modifier) {
var name by remember { mutableStateOf("") }
var gender by remember { mutableStateOf("") }
var occupation by remember { mutableStateOf("") }
var contact by remember { mutableStateOf("") }
var email by remember { mutableStateOf("") }
var nationality by remember { mutableStateOf("") }
Column(
verticalArrangement = Arrangement.SpaceAround,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.background(Color.White)
.padding(10.dp)
) {
Text(
text = "CUSTOMER DETAILS",
fontSize = 30.sp,
color = Color.Red,
fontWeight = FontWeight.Bold,
textDecoration = TextDecoration.Underline
)
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
Text(
text = "NAME:",
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
color = Color.Black
)
TextField(
value = "name",
onValueChange = {name = it},
label = {
Text(
text = "Enter Name",
fontSize = 20.sp
)
},
modifier = Modifier
.width(200.dp)
)
}
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
Text(
text = "GENDER:",
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
color = Color.Black
)
TextField(
value = "gender",
onValueChange = {gender = it},
label = {
Text(
text = "Enter Gender",
fontSize = 20.sp
)
},
modifier = Modifier
.width(200.dp)
)
}
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
Text(
text = "OCCUPATION:",
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
color = Color.Black
)
TextField(
value = "occupation",
onValueChange = {occupation = it},
label = {
Text(
text = "Enter Occupation",
fontSize = 20.sp
)
},
modifier = Modifier
.width(200.dp)
)
}
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
Text(
text = "CONTACT:",
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
color = Color.Black
)
TextField(
value = "contact",
onValueChange = {contact = it},
label = {
Text(
text = "Enter Contact",
fontSize = 20.sp
)
},
modifier = Modifier
.width(200.dp)
)
}
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
Text(
text = "EMAIL:",
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
color = Color.Black
)
TextField(
value = "email",
onValueChange = {email = it},
label = {
Text(
text = "Enter Email",
fontSize = 20.sp
)
},
modifier = Modifier
.width(200.dp)
)
}
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
Text(
text = "NATIONALITY:",
fontWeight = FontWeight.Bold,
fontSize = 30.sp,
color = Color.Black
)
TextField(
value = "nationality",
onValueChange = {nationality = it},
label = {
Text(
text = "Enter Nationality",
fontSize = 20.sp
)
},
modifier = Modifier
.width(200.dp)
)
}
Row(
horizontalArrangement = Arrangement.SpaceAround,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
){
Button(onClick = {}) {
Text(
text = "SAVE",
fontSize = 20.sp
)
}
Button(onClick = {}) {
Text(
text = "CANCEL",
fontSize = 20.sp,
)
}
}
}
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
CustomerDetailsAppTheme {
Details(modifier = Modifier)
}
}