mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Article themes moved to SwiftUI
This commit is contained in:
108
iOS/Settings/Help/AboutView.swift
Normal file
108
iOS/Settings/Help/AboutView.swift
Normal file
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// AboutView.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 02/10/2022.
|
||||
// Copyright © 2022 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct AboutView: View, LoadableAboutData {
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section(header: aboutHeaderView) {}
|
||||
Section(header: Text("PRIMARY_CONTRIBUTORS", tableName: "Settings")) {
|
||||
ForEach(0..<about.PrimaryContributors.count, id: \.self) { i in
|
||||
contributorView(about.PrimaryContributors[i])
|
||||
}
|
||||
}
|
||||
Section(header: Text("ADDITIONAL_CONTRIBUTORS", tableName: "Settings")) {
|
||||
ForEach(0..<about.AdditionalContributors.count, id: \.self) { i in
|
||||
contributorView(about.AdditionalContributors[i])
|
||||
}
|
||||
}
|
||||
Section(header: Text("THANKS", tableName: "Settings"), footer: thanks, content: {})
|
||||
Section(footer: copyright, content: {})
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.navigationTitle(Text("ABOUT", tableName: "Settings"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
var aboutHeaderView: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
VStack(alignment: .center, spacing: 8) {
|
||||
Image("About")
|
||||
.resizable()
|
||||
.frame(width: 75, height: 75)
|
||||
|
||||
Text(Bundle.main.appName)
|
||||
.font(.headline)
|
||||
|
||||
Text("\(Bundle.main.versionNumber) (\(Bundle.main.buildNumber))")
|
||||
.foregroundColor(.secondary)
|
||||
.font(.callout)
|
||||
|
||||
Text("BYLINE", tableName: "Settings")
|
||||
.font(.subheadline)
|
||||
|
||||
Text("[netnewswire.com](https://netnewswire.com)")
|
||||
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.textCase(.none)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
func contributorView(_ appCredit: AboutData.Contributor) -> some View {
|
||||
HStack {
|
||||
Text(appCredit.name)
|
||||
Spacer()
|
||||
if let role = appCredit.role {
|
||||
Text(role)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
if let _ = appCredit.url {
|
||||
Image(systemName: "info.circle")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
guard let url = appCredit.url else { return }
|
||||
if let creditURL = URL(string: url) {
|
||||
UIApplication.shared.open(creditURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var thanks: some View {
|
||||
Text(about.ThanksMarkdown)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.callout)
|
||||
}
|
||||
|
||||
var copyright: some View {
|
||||
HStack {
|
||||
Spacer()
|
||||
Text(verbatim: "Copyright © Brent Simmons 2002 - \(Calendar.current.component(.year, from: .now))")
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct AboutView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NavigationView {
|
||||
AboutView()
|
||||
}
|
||||
}
|
||||
}
|
||||
42
iOS/Settings/Help/SettingsHelpSheets.swift
Normal file
42
iOS/Settings/Help/SettingsHelpSheets.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// SettingsHelpSheets.swift
|
||||
// NetNewsWire-iOS
|
||||
//
|
||||
// Created by Stuart Breckenridge on 12/11/2022.
|
||||
// Copyright © 2022 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public enum HelpSheet: CustomStringConvertible, CaseIterable {
|
||||
|
||||
case help, website
|
||||
|
||||
public var description: String {
|
||||
switch self {
|
||||
case .help:
|
||||
return NSLocalizedString("NETNEWSWIRE_HELP", tableName: "Settings", comment: "NetNewsWire Help")
|
||||
case .website:
|
||||
return NSLocalizedString("NETNEWSWIRE_WEBSITE", tableName: "Settings", comment: "NetNewsWire Website")
|
||||
}
|
||||
}
|
||||
|
||||
public var url: URL {
|
||||
switch self {
|
||||
case .help:
|
||||
return URL(string: "https://netnewswire.com/help/ios/6.1/en/")!
|
||||
case .website:
|
||||
return URL(string: "https://netnewswire.com/")!
|
||||
}
|
||||
}
|
||||
|
||||
public var systemImage: String {
|
||||
switch self {
|
||||
case .help:
|
||||
return "questionmark.app"
|
||||
case .website:
|
||||
return "globe"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user