Sources/OrgstarMobile/AboutScreen.swift
cmc Distribute from files.krz.sh; all rights reserved; issues in krz/orgstar-issues
f6297bb2ab 12 days ago81 lines · 3383 bytes
1#if os(iOS)
2import SwiftUI
3import UIKit
4
5/// The version, and where to read the manual and source, report a problem or ask for help.
6struct AboutScreen: View {
7 /// The app icon in use, as `AppIcons` names it.
8 let appIcon: String
9
10 static let supportEmail = "help@krz.sh"
11
12 private static let site = "https://files.krz.sh/orgstar/"
13
14 private var version: String {
15 let info = Bundle.main.infoDictionary
16 let short = info?["CFBundleShortVersionString"] as? String ?? "?"
17 let build = info?["CFBundleVersion"] as? String ?? "?"
18 return build == short ? short : "\(short) (\(build))"
19 }
20
21 var body: some View {
22 Form {
23 Section {
24 VStack(spacing: 8) {
25 // Builds without the asset catalog have no preview.
26 if let icon = UIImage(named: "IconPreview-\(appIcon)") {
27 Image(uiImage: icon)
28 .resizable()
29 .frame(width: 80, height: 80)
30 .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
31 .accessibilityHidden(true)
32 }
33 Text("orgstar").font(.title2.bold())
34 Text("Version \(version)").font(.subheadline).foregroundStyle(.secondary).textSelection(.enabled)
35 }
36 .frame(maxWidth: .infinity)
37 .listRowBackground(Color.clear)
38 }
39 Section {
40 link("Manual", "book", Self.site)
41 link("Release Notes", "sparkles", "https://apps.apple.com/app/id6821552018")
42 link("Website", "globe", "https://krz.sh/apps/orgstar")
43 }
44 Section {
45 link("Report an Issue", "ladybug", "https://gitbay.org/krz/orgstar-issues/issues/new")
46 link("Email Support", "envelope", mail.absoluteString)
47 link("Rate on the App Store", "star", "https://apps.apple.com/app/id6821552018?action=write-review")
48 } footer: {
49 Text("Reporting an issue needs a gitbay account. Without one, email \(Self.supportEmail).")
50 }
51 Section {
52 link("Third-Party Notices", "doc.on.doc", Self.site + "third-party.html")
53 link("Privacy Policy", "hand.raised", "https://krz.sh/privacy/orgstar/")
54 } footer: {
55 Text(verbatim: "© 2026 Christian Cleberg")
56 }
57 }
58 .navigationTitle("About")
59 .navigationBarTitleDisplayMode(.inline)
60 }
61
62 /// A message to support with the version and device filled in.
63 private var mail: URL {
64 let device = UIDevice.current
65 var components = URLComponents()
66 components.scheme = "mailto"
67 components.path = Self.supportEmail
68 components.queryItems = [
69 URLQueryItem(name: "subject", value: "orgstar \(version)"),
70 URLQueryItem(name: "body", value: "\n\n—\norgstar \(version), \(device.systemName) \(device.systemVersion), \(device.model)"),
71 ]
72 return components.url!
73 }
74
75 private func link(_ title: LocalizedStringKey, _ systemImage: String, _ url: String) -> some View {
76 Link(destination: URL(string: url)!) {
77 Label(title, systemImage: systemImage)
78 }
79 }
80}
81#endif