File tree Expand file tree Collapse file tree 6 files changed +74
-79
lines changed
Expand file tree Collapse file tree 6 files changed +74
-79
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import SwiftUI
2+ import AppKit
23
34struct ColorSelectionSection : View {
45 let title : String
@@ -71,4 +72,36 @@ struct ColorSelectionSection: View {
7172 . padding ( . horizontal, 20 )
7273 . padding ( . vertical, 12 )
7374 }
74- }
75+ }
76+
77+ class ColorPanelCoordinator : NSObject {
78+ var onColorChanged : ( ( Color ) -> Void ) ?
79+ private var colorPanel : NSColorPanel ?
80+
81+ func showColorPanel( initialColor: Color ) {
82+ colorPanel = NSColorPanel ( )
83+ colorPanel? . color = NSColor ( initialColor)
84+ colorPanel? . setTarget ( self )
85+ colorPanel? . setAction ( #selector( colorChanged) )
86+ colorPanel? . makeKeyAndOrderFront ( nil )
87+ }
88+
89+ @objc func colorChanged( ) {
90+ guard let colorPanel = colorPanel else { return }
91+ let newColor = Color ( colorPanel. color)
92+ onColorChanged ? ( newColor)
93+ }
94+
95+ func closeColorPanel( ) {
96+ colorPanel? . close ( )
97+ colorPanel = nil
98+ }
99+ }
100+
101+ class BackgroundColorPanelCoordinator : ColorPanelCoordinator {
102+ static let shared = BackgroundColorPanelCoordinator ( )
103+ }
104+
105+ class ForegroundColorPanelCoordinator : ColorPanelCoordinator {
106+ static let shared = ForegroundColorPanelCoordinator ( )
107+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -196,4 +196,43 @@ struct IconSelectorView: View {
196196 hasCustomBackgroundColor = newColor != . clear
197197 }
198198 }
199- }
199+ }
200+
201+ struct IconGridItem : View {
202+ let iconName : String ?
203+ let isSelected : Bool
204+ let hasCustomBackgroundColor : Bool
205+ let selectedBackgroundColor : Color
206+ let hasCustomForegroundColor : Bool
207+ let selectedForegroundColor : Color
208+ let onTap : ( ) -> Void
209+
210+ var body : some View {
211+ Button ( action: onTap) {
212+ VStack ( spacing: 4 ) {
213+ ZStack {
214+ if hasCustomBackgroundColor {
215+ RoundedRectangle ( cornerRadius: 8 )
216+ . fill ( selectedBackgroundColor)
217+ . frame ( width: 40 , height: 40 )
218+ }
219+ if let iconName = iconName, let icon = Ph ( rawValue: iconName) {
220+ icon. regular
221+ . font ( . title2)
222+ . foregroundColor ( hasCustomForegroundColor ? selectedForegroundColor : . primary)
223+ } else {
224+ Image ( systemName: " folder " )
225+ . font ( . title2)
226+ . foregroundColor ( hasCustomForegroundColor ? selectedForegroundColor : . blue)
227+ }
228+ }
229+ . frame ( width: 40 , height: 40 )
230+ . overlay (
231+ RoundedRectangle ( cornerRadius: 8 )
232+ . stroke ( isSelected ? Color . blue : Color . clear, lineWidth: 2 )
233+ )
234+ }
235+ }
236+ . buttonStyle ( . plain)
237+ }
238+ }
You can’t perform that action at this time.
0 commit comments