Sfoglia il codice sorgente

Apply purple branding to the sidebar logo and Premium nav item.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 12 ore fa
parent
commit
3b98916bf1
2 ha cambiato i file con 20 aggiunte e 8 eliminazioni
  1. 2 2
      smart_printer/SidebarView.swift
  2. 18 6
      smart_printer/UIComponents.swift

+ 2 - 2
smart_printer/SidebarView.swift

@@ -38,7 +38,7 @@ final class SidebarView: NSView {
38
             let config = NSImage.SymbolConfiguration(pointSize: 28, weight: .medium)
38
             let config = NSImage.SymbolConfiguration(pointSize: 28, weight: .medium)
39
             logoIcon.image = image.withSymbolConfiguration(config)
39
             logoIcon.image = image.withSymbolConfiguration(config)
40
         }
40
         }
41
-        logoIcon.contentTintColor = AppTheme.blue
41
+        logoIcon.contentTintColor = AppTheme.purple
42
 
42
 
43
         let appNameLabel = NSTextField(labelWithString: "Smart Printer")
43
         let appNameLabel = NSTextField(labelWithString: "Smart Printer")
44
         appNameLabel.font = AppTheme.semiboldFont(size: 15)
44
         appNameLabel.font = AppTheme.semiboldFont(size: 15)
@@ -54,7 +54,7 @@ final class SidebarView: NSView {
54
 
54
 
55
         let homeItem = SidebarNavItem(title: "Home", symbolName: "house.fill", isSelected: true)
55
         let homeItem = SidebarNavItem(title: "Home", symbolName: "house.fill", isSelected: true)
56
         let scanItem = SidebarNavItem(title: "Scan", symbolName: "viewfinder")
56
         let scanItem = SidebarNavItem(title: "Scan", symbolName: "viewfinder")
57
-        let scanAndHomeItem = SidebarNavItem(title: "Premium", symbolName: "diamond.fill")
57
+        let scanAndHomeItem = SidebarNavItem(title: "Premium", symbolName: "diamond.fill", accent: .premium)
58
 
58
 
59
         navItems = [homeItem, scanItem, scanAndHomeItem]
59
         navItems = [homeItem, scanItem, scanAndHomeItem]
60
         for (index, item) in navItems.enumerated() {
60
         for (index, item) in navItems.enumerated() {

+ 18 - 6
smart_printer/UIComponents.swift

@@ -63,8 +63,14 @@ final class SidebarNavItem: NSControl {
63
         case active
63
         case active
64
     }
64
     }
65
 
65
 
66
+    enum Accent {
67
+        case standard
68
+        case premium
69
+    }
70
+
66
     var onClick: (() -> Void)?
71
     var onClick: (() -> Void)?
67
 
72
 
73
+    private let accent: Accent
68
     private let iconView = NSImageView()
74
     private let iconView = NSImageView()
69
     private let titleLabel = NSTextField(labelWithString: "")
75
     private let titleLabel = NSTextField(labelWithString: "")
70
     private let container = NSView()
76
     private let container = NSView()
@@ -73,7 +79,8 @@ final class SidebarNavItem: NSControl {
73
         didSet { applyStyle(isSelected ? .active : .normal) }
79
         didSet { applyStyle(isSelected ? .active : .normal) }
74
     }
80
     }
75
 
81
 
76
-    init(title: String, symbolName: String, isSelected: Bool = false) {
82
+    init(title: String, symbolName: String, isSelected: Bool = false, accent: Accent = .standard) {
83
+        self.accent = accent
77
         super.init(frame: .zero)
84
         super.init(frame: .zero)
78
         self.isSelected = isSelected
85
         self.isSelected = isSelected
79
 
86
 
@@ -124,15 +131,20 @@ final class SidebarNavItem: NSControl {
124
         container.wantsLayer = true
131
         container.wantsLayer = true
125
         container.layer?.cornerRadius = AppTheme.cornerRadius
132
         container.layer?.cornerRadius = AppTheme.cornerRadius
126
 
133
 
134
+        let activeBackground = accent == .premium ? AppTheme.premiumBackground : AppTheme.homeActiveBackground
135
+        let activeForeground = accent == .premium ? AppTheme.premiumForeground : AppTheme.homeActiveForeground
136
+
137
+        let normalForeground = accent == .premium ? AppTheme.premiumForeground : AppTheme.textPrimary
138
+
127
         switch style {
139
         switch style {
128
         case .normal:
140
         case .normal:
129
             container.layer?.backgroundColor = NSColor.clear.cgColor
141
             container.layer?.backgroundColor = NSColor.clear.cgColor
130
-            titleLabel.textColor = AppTheme.textPrimary
131
-            iconView.contentTintColor = AppTheme.textPrimary
142
+            titleLabel.textColor = normalForeground
143
+            iconView.contentTintColor = normalForeground
132
         case .active:
144
         case .active:
133
-            container.layer?.backgroundColor = AppTheme.homeActiveBackground.cgColor
134
-            titleLabel.textColor = AppTheme.homeActiveForeground
135
-            iconView.contentTintColor = AppTheme.homeActiveForeground
145
+            container.layer?.backgroundColor = activeBackground.cgColor
146
+            titleLabel.textColor = activeForeground
147
+            iconView.contentTintColor = activeForeground
136
         }
148
         }
137
     }
149
     }
138
 
150