v1.1 polish: accessibility, error logging, localization, and code quality sweep
- Wrap 30+ production print() statements in #if DEBUG guards across 18 files - Add VoiceOver labels, hints, and traits to Watch app, Live Activities, widgets - Add .accessibilityAddTraits(.isButton) to 15+ onTapGesture views - Add text alternatives for color-only indicators (progress dots, mood circles) - Localize raw string literals in NoteEditorView, EntryDetailView, widgets - Replace 25+ silent try? with do/catch + AppLogger error logging - Replace hardcoded font sizes with semantic Dynamic Type fonts - Fix FIXME in IconPickerView (log icon change errors) - Extract magic animation delays to named constants across 8 files - Add widget empty state "Log your first mood!" messaging - Hide decorative images from VoiceOver, add labels to ColorPickers - Remove stale TODO in Color+Codable (alpha change deferred for migration) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,11 @@ class PhotoManager: ObservableObject {
|
||||
let thumbnailURL = thumbnailsDir.appendingPathComponent(filename)
|
||||
if let thumbnail = createThumbnail(from: image),
|
||||
let thumbnailData = thumbnail.jpegData(compressionQuality: 0.6) {
|
||||
try? thumbnailData.write(to: thumbnailURL)
|
||||
do {
|
||||
try thumbnailData.write(to: thumbnailURL)
|
||||
} catch {
|
||||
AppLogger.photos.error("Failed to save thumbnail: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
AnalyticsManager.shared.track(.photoAdded)
|
||||
@@ -107,13 +111,21 @@ class PhotoManager: ObservableObject {
|
||||
let filename = "\(id.uuidString).jpg"
|
||||
let fullURL = photosDir.appendingPathComponent(filename)
|
||||
|
||||
guard FileManager.default.fileExists(atPath: fullURL.path),
|
||||
let data = try? Data(contentsOf: fullURL),
|
||||
let image = UIImage(data: data) else {
|
||||
guard FileManager.default.fileExists(atPath: fullURL.path) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return image
|
||||
do {
|
||||
let data = try Data(contentsOf: fullURL)
|
||||
guard let image = UIImage(data: data) else {
|
||||
AppLogger.photos.error("Failed to create UIImage from photo data: \(id)")
|
||||
return nil
|
||||
}
|
||||
return image
|
||||
} catch {
|
||||
AppLogger.photos.error("Failed to read photo data for \(id): \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func loadThumbnail(id: UUID) -> UIImage? {
|
||||
@@ -123,10 +135,15 @@ class PhotoManager: ObservableObject {
|
||||
let thumbnailURL = thumbnailsDir.appendingPathComponent(filename)
|
||||
|
||||
// Try thumbnail first
|
||||
if FileManager.default.fileExists(atPath: thumbnailURL.path),
|
||||
let data = try? Data(contentsOf: thumbnailURL),
|
||||
let image = UIImage(data: data) {
|
||||
return image
|
||||
if FileManager.default.fileExists(atPath: thumbnailURL.path) {
|
||||
do {
|
||||
let data = try Data(contentsOf: thumbnailURL)
|
||||
if let image = UIImage(data: data) {
|
||||
return image
|
||||
}
|
||||
} catch {
|
||||
AppLogger.photos.error("Failed to read thumbnail data for \(id): \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to full image if thumbnail doesn't exist
|
||||
@@ -159,7 +176,11 @@ class PhotoManager: ObservableObject {
|
||||
|
||||
// Delete thumbnail
|
||||
if FileManager.default.fileExists(atPath: thumbnailURL.path) {
|
||||
try? FileManager.default.removeItem(at: thumbnailURL)
|
||||
do {
|
||||
try FileManager.default.removeItem(at: thumbnailURL)
|
||||
} catch {
|
||||
AppLogger.photos.error("Failed to delete thumbnail: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
if success {
|
||||
@@ -197,8 +218,13 @@ class PhotoManager: ObservableObject {
|
||||
var totalPhotoCount: Int {
|
||||
guard let photosDir = photosDirectory else { return 0 }
|
||||
|
||||
let files = try? FileManager.default.contentsOfDirectory(atPath: photosDir.path)
|
||||
return files?.filter { $0.hasSuffix(".jpg") }.count ?? 0
|
||||
do {
|
||||
let files = try FileManager.default.contentsOfDirectory(atPath: photosDir.path)
|
||||
return files.filter { $0.hasSuffix(".jpg") }.count
|
||||
} catch {
|
||||
AppLogger.photos.error("Failed to list photos directory: \(error)")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
var totalStorageUsed: Int64 {
|
||||
|
||||
Reference in New Issue
Block a user