|
|
@@ -162,7 +162,7 @@ class ViewController: NSViewController {
|
|
|
let documentView = FlippedDocumentView()
|
|
|
documentView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
- let sectionTitle = makeSectionTitle(title, showGridIcon: true)
|
|
|
+ let sectionTitle = makeSectionTitle(title, icon: .grid)
|
|
|
let grid = makeFeatureRow(features: features)
|
|
|
|
|
|
documentView.addSubview(sectionTitle)
|
|
|
@@ -271,40 +271,58 @@ class ViewController: NSViewController {
|
|
|
return scrollView
|
|
|
}
|
|
|
|
|
|
- private func makeSectionTitle(_ text: String, showGridIcon: Bool = false) -> NSView {
|
|
|
+ private enum SectionTitleIcon {
|
|
|
+ case none
|
|
|
+ case sparkle
|
|
|
+ case grid
|
|
|
+ }
|
|
|
+
|
|
|
+ private func makeSectionTitle(_ text: String, icon: SectionTitleIcon = .none) -> NSView {
|
|
|
let container = NSView()
|
|
|
container.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
var leadingAnchor = container.leadingAnchor
|
|
|
-
|
|
|
- if showGridIcon {
|
|
|
- let gridIcon = NSImageView()
|
|
|
- gridIcon.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- if let image = NSImage(systemSymbolName: "square.grid.2x2", accessibilityDescription: nil) {
|
|
|
- let config = NSImage.SymbolConfiguration(pointSize: 16, weight: .medium)
|
|
|
- gridIcon.image = image.withSymbolConfiguration(config)
|
|
|
+ var iconSpacing: CGFloat = 0
|
|
|
+
|
|
|
+ if icon != .none {
|
|
|
+ let titleIcon: NSView
|
|
|
+ switch icon {
|
|
|
+ case .sparkle:
|
|
|
+ titleIcon = SparkleIconView()
|
|
|
+ case .grid:
|
|
|
+ let gridIcon = NSImageView()
|
|
|
+ if let image = NSImage(systemSymbolName: "square.grid.2x2", accessibilityDescription: nil) {
|
|
|
+ let config = NSImage.SymbolConfiguration(pointSize: 16, weight: .medium)
|
|
|
+ gridIcon.image = image.withSymbolConfiguration(config)
|
|
|
+ }
|
|
|
+ gridIcon.contentTintColor = AppTheme.textPrimary
|
|
|
+ titleIcon = gridIcon
|
|
|
+ case .none:
|
|
|
+ titleIcon = NSView()
|
|
|
}
|
|
|
- gridIcon.contentTintColor = AppTheme.textPrimary
|
|
|
- container.addSubview(gridIcon)
|
|
|
+
|
|
|
+ titleIcon.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+ container.addSubview(titleIcon)
|
|
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
- gridIcon.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
|
- gridIcon.centerYAnchor.constraint(equalTo: container.centerYAnchor),
|
|
|
- gridIcon.widthAnchor.constraint(equalToConstant: 20),
|
|
|
- gridIcon.heightAnchor.constraint(equalToConstant: 20),
|
|
|
+ titleIcon.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
|
|
+ titleIcon.centerYAnchor.constraint(equalTo: container.centerYAnchor),
|
|
|
+ titleIcon.widthAnchor.constraint(equalToConstant: 24),
|
|
|
+ titleIcon.heightAnchor.constraint(equalToConstant: 24),
|
|
|
])
|
|
|
- leadingAnchor = gridIcon.trailingAnchor
|
|
|
+ leadingAnchor = titleIcon.trailingAnchor
|
|
|
+ iconSpacing = 8
|
|
|
}
|
|
|
|
|
|
let label = NSTextField(labelWithString: text)
|
|
|
- label.font = AppTheme.semiboldFont(size: 20)
|
|
|
+ label.font = .systemFont(ofSize: 20, weight: .bold)
|
|
|
label.textColor = AppTheme.textPrimary
|
|
|
label.translatesAutoresizingMaskIntoConstraints = false
|
|
|
container.addSubview(label)
|
|
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
container.heightAnchor.constraint(equalToConstant: 28),
|
|
|
- label.leadingAnchor.constraint(equalTo: leadingAnchor, constant: showGridIcon ? 8 : 0),
|
|
|
+ label.leadingAnchor.constraint(equalTo: leadingAnchor, constant: iconSpacing),
|
|
|
label.centerYAnchor.constraint(equalTo: container.centerYAnchor),
|
|
|
label.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
|
|
])
|
|
|
@@ -316,7 +334,7 @@ class ViewController: NSViewController {
|
|
|
let section = NSView()
|
|
|
section.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
- let title = makeSectionTitle("Quick Start")
|
|
|
+ let title = makeSectionTitle("Quick Start", icon: .sparkle)
|
|
|
section.addSubview(title)
|
|
|
|
|
|
let cardsStack = NSStackView()
|
|
|
@@ -375,7 +393,7 @@ class ViewController: NSViewController {
|
|
|
let section = NSView()
|
|
|
section.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
|
|
- let title = makeSectionTitle("Create & Print", showGridIcon: true)
|
|
|
+ let title = makeSectionTitle("Create & Print", icon: .grid)
|
|
|
section.addSubview(title)
|
|
|
|
|
|
let features: [FeatureCardData] = [
|