import SwiftUI
struct CertificateManagerView: View {
@State private var certificates = ["Dev Cert 1", "Dev Cert 2"]
@State private var profiles = ["Profile A", "Profile B"]
@State private var showingAlert = false
@State private var selectedItem = ""
@State private var selectedType = ""
var body: some View {
NavigationView {
List {
Section(header: Text("Certificates")) {
ForEach(certificates, id: \.self) { cert in
Button(action: {
selectedItem = cert
selectedType = "Certificate"
showingAlert = true
}) {
Text(cert)
}
.accessibilityLabel("\(cert), Certificate")
}
}
Section(header: Text("Provisioning Profiles")) {
ForEach(profiles, id: \.self) { profile in
Button(action: {
selectedItem = profile
selectedType = "Provisioning Profile"
showingAlert = true
}) {
Text(profile)
}
.accessibilityLabel("\(profile), Provisioning Profile")
}
}
}
.navigationTitle("Certificate Manager")
.toolbar {
Button(action: refreshLists) {
Text("Refresh")
}
.accessibilityLabel("Refresh certificates and profiles")
}
.alert(isPresented: $showingAlert) {
Alert(title: Text(selectedType), message: Text(selectedItem), dismissButton: .default(Text("OK")))
}
}
}
func refreshLists() {
// Simulate refreshing by shuffling the lists
certificates.shuffle()
profiles.shuffle()
}
}
struct CertificateManagerView_Previews: PreviewProvider {
static var previews: some View {
CertificateManagerView()
}
}This SwiftUI view shows two sections in a list: Certificates and Provisioning Profiles. Each section uses a ForEach to list items as buttons. When a user taps an item, an alert pops up showing the item's name and type.
The Refresh button in the toolbar calls refreshLists(), which shuffles the arrays to simulate reloading data.
Accessibility labels are added to buttons for screen readers, describing the item and its type. The UI uses a NavigationView with a title for clarity.