Exhaustive file-by-file audit of every Swift file in the project (iOS app, Watch app, Widget extension). Every interactive UI element — buttons, toggles, pickers, links, menus, tap gestures, text editors, color pickers, photo pickers — now has an accessibilityIdentifier for XCUITest automation. 46 files changed across Shared/, Onboarding/, Watch App/, and Widget targets. Added ~100 new ID definitions covering settings debug controls, export/photo views, sharing templates, customization subviews, onboarding flows, tip modals, widget voting buttons, and watch mood buttons.
57 lines
1.8 KiB
Swift
57 lines
1.8 KiB
Swift
//
|
|
// ImagePickerGrid.swift
|
|
// Reflect (iOS)
|
|
//
|
|
// Created by Trey Tartt on 3/12/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ImagePickerGridView: View {
|
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
|
@Environment(\.presentationMode) var presentationMode
|
|
@State var column = Array(repeating: GridItem(.flexible(), spacing: 10), count: 7)
|
|
let pickedImageClosure: ((CustomWidgeImageOptions) -> Void)
|
|
|
|
private var textColor: Color { theme.currentTheme.labelColor }
|
|
|
|
let imageOptions = CustomWidgeImageOptions.allCases.sorted(by: {
|
|
$0.rawValue < $1.rawValue
|
|
})
|
|
|
|
var body: some View {
|
|
VStack {
|
|
ScrollView {
|
|
LazyVGrid(columns: column,spacing: 10, content: {
|
|
ForEach(imageOptions, id:\.self.rawValue) { item in
|
|
Image(item.rawValue)
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(width: 40, height: 40)
|
|
.foregroundColor(textColor)
|
|
.accessibilityIdentifier(AccessibilityID.CustomWidget.imageOption(item.rawValue))
|
|
.onTapGesture {
|
|
pickedImageClosure(item)
|
|
presentationMode.wrappedValue.dismiss()
|
|
}
|
|
}
|
|
})
|
|
}
|
|
.padding()
|
|
Spacer()
|
|
}
|
|
.background(
|
|
theme.currentTheme.bg
|
|
.edgesIgnoringSafeArea(.all)
|
|
)
|
|
}
|
|
}
|
|
|
|
struct ImagePickerGridView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
ImagePickerGridView(pickedImageClosure: { image in
|
|
|
|
})
|
|
}
|
|
}
|