Files
Reflect/Shared/Views/CustomizeView/SubViews/ImagePackPickerView.swift
Trey t be84825aba Fix widget layout clipping and add comprehensive widget previews
- Fix LargeVotingView mood icons getting clipped at edges by using
  flexible HStack spacing with maxWidth: .infinity
- Fix VotingView medium layout with smaller icons and even distribution
- Add comprehensive #Preview macros for all widget states:
  - Vote widget: small/medium, voted/not voted, all mood states
  - Timeline widget: small/medium/large with various data states
- Reduce icon sizes and padding to fit within widget bounds
- Update accessibility labels and hints across views

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 09:53:40 -06:00

69 lines
3.1 KiB
Swift

//
// ImagePackPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct ImagePackPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
@AppStorage(UserDefaultsStore.Keys.moodImages.rawValue, store: GroupUserDefaults.groupDefaults) private var imagePack: MoodImages = .FontAwesome
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
var body: some View {
ZStack {
Text(String(customMoodTintUpdateNumber))
.hidden()
theme.currentTheme.secondaryBGColor
VStack {
ForEach(MoodImages.allCases, id: \.rawValue) { images in
ZStack {
VStack {
HStack {
ForEach(Mood.allValues, id: \.self) { mood in
images.icon(forMood: mood)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 35, height: 35)
.foregroundColor(
moodTint.color(forMood: mood)
)
.accessibilityLabel(mood.strValue)
}
.frame(minWidth: 0, maxWidth: .infinity)
}
.contentShape(Rectangle())
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(imagePack == images ? theme.currentTheme.bgColor : .clear)
.padding([.top, .bottom], -3)
)
.onTapGesture {
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
impactMed.impactOccurred()
imagePack = images
EventLogger.log(event: "change_image_pack_id", withData: ["id": images.rawValue])
}
if images.rawValue != (MoodImages.allCases.sorted(by: { $0.rawValue > $1.rawValue }).first?.rawValue) ?? 0 {
Divider()
}
}
}
}
}
.padding()
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct ImagePackPickerView_Previews: PreviewProvider {
static var previews: some View {
ImagePackPickerView()
}
}