Files
NetNewsWire/Mac/MainWindow/About/AboutNewNewsWireView.swift
Stuart Breckenridge e2eeed8f99 Target macOS 13
• `xcconfig` `MACOSX_DEPLOYMENT_TARGET` updated to 13.0
• Removed `@available` annotations for macOS < 13.0
• Removed for Big Sur fixes.

This has been built and doesn’t trigger any build settings should be `xcconfig` options.
2023-05-30 09:15:08 +08:00

92 lines
2.1 KiB
Swift

//
// AboutNewNewsWireView.swift
// NetNewsWire
//
// Created by Stuart Breckenridge on 03/10/2022.
// Copyright © 2022 Ranchero Software. All rights reserved.
//
import SwiftUI
import WebKit
import Html
fileprivate struct WebView: NSViewRepresentable {
var htmlString: String
func makeNSView(context: Context) -> DetailWebView {
let view = DetailWebView()
view.loadHTMLString(htmlString, baseURL: nil)
return view
}
func updateNSView(_ webView: DetailWebView, context: Context) {
webView.navigationDelegate = context.coordinator
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject, WKNavigationDelegate {
var parent: WebView!
init(_ parent: WebView) {
self.parent = parent
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == .linkActivated {
if let url = navigationAction.request.url {
Task { @MainActor in Browser.open(url.absoluteString) }
}
decisionHandler(.cancel)
return
}
decisionHandler(.allow)
}
}
}
struct AboutNewNewsWireView: View, LoadableAboutData {
var body: some View {
VStack(spacing: 4) {
Image("About")
.resizable()
.frame(width: 70, height: 70)
.padding(.top)
Text(verbatim: "NetNewsWire")
.font(.title3)
.bold()
Text("\(Bundle.main.versionNumber) (\(Bundle.main.buildNumber))")
.font(.body)
.padding(.bottom)
WebView(htmlString: AboutHTML().renderedDocument())
.overlay(Divider(), alignment: .top)
.overlay(Divider(), alignment: .bottom)
HStack(alignment: .center) {
Spacer()
Text(verbatim: "Copyright © Brent Simmons 2002 - \(Calendar.current.component(.year, from: .now))")
.font(.caption2)
.padding(.bottom, 6)
.padding(.top, 2)
Spacer()
}
}
.frame(width: 425, height: 550)
}
}
struct AboutNetNewsWireView_Previews: PreviewProvider {
static var previews: some View {
AboutNewNewsWireView()
}
}