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