[kit] Dynamically build the style dropdown menu
This commit is contained in:
parent
587e616d76
commit
f6e7217b2c
1 changed files with 2 additions and 16 deletions
|
|
@ -11,15 +11,6 @@ import Cocoa
|
||||||
internal let PreferencesDidChange_Color = Notification.Name("PreferencesDidChange_Color")
|
internal let PreferencesDidChange_Color = Notification.Name("PreferencesDidChange_Color")
|
||||||
|
|
||||||
class PreferencesViewController: NSViewController {
|
class PreferencesViewController: NSViewController {
|
||||||
private static var styleItems: [(name: String, tag: Int)] {
|
|
||||||
return [
|
|
||||||
(name: NSLocalizedString("Single Color", comment: "single color menu item"),
|
|
||||||
tag: Int(ColorStyle.singleColor.rawValue)),
|
|
||||||
(name: NSLocalizedString("Two Color Gradient — Horizontal", comment: "two color horizontal gradient menu item"),
|
|
||||||
tag: Int(ColorStyle.gradient2Horizontal.rawValue)),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
public var defaults = UserDefaults.standard
|
public var defaults = UserDefaults.standard
|
||||||
|
|
||||||
private var colorStackView = NSStackView()
|
private var colorStackView = NSStackView()
|
||||||
|
|
@ -30,13 +21,8 @@ class PreferencesViewController: NSViewController {
|
||||||
button.translatesAutoresizingMaskIntoConstraints = false
|
button.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
for item in PreferencesViewController.styleItems {
|
menu.addItem(withTitle: NSLocalizedString("Single Color", comment: "single color menu item"), action: nil, keyEquivalent: "")
|
||||||
// TODO: Set action here.
|
menu.addItem(withTitle: NSLocalizedString("Two Color Gradient — Horizontal", comment: "two color horizontal gradient menu item"), action: nil, keyEquivalent: "")
|
||||||
let menuItem = NSMenuItem(title: item.name, action: nil, keyEquivalent: "")
|
|
||||||
menuItem.target = self
|
|
||||||
menuItem.tag = item.tag
|
|
||||||
menu.addItem(menuItem)
|
|
||||||
}
|
|
||||||
button.menu = menu
|
button.menu = menu
|
||||||
|
|
||||||
return button
|
return button
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue