Harden iOS app with audit fixes, UI consistency, and sheet race condition fixes

Applies verified fixes from deep audit (concurrency, performance, security,
accessibility), standardizes CRUD form buttons to Add/Save pattern, removes
.drawingGroup() that broke search bar TextFields, and converts vulnerable
.sheet(isPresented:) + if-let patterns to safe presentation to prevent
blank white modals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-03-06 09:59:56 -06:00
parent 61ab95d108
commit 9c574c4343
76 changed files with 824 additions and 971 deletions

View File

@@ -198,16 +198,15 @@ class PreviewViewController: UIViewController, QLPreviewingController {
func preparePreviewOfFile(at url: URL) async throws {
print("CaseraQLPreview: preparePreviewOfFile called with URL: \(url)")
// Parse the .casera file
// Parse the .casera file single Codable pass to detect type, then decode
let data = try Data(contentsOf: url)
let decoder = JSONDecoder()
// Detect package type first
if let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let typeString = json["type"] as? String,
typeString == "residence" {
let envelope = try? decoder.decode(PackageTypeEnvelope.self, from: data)
if envelope?.type == "residence" {
currentPackageType = .residence
let decoder = JSONDecoder()
let residence = try decoder.decode(ResidencePreviewData.self, from: data)
self.residenceData = residence
print("CaseraQLPreview: Parsed residence: \(residence.residenceName)")
@@ -218,7 +217,6 @@ class PreviewViewController: UIViewController, QLPreviewingController {
} else {
currentPackageType = .contractor
let decoder = JSONDecoder()
let contractor = try decoder.decode(ContractorPreviewData.self, from: data)
self.contractorData = contractor
print("CaseraQLPreview: Parsed contractor: \(contractor.name)")
@@ -287,6 +285,13 @@ class PreviewViewController: UIViewController, QLPreviewingController {
}
}
// MARK: - Type Discriminator
/// Lightweight struct to detect the package type without a full parse
private struct PackageTypeEnvelope: Decodable {
let type: String?
}
// MARK: - Data Model
struct ContractorPreviewData: Codable {