feat: add feedback button on about window

This commit is contained in:
louis.pontoise authored and lwouis committed 2020-03-10 14:00:37 +09:00
1 parent 67f291d1fe
commit 404613607c
1 file changed
+18 -6
@@ -1,26 +1,38 @@
import Cocoa
import Foundation
class AboutTab {
class AboutTab: NSObject {
static func make() -> NSTabViewItem {
return TabViewItem.make("About", NSImage.infoName, makeView())
}
private static func makeView() -> NSGridView {
static func makeView() -> NSGridView {
let appIcon = NSImageView(image: App.shared.applicationIconImage)
appIcon.fit(80, 80)
let appText = NSStackView(views: [BoldLabel(App.name), NSTextField(wrappingLabelWithString: "Version \(App.version)")])
appIcon.fit(128, 128)
let appText = NSStackView(views: [
BoldLabel(App.name),
NSTextField(wrappingLabelWithString: "Version \(App.version)"),
HyperlinkLabel("Source code repository", App.repository),
HyperlinkLabel("Latest releases", App.repository + "/releases"),
])
appText.orientation = .vertical
appText.alignment = .left
appText.spacing = GridView.interPadding / 2
appText.views[2].topAnchor.constraint(equalTo: appText.views[1].bottomAnchor, constant: GridView.interPadding).isActive = true
let appInfo = NSStackView(views: [appIcon, appText])
appInfo.spacing = GridView.interPadding
let view = GridView.make([
[appInfo],
[HyperlinkLabel("Source code repository", App.repository)],
[HyperlinkLabel("Latest releases", App.repository + "/releases")],
[NSButton(title: "Send feedback", target: self, action: #selector(feedbackCallback))],
])
view.row(at: 1).topPadding = GridView.interPadding * 2
view.cell(atColumnIndex: 0, rowIndex: 1).xPlacement = .center
view.fit()
return view
}
@objc
static func feedbackCallback(senderControl: NSControl) {
(App.shared as! App).showFeedbackPanel()
}
}