welcome claude jfc
This commit is contained in:
@@ -4,6 +4,7 @@ import android.os.Build
|
||||
import android.view.View
|
||||
import android.view.autofill.AutofillManager
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
@@ -28,11 +29,12 @@ import java.util.*
|
||||
@Composable
|
||||
fun BeautifulPersonInfoDialog(
|
||||
onDismiss: () -> Unit,
|
||||
onConfirm: (name: String, dateOfBirth: Long?, relationship: String) -> Unit
|
||||
onConfirm: (name: String, dateOfBirth: Long?, relationship: String, isChild: Boolean) -> Unit
|
||||
) {
|
||||
var name by remember { mutableStateOf("") }
|
||||
var dateOfBirth by remember { mutableStateOf<Long?>(null) }
|
||||
var selectedRelationship by remember { mutableStateOf("Other") }
|
||||
var isChild by remember { mutableStateOf(false) }
|
||||
var showDatePicker by remember { mutableStateOf(false) }
|
||||
|
||||
// ✅ Disable autofill for this dialog
|
||||
@@ -108,8 +110,75 @@ fun BeautifulPersonInfoDialog(
|
||||
)
|
||||
}
|
||||
|
||||
// Child toggle
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { isChild = !isChild },
|
||||
color = if (isChild) MaterialTheme.colorScheme.primaryContainer
|
||||
else MaterialTheme.colorScheme.surfaceVariant,
|
||||
shape = RoundedCornerShape(16.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Face,
|
||||
contentDescription = null,
|
||||
tint = if (isChild) MaterialTheme.colorScheme.primary
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Column {
|
||||
Text(
|
||||
"This is a child",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
color = if (isChild) MaterialTheme.colorScheme.onPrimaryContainer
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Text(
|
||||
"Creates age tags (emma_age2, emma_age3...)",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = if (isChild) MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.7f)
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)
|
||||
)
|
||||
}
|
||||
}
|
||||
Switch(
|
||||
checked = isChild,
|
||||
onCheckedChange = { isChild = it }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Birthday (more prominent for children)
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text("Birthday", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.primary)
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Text(
|
||||
if (isChild) "Birthday *" else "Birthday",
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
if (isChild && dateOfBirth == null) {
|
||||
Text(
|
||||
"(required for age tags)",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
}
|
||||
}
|
||||
OutlinedTextField(
|
||||
value = dateOfBirth?.let { SimpleDateFormat("MMM d, yyyy", Locale.getDefault()).format(Date(it)) } ?: "",
|
||||
onValueChange = {},
|
||||
@@ -169,8 +238,8 @@ fun BeautifulPersonInfoDialog(
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { onConfirm(name.trim(), dateOfBirth, selectedRelationship) },
|
||||
enabled = name.trim().isNotEmpty(),
|
||||
onClick = { onConfirm(name.trim(), dateOfBirth, selectedRelationship, isChild) },
|
||||
enabled = name.trim().isNotEmpty() && (!isChild || dateOfBirth != null),
|
||||
modifier = Modifier.weight(1f).height(56.dp),
|
||||
shape = RoundedCornerShape(16.dp)
|
||||
) {
|
||||
|
||||
@@ -41,7 +41,8 @@ sealed class TrainingState {
|
||||
data class PersonInfo(
|
||||
val name: String,
|
||||
val dateOfBirth: Long?,
|
||||
val relationship: String
|
||||
val relationship: String,
|
||||
val isChild: Boolean = false
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -80,8 +81,8 @@ class TrainViewModel @Inject constructor(
|
||||
/**
|
||||
* Store person info before photo selection
|
||||
*/
|
||||
fun setPersonInfo(name: String, dateOfBirth: Long?, relationship: String) {
|
||||
personInfo = PersonInfo(name, dateOfBirth, relationship)
|
||||
fun setPersonInfo(name: String, dateOfBirth: Long?, relationship: String, isChild: Boolean = false) {
|
||||
personInfo = PersonInfo(name, dateOfBirth, relationship, isChild)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,6 +152,7 @@ class TrainViewModel @Inject constructor(
|
||||
val person = PersonEntity.create(
|
||||
name = personName,
|
||||
dateOfBirth = personInfo?.dateOfBirth,
|
||||
isChild = personInfo?.isChild ?: false,
|
||||
relationship = personInfo?.relationship
|
||||
)
|
||||
|
||||
|
||||
@@ -61,9 +61,9 @@ fun TrainingScreen(
|
||||
if (showInfoDialog) {
|
||||
BeautifulPersonInfoDialog(
|
||||
onDismiss = { showInfoDialog = false },
|
||||
onConfirm = { name, dob, relationship ->
|
||||
onConfirm = { name, dob, relationship, isChild ->
|
||||
showInfoDialog = false
|
||||
trainViewModel.setPersonInfo(name, dob, relationship)
|
||||
trainViewModel.setPersonInfo(name, dob, relationship, isChild)
|
||||
onSelectImages()
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user