[About Dialog] Switched to WebView for credits

Signed-off-by: Kevin López Brante <kevin@kddlb.cl>
swiftingly
Kevin López 2022-06-21 22:17:03 -04:00 committed by Christopher Snowhill
parent 05da7450da
commit de5cce8351
3 changed files with 57 additions and 54 deletions

View File

@ -6,6 +6,7 @@
// //
import Cocoa import Cocoa
import WebKit
class AboutWindowController: NSWindowController { class AboutWindowController: NSWindowController {
@ -13,7 +14,7 @@ class AboutWindowController: NSWindowController {
@IBOutlet weak var appVersion: NSTextField! @IBOutlet weak var appVersion: NSTextField!
@IBOutlet weak var appCopyright: NSTextField! @IBOutlet weak var appCopyright: NSTextField!
@IBOutlet var creditsView: NSTextView! @IBOutlet weak var creditsView: WKWebView!
override var windowNibName: NSNib.Name? { override var windowNibName: NSNib.Name? {
return "AboutWindowController" return "AboutWindowController"
@ -27,11 +28,8 @@ class AboutWindowController: NSWindowController {
self.window?.center() self.window?.center()
self.window?.isMovableByWindowBackground = true self.window?.isMovableByWindowBackground = true
vfxView.wantsLayer = true creditsView.setValue(false, forKey: "drawsBackground")
vfxView.canDrawSubviewsIntoLayer = true
vfxView.layer?.cornerRadius = 10.0
vfxView.layer?.masksToBounds = true
// fill up labels // fill up labels
@ -47,9 +45,8 @@ class AboutWindowController: NSWindowController {
if let creditsFile = Bundle.main.url(forResource: "Credits", withExtension: "html") { if let creditsFile = Bundle.main.url(forResource: "Credits", withExtension: "html") {
let data = try! Data(contentsOf: creditsFile) let data = try! Data(contentsOf: creditsFile)
if let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) { creditsView.loadHTMLString(String(data: data, encoding: .utf8) ?? "Could not load credits.", baseURL: nil)
creditsView.textStorage?.setAttributedString(attributedString)
}
} }
} }

View File

@ -3,6 +3,7 @@
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
<plugIn identifier="com.apple.WebKit2IBPlugin" version="20037"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@ -11,7 +12,7 @@
<outlet property="appCopyright" destination="ht5-N1-YXd" id="cUK-kB-F2V"/> <outlet property="appCopyright" destination="ht5-N1-YXd" id="cUK-kB-F2V"/>
<outlet property="appName" destination="Lya-f1-R7S" id="ZVN-sE-MQp"/> <outlet property="appName" destination="Lya-f1-R7S" id="ZVN-sE-MQp"/>
<outlet property="appVersion" destination="7dE-CE-MBv" id="qOe-3F-tMG"/> <outlet property="appVersion" destination="7dE-CE-MBv" id="qOe-3F-tMG"/>
<outlet property="creditsView" destination="iz8-0U-jtY" id="uMm-WQ-Fui"/> <outlet property="creditsView" destination="LZw-Xy-wYl" id="jyQ-Rg-oqx"/>
<outlet property="imageView" destination="aIO-L9-zMj" id="cIl-Ce-onP"/> <outlet property="imageView" destination="aIO-L9-zMj" id="cIl-Ce-onP"/>
<outlet property="vfxView" destination="2nK-dq-1h6" id="ToT-af-ycD"/> <outlet property="vfxView" destination="2nK-dq-1h6" id="ToT-af-ycD"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/> <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
@ -39,39 +40,15 @@
<visualEffectView blendingMode="withinWindow" material="fullScreenUI" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="2nK-dq-1h6"> <visualEffectView blendingMode="withinWindow" material="fullScreenUI" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="2nK-dq-1h6">
<rect key="frame" x="387" y="84" width="262" height="230"/> <rect key="frame" x="387" y="84" width="262" height="230"/>
<subviews> <subviews>
<scrollView appearanceType="aqua" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HLG-H1-ARK"> <wkWebView wantsLayer="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LZw-Xy-wYl">
<rect key="frame" x="0.0" y="0.0" width="262" height="230"/> <rect key="frame" x="0.0" y="0.0" width="262" height="230"/>
<clipView key="contentView" drawsBackground="NO" id="VsR-Lq-AhX">
<rect key="frame" x="0.0" y="0.0" width="247" height="230"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" verticallyResizable="YES" findStyle="bar" allowsDocumentBackgroundColorChange="YES" spellingCorrection="YES" smartInsertDelete="YES" id="iz8-0U-jtY">
<rect key="frame" x="0.0" y="0.0" width="247" height="230"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<size key="minSize" width="247" height="230"/>
<size key="maxSize" width="247" height="10000000"/>
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Jrl-HU-vmJ">
<rect key="frame" x="-100" y="-100" width="225" height="15"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
</scroller> <wkWebViewConfiguration key="configuration" applicationNameForUserAgent="Cog">
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="z2b-Sa-SQ9"> <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<rect key="frame" x="247" y="0.0" width="15" height="230"/> <wkPreferences key="preferences"/>
<autoresizingMask key="autoresizingMask"/> </wkWebViewConfiguration>
</scroller> </wkWebView>
</scrollView>
</subviews> </subviews>
<constraints>
<constraint firstItem="HLG-H1-ARK" firstAttribute="leading" secondItem="2nK-dq-1h6" secondAttribute="leading" id="RIy-GD-jCE"/>
<constraint firstItem="HLG-H1-ARK" firstAttribute="top" secondItem="2nK-dq-1h6" secondAttribute="top" id="Ye7-Xs-CXc"/>
<constraint firstAttribute="trailing" secondItem="HLG-H1-ARK" secondAttribute="trailing" id="tZ8-S3-bky"/>
<constraint firstAttribute="bottom" secondItem="HLG-H1-ARK" secondAttribute="bottom" id="vNr-Wi-0vq"/>
</constraints>
</visualEffectView> </visualEffectView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Lya-f1-R7S"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Lya-f1-R7S">
<rect key="frame" x="385" y="351" width="266" height="31"/> <rect key="frame" x="385" y="351" width="266" height="31"/>

View File

@ -1,5 +1,33 @@
<!DOCTYPE html>
<html> <html>
<body style="text-align:center;"> <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SpoGen web view</title>
<style>
:root {
color-scheme: light dark;
}
html, body {
font: -apple-system-body;
-webkit-text-size-adjust: 100%;
}
div {
text-align: center;
}
a:link {
color: #ffb565;
text-decoration: none;
}
</style>
</head>
<body>
<div>
Now with 92% more future! Now with 92% more future!
<br><br> <br><br>
<em>This program has been made possible through contributions from users like you.</em> <em>This program has been made possible through contributions from users like you.</em>
@ -11,5 +39,6 @@
Thanks to my patrons: Thanks to my patrons:
<br> <br>
Alexander Pecheny, Electric Keet, Antti Aro, Fj&ouml;lnir &Aacute;sgeirsson, Giampaolo Bellavite, Louis Martinez V, alga Alexander Pecheny, Electric Keet, Antti Aro, Fj&ouml;lnir &Aacute;sgeirsson, Giampaolo Bellavite, Louis Martinez V, alga
</body> </div>
</body>
</html> </html>