Updated Kotlin models, Android UI, and iOS UI to make all address fields optional for residences. Only the residence name is now required. Changes: - Kotlin: Made propertyType, streetAddress, city, stateProvince, postalCode, country nullable in Residence, ResidenceSummary, ResidenceWithTasks models - Kotlin: Updated navigation routes to handle nullable address fields - Android: Updated ResidenceFormScreen and ResidenceDetailScreen to handle nulls - iOS: Updated ResidenceFormView validation to only check name field - iOS: Updated PropertyHeaderCard and ResidenceCard to use optional binding for address field displays 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
97 lines
3.1 KiB
Swift
97 lines
3.1 KiB
Swift
import SwiftUI
|
|
import ComposeApp
|
|
|
|
struct PropertyHeaderCard: View {
|
|
let residence: Residence
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
HStack {
|
|
Image(systemName: "house.fill")
|
|
.font(.title2)
|
|
.foregroundColor(.blue)
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text(residence.name)
|
|
.font(.title2)
|
|
.fontWeight(.bold)
|
|
|
|
if let propertyType = residence.propertyType {
|
|
Text(propertyType)
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
|
|
Divider()
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
if let streetAddress = residence.streetAddress {
|
|
Label(streetAddress, systemImage: "mappin.circle.fill")
|
|
.font(.subheadline)
|
|
}
|
|
|
|
if residence.city != nil || residence.stateProvince != nil || residence.postalCode != nil {
|
|
Text("\(residence.city ?? ""), \(residence.stateProvince ?? "") \(residence.postalCode ?? "")")
|
|
.font(.subheadline)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
|
|
if let country = residence.country, !country.isEmpty {
|
|
Text(country)
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
}
|
|
}
|
|
|
|
if let bedrooms = residence.bedrooms,
|
|
let bathrooms = residence.bathrooms {
|
|
Divider()
|
|
|
|
HStack(spacing: 24) {
|
|
PropertyDetailItem(icon: "bed.double.fill", value: "\(bedrooms)", label: "Beds")
|
|
PropertyDetailItem(icon: "shower.fill", value: String(format: "%.1f", bathrooms), label: "Baths")
|
|
|
|
if let sqft = residence.squareFootage {
|
|
PropertyDetailItem(icon: "square.fill", value: "\(sqft)", label: "Sq Ft")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.padding(20)
|
|
.background(Color.blue.opacity(0.1))
|
|
.cornerRadius(16)
|
|
}
|
|
}
|
|
|
|
//#Preview {
|
|
// PropertyHeaderCard(residence: Residence(
|
|
// id: 1,
|
|
// owner: "My Beautiful Home",
|
|
// ownerUsername: "House",
|
|
// name: "123 Main Street",
|
|
// propertyType: nil,
|
|
// streetAddress: "San Francisco",
|
|
// apartmentUnit: "CA",
|
|
// city: "94102",
|
|
// stateProvince: "USA",
|
|
// postalCode: 3,
|
|
// country: 2.5,
|
|
// bedrooms: 1800,
|
|
// bathrooms: 0.25,
|
|
// squareFootage: 2010,
|
|
// lotSize: nil,
|
|
// yearBuilt: nil,
|
|
// description: nil,
|
|
// purchaseDate: true,
|
|
// purchasePrice: "testuser",
|
|
// isPrimary: 1,
|
|
// createdAt: "2024-01-01T00:00:00Z",
|
|
// updatedAt: "2024-01-01T00:00:00Z"
|
|
// ))
|
|
// .padding()
|
|
//}
|