Files
NetNewsWire/Shared/AboutData.swift
Stuart Breckenridge 05aca1c995 About Views
- Tidied up iOS
- Adds refreshed About view to macOS 12+
- About.plist is now shared
2022-10-03 21:16:51 +08:00

49 lines
1.2 KiB
Swift

//
// AboutData.swift
// NetNewsWire-iOS
//
// Created by Stuart Breckenridge on 02/10/2022.
// Copyright © 2022 Ranchero Software. All rights reserved.
//
import Foundation
@available(iOS 15, *)
@available(macOS 12, *)
protocol LoadableAboutData {
var about: AboutData { get }
}
@available(iOS 15, *)
@available(macOS 12, *)
extension LoadableAboutData {
var about: AboutData {
guard let path = Bundle.main.path(forResource: "About", ofType: "plist") else {
fatalError("The about plist really should exist.")
}
let url = URL(fileURLWithPath: path)
let data = try! Data(contentsOf: url)
return try! PropertyListDecoder().decode(AboutData.self, from: data)
}
}
@available(iOS 15, *)
@available(macOS 12, *)
struct AboutData: Codable {
var PrimaryContributors: [Contributor]
var AdditionalContributors: [Contributor]
var ThanksMarkdown: AttributedString {
let dataURL = Bundle.main.url(forResource: "Thanks", withExtension: "md")!
return try! AttributedString(markdown: Data(contentsOf: dataURL), options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace))
}
struct Contributor: Codable {
var name: String
var url: String?
var role: String?
}
}