Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 4e31397

Browse files
authored
Move UIComponents to UIComponents.swift
1 parent f27ec85 commit 4e31397

File tree

3 files changed

+57
-12
lines changed

3 files changed

+57
-12
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import SwiftUI
2+
import UniformTypeIdentifiers
3+
4+
// MARK: - DocumentPicker
5+
6+
struct DocumentPicker: UIViewControllerRepresentable {
7+
var kind: PickerKind
8+
var onPick: (URL) -> Void
9+
10+
func makeCoordinator() -> Coordinator { Coordinator(self) }
11+
12+
func makeUIViewController(context: Context) -> UIDocumentPickerViewController {
13+
let types: [UTType] = [.item]
14+
let vc = UIDocumentPickerViewController(forOpeningContentTypes: types, asCopy: true)
15+
vc.delegate = context.coordinator
16+
vc.allowsMultipleSelection = false
17+
return vc
18+
}
19+
20+
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {}
21+
22+
class Coordinator: NSObject, UIDocumentPickerDelegate {
23+
let parent: DocumentPicker
24+
init(_ p: DocumentPicker) { parent = p }
25+
26+
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
27+
guard let u = urls.first else { return }
28+
parent.onPick(u)
29+
}
30+
}
31+
}
32+
33+
// MARK: - ActivityView
34+
35+
struct ActivityView: UIViewControllerRepresentable {
36+
let url: URL
37+
38+
func makeUIViewController(context: Context) -> UIActivityViewController {
39+
UIActivityViewController(activityItems: [url], applicationActivities: nil)
40+
}
41+
42+
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
43+
}
44+
45+
// MARK: - PickerKind Enum
46+
47+
enum PickerKind: Identifiable {
48+
case ipa, p12, prov
49+
var id: Int {
50+
switch self {
51+
case .ipa: return 0
52+
case .p12: return 1
53+
case .prov: return 2
54+
}
55+
}
56+
}

Sources/prostore/views/CertificateView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct CertificateView: View {
1010
@State private var p12Password = ""
1111
@State private var isProcessing = false
1212
@State private var statusMessage = "" // will hold exactly one of: "Incorrect Password", "P12 and MOBILEPROVISION do not match", "Success!"
13-
@State private var showPickerFor: SignerView.PickerKind? = nil // reuse PickerKind from SignerView
13+
@State private var showPickerFor: PickerKind? = nil
1414

1515
var body: some View {
1616
Form {

Sources/prostore/views/SignerView.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ struct SignerView: View {
1212
@State private var activityURL: URL? = nil
1313
@State private var showPickerFor: PickerKind?
1414

15-
enum PickerKind: Identifiable {
16-
case ipa, p12, prov
17-
var id: Int {
18-
switch self {
19-
case .ipa: return 0
20-
case .p12: return 1
21-
case .prov: return 2
22-
}
23-
}
24-
}
25-
2615
var body: some View {
2716
Form {
2817
Section(header: Text("Inputs")) {

0 commit comments

Comments
 (0)