Sources/OrgstarMobile/AboutScreen.swift
82 lines · 3414 bytes
1#if os(iOS)
2import SwiftUI
3import UIKit
4
5/// The version, where to read the manual and source, report a problem or ask for help, and tips.
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 TipSection()
52 Section {
53 link("Third-Party Notices", "doc.on.doc", Self.site + "third-party.html")
54 link("Privacy Policy", "hand.raised", "https://krz.sh/privacy/orgstar/")
55 } footer: {
56 Text(verbatim: "© 2026 Christian Cleberg")
57 }
58 }
59 .navigationTitle("About")
60 .navigationBarTitleDisplayMode(.inline)
61 }
62
63 /// A message to support with the version and device filled in.
64 private var mail: URL {
65 let device = UIDevice.current
66 var components = URLComponents()
67 components.scheme = "mailto"
68 components.path = Self.supportEmail
69 components.queryItems = [
70 URLQueryItem(name: "subject", value: "orgstar \(version)"),
71 URLQueryItem(name: "body", value: "\n\n—\norgstar \(version), \(device.systemName) \(device.systemVersion), \(device.model)"),
72 ]
73 return components.url!
74 }
75
76 private func link(_ title: LocalizedStringKey, _ systemImage: String, _ url: String) -> some View {
77 Link(destination: URL(string: url)!) {
78 Label(title, systemImage: systemImage)
79 }
80 }
81}
82#endif