summaryrefslogtreecommitdiff
path: root/DomainDig/AppLinks.swift
blob: 39c903635228744ed882ab1ac8b3c846ac4122e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Foundation

/// Centralized external destinations, kept in one place so URLs and the App Store
/// identifier can be swapped without touching any view.
///
/// TODO(release): `appStoreID` is a placeholder until the App Store listing is
/// live — the listing/review/share URLs derive from it. `documentation` points
/// at the repository README for now; swap in a dedicated docs site if one lands.
enum AppLinks {
    /// App Store numeric identifier. Placeholder until the listing is published.
    static let appStoreID = "0000000000"

    static let sourceCode = url("https://github.com/zerolabsco/domain-dig")
    static let documentation = url("https://github.com/zerolabsco/domain-dig#readme")
    static let privacyPolicy = url("https://zerolabs.sh/domaindig/privacy-policy/")
    static let supportEmail = "[email protected]"

    static var appStoreListing: URL { url("https://apps.apple.com/app/id\(appStoreID)") }
    static var writeReview: URL { url("https://apps.apple.com/app/id\(appStoreID)?action=write-review") }

    static var copyright: String {
        let year = Calendar.current.component(.year, from: Date())
        return \(year) Christian Cleberg"
    }

    /// Builds URLs from developer-controlled literals; a malformed literal is a
    /// programming error, surfaced loudly in development rather than force-unwrapped.
    private static func url(_ string: String) -> URL {
        guard let url = URL(string: string) else {
            preconditionFailure("Invalid AppLinks URL literal: \(string)")
        }
        return url
    }
}