welcome claude jfc

This commit is contained in:
genki
2026-01-25 15:59:59 -05:00
parent 4aa3499bb3
commit 941337f671
3 changed files with 80 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import android.os.Build
import android.view.View import android.view.View
import android.view.autofill.AutofillManager import android.view.autofill.AutofillManager
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
@@ -28,11 +29,12 @@ import java.util.*
@Composable @Composable
fun BeautifulPersonInfoDialog( fun BeautifulPersonInfoDialog(
onDismiss: () -> Unit, 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 name by remember { mutableStateOf("") }
var dateOfBirth by remember { mutableStateOf<Long?>(null) } var dateOfBirth by remember { mutableStateOf<Long?>(null) }
var selectedRelationship by remember { mutableStateOf("Other") } var selectedRelationship by remember { mutableStateOf("Other") }
var isChild by remember { mutableStateOf(false) }
var showDatePicker by remember { mutableStateOf(false) } var showDatePicker by remember { mutableStateOf(false) }
// ✅ Disable autofill for this dialog // ✅ 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)) { 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( OutlinedTextField(
value = dateOfBirth?.let { SimpleDateFormat("MMM d, yyyy", Locale.getDefault()).format(Date(it)) } ?: "", value = dateOfBirth?.let { SimpleDateFormat("MMM d, yyyy", Locale.getDefault()).format(Date(it)) } ?: "",
onValueChange = {}, onValueChange = {},
@@ -169,8 +238,8 @@ fun BeautifulPersonInfoDialog(
} }
Button( Button(
onClick = { onConfirm(name.trim(), dateOfBirth, selectedRelationship) }, onClick = { onConfirm(name.trim(), dateOfBirth, selectedRelationship, isChild) },
enabled = name.trim().isNotEmpty(), enabled = name.trim().isNotEmpty() && (!isChild || dateOfBirth != null),
modifier = Modifier.weight(1f).height(56.dp), modifier = Modifier.weight(1f).height(56.dp),
shape = RoundedCornerShape(16.dp) shape = RoundedCornerShape(16.dp)
) { ) {

View File

@@ -41,7 +41,8 @@ sealed class TrainingState {
data class PersonInfo( data class PersonInfo(
val name: String, val name: String,
val dateOfBirth: Long?, 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 * Store person info before photo selection
*/ */
fun setPersonInfo(name: String, dateOfBirth: Long?, relationship: String) { fun setPersonInfo(name: String, dateOfBirth: Long?, relationship: String, isChild: Boolean = false) {
personInfo = PersonInfo(name, dateOfBirth, relationship) personInfo = PersonInfo(name, dateOfBirth, relationship, isChild)
} }
/** /**
@@ -151,6 +152,7 @@ class TrainViewModel @Inject constructor(
val person = PersonEntity.create( val person = PersonEntity.create(
name = personName, name = personName,
dateOfBirth = personInfo?.dateOfBirth, dateOfBirth = personInfo?.dateOfBirth,
isChild = personInfo?.isChild ?: false,
relationship = personInfo?.relationship relationship = personInfo?.relationship
) )

View File

@@ -61,9 +61,9 @@ fun TrainingScreen(
if (showInfoDialog) { if (showInfoDialog) {
BeautifulPersonInfoDialog( BeautifulPersonInfoDialog(
onDismiss = { showInfoDialog = false }, onDismiss = { showInfoDialog = false },
onConfirm = { name, dob, relationship -> onConfirm = { name, dob, relationship, isChild ->
showInfoDialog = false showInfoDialog = false
trainViewModel.setPersonInfo(name, dob, relationship) trainViewModel.setPersonInfo(name, dob, relationship, isChild)
onSelectImages() onSelectImages()
} }
) )