Files
Reflect/Shared/Views/CustomizeView/SubViews/IconPickerView.swift
Trey T 1f040ab676 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>
2026-03-26 20:09:14 -05:00

106 lines
4.7 KiB
Swift

//
// IconPickerView.swift
// Reflect (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct IconPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let iconSets: [(String,String)] = [
("AppIconGoodImage", "AppIconGood"),
("AppIconAverageImage", "AppIconAverage"),
("AppIconBadImage", "AppIconBad"),
("AppIconBlueGreenImage", "AppIconBlueGreen"),
("AppIconNeonGreenImage", "AppIconNeonGreen"),
("AppIconPinkImage", "AppIconPink"),
("AppIconPurpleImage", "AppIconPurple"),
("AppIconCustom1Image", "AppIconCustom1"),
("AppIconCustom2Image", "AppIconCustom2"),
("AppIconCustom3Image", "AppIconCustom3"),
("AppIconCustom4Image", "AppIconCustom4"),
("AppIconCustom5Image", "AppIconCustom5"),
("AppIconCustom6Image", "AppIconCustom6"),
("AppIconCustom7Image", "AppIconCustom7"),
("AppIconCustom8Image", "AppIconCustom8"),
("AppIconCustom9Image", "AppIconCustom9"),
("AppIconCustom10Image", "AppIconCustom10"),
("AppIconCustom11Image", "AppIconCustom11"),
("AppIconCustom12Image", "AppIconCustom12"),
("AppIconCustom13Image", "AppIconCustom13"),
("AppIconCustom14Image", "AppIconCustom14"),
("AppIconCustom15Image", "AppIconCustom15"),
("AppIconCustom16Image", "AppIconCustom16"),
("AppIconCustom17Image", "AppIconCustom17"),
("AppIconCustom18Image", "AppIconCustom18"),
("AppIconCustom19Image", "AppIconCustom19"),
("AppIconCustom20Image", "AppIconCustom20"),
("AppIconCustom21Image", "AppIconCustom21"),
("AppIconCustom22Image", "AppIconCustom22"),
("AppIconCustom23Image", "AppIconCustom23"),
("AppIconCustom24Image", "AppIconCustom24"),
("AppIconCustom25Image", "AppIconCustom25"),
("AppIconCustom26Image", "AppIconCustom26"),
("AppIconCustom27Image", "AppIconCustom27"),
("AppIconCustom28Image", "AppIconCustom28"),
("AppIconCustom29Image", "AppIconCustom29")
]
var body: some View {
VStack {
ScrollView(.horizontal) {
HStack {
Button(action: {
UIApplication.shared.setAlternateIconName(nil)
AnalyticsManager.shared.track(.appIconChanged(iconTitle: "default"))
}, label: {
Image("AppIconImage", bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
.accessibilityLabel(String(localized: "Default app icon"))
.accessibilityHint(String(localized: "Double tap to select"))
.accessibilityIdentifier(AccessibilityID.Customize.iconButton("default"))
ForEach(iconSets, id: \.self.0){ iconSet in
Button(action: {
UIApplication.shared.setAlternateIconName(iconSet.1) { error in
if let error {
AppLogger.settings.error("Failed to set app icon '\(iconSet.1)': \(error.localizedDescription)")
}
}
AnalyticsManager.shared.track(.appIconChanged(iconTitle: iconSet.1))
}, label: {
Image(iconSet.0, bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
.accessibilityLabel(String(localized: "App icon style \(iconSet.1.replacingOccurrences(of: "AppIcon", with: "").replacingOccurrences(of: "Image", with: ""))"))
.accessibilityHint(String(localized: "Double tap to select"))
.accessibilityIdentifier(AccessibilityID.Customize.iconButton(iconSet.1))
}
}
.padding()
}
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
.padding()
.cornerRadius(10)
}
.background(theme.currentTheme.secondaryBGColor)
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct IconPickerView_Previews: PreviewProvider {
static var previews: some View {
IconPickerView()
}
}