Make contractor phone optional and add UI test accessibility identifiers

Updated contractor models and forms to make phone field optional. Added
accessibility identifiers for add buttons to enable UI testing.

Contractor changes:
- Kotlin: Made phone nullable in Contractor, ContractorCreateRequest,
  ContractorSummary models
- Android: Updated AddContractorDialog validation to only require name
- Android: Removed asterisk from phone field label
- Android: Updated ContractorDetailScreen to handle nullable phone
- iOS: Updated ContractorFormSheet validation to only check name field
- iOS: Updated form footer text to show only name as required
- iOS: Updated ContractorDetailView to use optional binding for phone display

Accessibility improvements:
- iOS: Added accessibility identifier to contractor add button in
  ContractorsListView
- iOS: Added accessibility identifier to task add button in
  ResidenceDetailView

These identifiers enable reliable UI testing by allowing tests to access
buttons by their accessibility identifiers instead of searching by label.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-11-20 23:04:06 -06:00
parent dd5e050025
commit 1100bc423d
7 changed files with 33 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ data class Contractor(
val id: Int,
val name: String,
val company: String? = null,
val phone: String,
val phone: String? = null,
val email: String? = null,
@SerialName("secondary_phone") val secondaryPhone: String? = null,
val specialty: String? = null,
@@ -33,7 +33,7 @@ data class Contractor(
data class ContractorCreateRequest(
val name: String,
val company: String? = null,
val phone: String,
val phone: String? = null,
val email: String? = null,
@SerialName("secondary_phone") val secondaryPhone: String? = null,
val specialty: String? = null,
@@ -72,7 +72,7 @@ data class ContractorSummary(
val id: Int,
val name: String,
val company: String? = null,
val phone: String,
val phone: String? = null,
val specialty: String? = null,
@SerialName("average_rating") val averageRating: Double? = null,
@SerialName("is_favorite") val isFavorite: Boolean = false,

View File

@@ -62,7 +62,7 @@ fun AddContractorDialog(
val contractor = (contractorDetailState as ApiResult.Success).data
name = contractor.name
company = contractor.company ?: ""
phone = contractor.phone
phone = contractor.phone ?: ""
email = contractor.email ?: ""
secondaryPhone = contractor.secondaryPhone ?: ""
specialty = contractor.specialty ?: ""
@@ -157,7 +157,7 @@ fun AddContractorDialog(
OutlinedTextField(
value = phone,
onValueChange = { phone = it },
label = { Text("Phone *") },
label = { Text("Phone") },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
shape = RoundedCornerShape(12.dp),
@@ -402,13 +402,13 @@ fun AddContractorDialog(
confirmButton = {
Button(
onClick = {
if (name.isNotBlank() && phone.isNotBlank()) {
if (name.isNotBlank()) {
if (contractorId == null) {
viewModel.createContractor(
ContractorCreateRequest(
name = name,
company = company.takeIf { it.isNotBlank() },
phone = phone,
phone = phone.takeIf { it.isNotBlank() },
email = email.takeIf { it.isNotBlank() },
secondaryPhone = secondaryPhone.takeIf { it.isNotBlank() },
specialty = specialty.takeIf { it.isNotBlank() },
@@ -445,7 +445,7 @@ fun AddContractorDialog(
}
}
},
enabled = name.isNotBlank() && phone.isNotBlank() &&
enabled = name.isNotBlank() &&
createState !is ApiResult.Loading && updateState !is ApiResult.Loading,
colors = ButtonDefaults.buttonColors(
containerColor = Color(0xFF2563EB)

View File

@@ -231,12 +231,14 @@ fun ContractorDetailScreen(
// Contact Information
item {
DetailSection(title = "Contact Information") {
DetailRow(
icon = Icons.Default.Phone,
label = "Phone",
value = contractor.phone,
iconTint = Color(0xFF3B82F6)
)
if (contractor.phone != null) {
DetailRow(
icon = Icons.Default.Phone,
label = "Phone",
value = contractor.phone,
iconTint = Color(0xFF3B82F6)
)
}
if (contractor.email != null) {
DetailRow(