-
-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add feedback button on about window
- Loading branch information
Showing
1 changed file
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |