Skip to content

Commit 1fff3be

Browse files
committed
moving stuff around
1 parent 430ae37 commit 1fff3be

File tree

6 files changed

+74
-79
lines changed

6 files changed

+74
-79
lines changed

Flitro/Sidebar/BackgroundColorPanelCoordinator.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

Flitro/Sidebar/ColorPanelCoordinator.swift

Lines changed: 0 additions & 26 deletions
This file was deleted.

Flitro/Sidebar/ColorSelectionSection.swift

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import SwiftUI
2+
import AppKit
23

34
struct 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+
}

Flitro/Sidebar/ForegroundColorPanelCoordinator.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

Flitro/Sidebar/IconGridItem.swift

Lines changed: 0 additions & 41 deletions
This file was deleted.

Flitro/Sidebar/IconSelectorView.swift

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)