← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


Reportage/Views/Settings/AboutView.swift (4233B)

1import SwiftUI
2
3/// The app's name, version and credits, with links to its website and
4/// source.
5struct AboutView: View {
6    private var appVersion: String {
7        Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
8    }
9
10    private var buildNumber: String {
11        Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "Unknown"
12    }
13
14    var body: some View {
15        List {
16            Section {
17                AboutHeader(appVersion: appVersion, buildNumber: buildNumber)
18                    .frame(maxWidth: .infinity)
19                    .padding(.vertical, 12)
20                    .listRowBackground(Theme.paper)
21                    .listRowSeparator(.hidden)
22            }
23            Section {
24                Link(destination: URL(string: "https://apps.inqk.net/reportage")!) {
25                    Label("Website", systemImage: "globe")
26                }
27                .settingsRow()
28                Link(destination: URL(string: "https://code.inqk.net/reportage")!) {
29                    Label("Source Code", systemImage: "chevron.left.forwardslash.chevron.right")
30                }
31                .settingsRow()
32            }
33            Section {
34                Text("Thank you to my wife, daughter and sons for their love and inspiration.")
35                    .font(.subheadline)
36                    .foregroundStyle(Theme.muted)
37                    .multilineTextAlignment(.center)
38                    .frame(maxWidth: .infinity)
39                    .padding(.top, 12)
40                    .listRowInsets(EdgeInsets(top: 8, leading: Theme.margin, bottom: 8, trailing: Theme.margin))
41                    .listRowBackground(Theme.paper)
42                    .listRowSeparator(.hidden)
43            }
44        }
45        .listStyle(.plain)
46        .scrollContentBackground(.hidden)
47        .tabBarClearance()
48        .background(Theme.paper)
49        .foregroundStyle(Theme.ink)
50        .navigationTitle("About")
51        .navigationBarTitleDisplayMode(.inline)
52        .toolbar(.visible, for: .navigationBar)
53    }
54}
55
56/// The icon, name, version and credits at the top of the screen.
57struct AboutHeader: View {
58    let appVersion: String
59    let buildNumber: String
60
61    var body: some View {
62        VStack(spacing: 8) {
63            AppIconImage()
64                .padding(.bottom, 4)
65            Text("Reportage\(Text(".").foregroundStyle(Theme.mark))", comment: "The app's name on the About screen, with a coloured full stop")
66                .font(Theme.serif(.title, weight: .medium))
67                .foregroundStyle(Theme.titleInk)
68                .accessibilityLabel(Text("Reportage"))
69            Text("Version \(appVersion) (\(buildNumber))")
70                .font(.subheadline)
71                .foregroundStyle(Theme.muted)
72                .padding(.bottom, 20)
73            Credit("Programming", name: "Claude Code")
74                .padding(.bottom, 8)
75            Credit("Direction", name: "Michael Camilleri")
76        }
77    }
78}
79
80/// A role and who filled it, the role in small spaced capitals.
81private struct Credit: View {
82    let role: LocalizedStringKey
83    let name: String
84
85    init(_ role: LocalizedStringKey, name: String) {
86        self.role = role
87        self.name = name
88    }
89
90    var body: some View {
91        VStack(spacing: 4) {
92            Text(role)
93                .eyebrow()
94            Text(verbatim: name)
95                .font(.subheadline)
96        }
97        .accessibilityElement(children: .combine)
98    }
99}
100
101/// The app icon: the wordmark's 'e.' zoomed in until the full stop leads.
102/// It's a separate image from AppIcon, which apps can't load, with an
103/// opaque dark version where the dark app icon is transparent. Its paper
104/// matches the screen's, so a hairline marks its edge.
105private struct AppIconImage: View {
106    private let shape = RoundedRectangle(cornerRadius: 22, style: .continuous)
107
108    var body: some View {
109        Image(.aboutIcon)
110            .resizable()
111            .frame(width: 100, height: 100)
112            .clipShape(shape)
113            .overlay(shape.strokeBorder(Theme.rule))
114            .accessibilityHidden(true)
115    }
116}
117
118#Preview {
119    NavigationStack {
120        AboutView()
121    }
122    .tint(Theme.accent)
123}