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

Commit ddd338f

Browse files
authored
Improve setup and allow showing via About.
1 parent 8c78edd commit ddd338f

3 files changed

Lines changed: 41 additions & 23 deletions

File tree

Sources/prostore/views/AboutView.swift

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct AboutView: View {
4545
Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.0"
4646
}
4747

48+
@State private var showingSetup = false
49+
4850
var body: some View {
4951
NavigationStack {
5052
List {
@@ -88,9 +90,19 @@ struct AboutView: View {
8890
CreditRow(credit: c)
8991
}
9092
}
93+
94+
Section {
95+
Button("Show Setup") {
96+
showingSetup = true
97+
}
98+
.buttonStyle(.borderedProminent)
99+
}
91100
}
92101
.listStyle(InsetGroupedListStyle())
93102
}
103+
.sheet(isPresented: $showingSetup) {
104+
SetupView(onComplete: { showingSetup = false })
105+
}
94106
}
95107
}
96108

@@ -138,11 +150,4 @@ struct CreditRow: View {
138150
}
139151
.padding(.vertical, 8)
140152
}
141-
}
142-
143-
struct AboutView_Previews: PreviewProvider {
144-
static var previews: some View {
145-
AboutView()
146-
}
147-
148-
}
153+
}

Sources/prostore/views/SetupView.swift

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22
import UIKit
3+
import GCDWebServer
34

45
struct SetupView: View {
56
var onComplete: () -> Void
@@ -14,23 +15,23 @@ struct SetupView: View {
1415
imageName: "star.fill"),
1516

1617
SetupPage(title: "Install the SSL Certificate",
17-
subtitle: "When the popup appears, click the 'Close' button.",
18+
subtitle: "When the popup appears on the next page, click the 'Close' button.",
1819
imageName: "lock.shield"),
1920

2021
SetupPage(title: "Install the SSL Certificate",
2122
subtitle: "ProStore will now automatically generate the SSL certificate and open it for installation.",
2223
imageName: "sparkles"),
2324

2425
SetupPage(title: "Install the SSL Certificate",
25-
subtitle: "Go to Settings, tap 'Profile Downloaded', then 'Install'. Enter your passcode, and confirm by tapping 'Install' on the popup.",
26+
subtitle: "Go to Settings, tap 'Profile Downloaded', then 'Install'.\nEnter your passcode, and confirm by tapping 'Install' on the popup.",
2627
imageName: "checkmark.shield"),
2728

2829
SetupPage(title: "Install the SSL Certificate",
29-
subtitle: "Tap the tick, navigate to 'General → About → Certificate Trust Settings', and enable 'ProStore' under 'Enable Full Trust for Root Certificates'.",
30+
subtitle: "Tap the tick, then navigate to\n'General → About → Certificate Trust Settings'.\nEnable 'ProStore' under 'Enable Full Trust for Root Certificates'.",
3031
imageName: "hand.thumbsup"),
3132

3233
SetupPage(title: "You're finished!",
33-
subtitle: "Thanks for completing the setup! You're now ready to use ProStore.",
34+
subtitle: "Thanks for completing the setup!\nYou're now ready to use ProStore.",
3435
imageName: "party.popper")
3536
]
3637

@@ -118,7 +119,7 @@ struct SetupView: View {
118119

119120
// Find the ProStore.pem file
120121
if let proStoreCertURL = urls.first(where: { $0.lastPathComponent == "ProStore.pem" }) {
121-
openCertificateFile(url: proStoreCertURL)
122+
openCertificateUsingServer(certURL: proStoreCertURL)
122123
}
123124

124125
certGenerated = true
@@ -131,14 +132,26 @@ struct SetupView: View {
131132
}
132133
}
133134

134-
private func openCertificateFile(url: URL) {
135-
DispatchQueue.main.async {
136-
if UIApplication.shared.canOpenURL(url) {
137-
UIApplication.shared.open(url, options: [:], completionHandler: nil)
138-
} else {
139-
// Fallback to UIDocumentInteractionController
140-
let docController = UIDocumentInteractionController(url: url)
141-
docController.presentOptionsMenu(from: CGRect.zero, in: UIApplication.shared.windows.first!.rootViewController!.view, animated: true)
135+
private func openCertificateUsingServer(certURL: URL) {
136+
let webServer = GCDWebServer()
137+
138+
webServer.addHandler(forMethod: "GET", path: "/ProStore.crt", requestClass: GCDWebServerRequest.self) { request in
139+
do {
140+
let data = try Data(contentsOf: certURL)
141+
let response = GCDWebServerDataResponse(data: data, contentType: "application/x-x509-ca-cert")
142+
response?.setValue("attachment; filename=\"ProStore.crt\"", forAdditionalHeader: "Content-Disposition")
143+
return response
144+
} catch {
145+
return GCDWebServerResponse(statusCode: 500)
146+
}
147+
}
148+
149+
webServer.start(withPort: 0, bonjourName: nil)
150+
151+
if let serverURL = webServer.serverURL {
152+
let openURL = serverURL.appendingPathComponent("ProStore.crt")
153+
DispatchQueue.main.async {
154+
UIApplication.shared.open(openURL, options: [:], completionHandler: nil)
142155
}
143156
}
144157
}

project.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ targets:
3333
properties:
3434
CFBundleDisplayName: "ProStore"
3535
CFBundleName: "prostore"
36-
CFBundleVersion: "37"
37-
CFBundleShortVersionString: "0.11.0d4"
36+
CFBundleVersion: "38"
37+
CFBundleShortVersionString: "0.11.0d5"
3838
UILaunchStoryboardName: "LaunchScreen"
3939
NSPrincipalClass: "UIApplication"
4040
NSAppTransportSecurity:

0 commit comments

Comments
 (0)