Skip to content

Commit 9239171

Browse files
committed
feat: adopt liquid glass for panel controls
1 parent 2c2d1f7 commit 9239171

8 files changed

Lines changed: 185 additions & 135 deletions

File tree

‎EdgeMark/UI/Components/GlassControlGroup.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct GlassControlGroup<Content: View>: View {
77
private let content: Content
88

99
init(
10-
spacing: CGFloat? = SurfaceMetrics.controlGroupSpacing,
10+
spacing: CGFloat? = 0,
1111
@ViewBuilder content: () -> Content,
1212
) {
1313
self.spacing = spacing
Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,73 @@
11
import SwiftUI
22

3-
/// Toolbar icon with hover background animation.
3+
/// Toolbar icon that adopts native Liquid Glass when available and preserves
4+
/// EdgeMark's established hover treatment on older macOS releases.
45
struct HeaderIconButton: View {
56
let systemName: String
67
let help: String
8+
var role: ButtonRole?
9+
let action: () -> Void
10+
11+
var body: some View {
12+
AdaptiveIconButton(systemName: systemName, help: help, role: role, action: action)
13+
}
14+
}
15+
16+
/// Shared rendering boundary for icon-only controls used throughout panel chrome.
17+
struct AdaptiveIconButton: View {
18+
let systemName: String
19+
let help: String
20+
var isActive = false
21+
var role: ButtonRole?
722
let action: () -> Void
823

924
@State private var isHovered = false
1025

1126
var body: some View {
12-
Button(action: action) {
13-
Image(systemName: systemName)
14-
.font(.system(size: 16, weight: .medium))
15-
.foregroundStyle(isHovered ? .primary : .secondary)
16-
.frame(width: 28, height: 28)
17-
.background {
18-
RoundedRectangle(cornerRadius: 6)
19-
.fill(.primary.opacity(isHovered ? 0.1 : 0))
27+
if #available(macOS 26.0, *) {
28+
Button(role: role, action: action) {
29+
iconLabel(isHovered: false)
30+
}
31+
.buttonStyle(.glass)
32+
.help(help)
33+
.accessibilityLabel(help)
34+
} else {
35+
Button(role: role, action: action) {
36+
iconLabel(isHovered: isHovered)
37+
.background {
38+
RoundedRectangle(cornerRadius: SurfaceMetrics.compactControlCornerRadius)
39+
.fill(.primary.opacity(isHovered ? 0.1 : 0))
40+
}
41+
}
42+
.buttonStyle(.plain)
43+
.help(help)
44+
.accessibilityLabel(help)
45+
.onHover { hovering in
46+
withAnimation(.easeInOut(duration: 0.15)) {
47+
isHovered = hovering
2048
}
21-
.contentShape(Rectangle())
22-
}
23-
.buttonStyle(.plain)
24-
.help(help)
25-
.onHover { hovering in
26-
withAnimation(.easeInOut(duration: 0.15)) {
27-
isHovered = hovering
2849
}
2950
}
3051
}
52+
53+
private func iconLabel(isHovered: Bool) -> some View {
54+
Image(systemName: systemName)
55+
.font(.system(size: SurfaceMetrics.compactSymbolSize, weight: .medium))
56+
.foregroundStyle(foregroundColor(isHovered: isHovered))
57+
.frame(
58+
width: SurfaceMetrics.compactControlSize,
59+
height: SurfaceMetrics.compactControlSize,
60+
)
61+
.contentShape(Rectangle())
62+
}
63+
64+
private func foregroundColor(isHovered: Bool) -> Color {
65+
if isActive {
66+
return .accentColor
67+
}
68+
if role == .destructive, isHovered {
69+
return .red
70+
}
71+
return isHovered ? .primary : .secondary
72+
}
3173
}

‎EdgeMark/UI/Components/PinButton.swift‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,21 @@ import SwiftUI
66
struct PinButton: View {
77
@Environment(L10n.self) private var l10n
88
@State private var isPinned: Bool = PanelSettings.shared.isPanelPinned
9-
@State private var isHovered = false
109
/// Pinning is implicit in Edge-toggle mode (the panel sticks until the
1110
/// activating edge is re-touched), so the button is redundant there.
1211
@State private var isVisible: Bool = PanelSettings.shared.dismissalMode != .toggle
1312

1413
var body: some View {
15-
Button {
14+
AdaptiveIconButton(
15+
systemName: isPinned ? "pin.fill" : "pin",
16+
help: isPinned ? l10n["common.unpin"] : l10n["common.pin"],
17+
isActive: isPinned,
18+
) {
1619
isPinned.toggle()
1720
PanelSettings.shared.isPanelPinned = isPinned
18-
} label: {
19-
Image(systemName: isPinned ? "pin.fill" : "pin")
20-
.font(.system(size: 16, weight: .medium))
21-
.foregroundStyle(isPinned ? Color.accentColor : (isHovered ? .primary : .secondary))
22-
.frame(width: 28, height: 28)
23-
.background {
24-
RoundedRectangle(cornerRadius: 6)
25-
.fill(.primary.opacity(isHovered ? 0.1 : 0))
26-
}
27-
.contentShape(Rectangle())
2821
}
29-
.buttonStyle(.plain)
3022
.opacity(isVisible ? 1 : 0)
3123
.allowsHitTesting(isVisible)
32-
.help(isPinned ? l10n["common.unpin"] : l10n["common.pin"])
33-
.onHover { hovering in
34-
withAnimation(.easeInOut(duration: 0.15)) {
35-
isHovered = hovering
36-
}
37-
}
3824
.onReceive(NotificationCenter.default.publisher(for: .panelPinStateChanged)) { _ in
3925
// Keep the icon in sync when pin is toggled by the Cmd-P shortcut
4026
// (or any path other than this button's own tap).

‎EdgeMark/UI/Components/TagFilterBar.swift‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@ struct TagFilterBar: View {
2020
.help(appSettings.label(for: tag))
2121
}
2222
if !noteStore.activeTagFilter.isEmpty {
23-
Button {
23+
AdaptiveIconButton(
24+
systemName: "xmark.circle.fill",
25+
help: l10n["tags.clearFilter"],
26+
) {
2427
noteStore.clearTagFilter()
25-
} label: {
26-
Image(systemName: "xmark.circle.fill")
27-
.font(.system(size: 12))
28-
.foregroundStyle(.secondary)
2928
}
30-
.buttonStyle(.plain)
31-
.help(l10n["tags.clearFilter"])
3229
}
3330
}
3431
.padding(.horizontal, 12)

‎EdgeMark/UI/EditorScreen.swift‎

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,14 @@ struct EditorScreen: View {
109109

110110
PinButton()
111111

112-
CopyMenuButton(note: note)
112+
GlassControlGroup {
113+
HStack(spacing: SurfaceMetrics.controlGroupSpacing) {
114+
CopyMenuButton(note: note)
113115

114-
DeleteIconButton {
115-
showDeleteConfirm = true
116+
DeleteIconButton {
117+
showDeleteConfirm = true
118+
}
119+
}
116120
}
117121
}
118122

@@ -148,8 +152,33 @@ private struct CopyMenuButton: View {
148152
@State private var isHovered = false
149153

150154
var body: some View {
155+
if #available(macOS 26.0, *) {
156+
menu
157+
.menuStyle(.button)
158+
.buttonStyle(.glass)
159+
.menuIndicator(.hidden)
160+
.fixedSize()
161+
.help(L10n.shared["editor.copyNote"])
162+
.accessibilityLabel(L10n.shared["editor.copyNote"])
163+
} else {
164+
menu
165+
.menuStyle(.button)
166+
.buttonStyle(.plain)
167+
.menuIndicator(.hidden)
168+
.fixedSize()
169+
.help(L10n.shared["editor.copyNote"])
170+
.accessibilityLabel(L10n.shared["editor.copyNote"])
171+
.onHover { hovering in
172+
withAnimation(.easeInOut(duration: 0.15)) {
173+
isHovered = hovering
174+
}
175+
}
176+
}
177+
}
178+
179+
private var menu: some View {
151180
let l10n = L10n.shared
152-
Menu {
181+
return Menu {
153182
Button(l10n["common.copyPlainText"]) {
154183
let selected = Self.getSelectedText()
155184
let source = selected.isEmpty ? note.content : selected
@@ -175,24 +204,20 @@ private struct CopyMenuButton: View {
175204
}
176205
} label: {
177206
Image(systemName: "doc.on.doc")
178-
.font(.system(size: 14, weight: .medium))
207+
.font(.system(size: SurfaceMetrics.compactSymbolSize, weight: .medium))
179208
.foregroundStyle(isHovered ? .primary : .secondary)
180-
.frame(width: 28, height: 28)
209+
.frame(
210+
width: SurfaceMetrics.compactControlSize,
211+
height: SurfaceMetrics.compactControlSize,
212+
)
181213
.background {
182-
RoundedRectangle(cornerRadius: 6)
183-
.fill(.primary.opacity(isHovered ? 0.1 : 0))
214+
if #unavailable(macOS 26.0) {
215+
RoundedRectangle(cornerRadius: SurfaceMetrics.compactControlCornerRadius)
216+
.fill(.primary.opacity(isHovered ? 0.1 : 0))
217+
}
184218
}
185219
.contentShape(Rectangle())
186220
}
187-
.menuStyle(.borderlessButton)
188-
.menuIndicator(.hidden)
189-
.fixedSize()
190-
.help(l10n["editor.copyNote"])
191-
.onHover { hovering in
192-
withAnimation(.easeInOut(duration: 0.15)) {
193-
isHovered = hovering
194-
}
195-
}
196221
}
197222

198223
private static func getSelectedText() -> String {
@@ -209,27 +234,13 @@ private struct CopyMenuButton: View {
209234
private struct DeleteIconButton: View {
210235
let action: () -> Void
211236

212-
@State private var isHovered = false
213-
214237
var body: some View {
215-
Button(action: action) {
216-
Image(systemName: "trash")
217-
.font(.system(size: 14, weight: .medium))
218-
.foregroundStyle(isHovered ? .red : .secondary)
219-
.frame(width: 28, height: 28)
220-
.background {
221-
RoundedRectangle(cornerRadius: 6)
222-
.fill(.primary.opacity(isHovered ? 0.1 : 0))
223-
}
224-
.contentShape(Rectangle())
225-
}
226-
.buttonStyle(.plain)
227-
.help(L10n.shared["editor.deleteNote"])
228-
.onHover { hovering in
229-
withAnimation(.easeInOut(duration: 0.15)) {
230-
isHovered = hovering
231-
}
232-
}
238+
AdaptiveIconButton(
239+
systemName: "trash",
240+
help: L10n.shared["editor.deleteNote"],
241+
role: .destructive,
242+
action: action,
243+
)
233244
}
234245
}
235246

‎EdgeMark/UI/Navigation/HomeFolderView.swift‎

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ struct HomeFolderView: View {
221221
.textFieldStyle(.plain)
222222
.focused($isSearchFieldFocused)
223223

224-
Button(action: dismissSearch) {
225-
Image(systemName: "xmark.circle.fill")
226-
.foregroundStyle(.secondary)
224+
AdaptiveIconButton(
225+
systemName: "xmark.circle.fill",
226+
help: l10n["search.close"],
227+
) {
228+
dismissSearch()
227229
}
228-
.buttonStyle(.borderless)
229-
.help(l10n["search.close"])
230230
}
231231
.onExitCommand { dismissSearch() }
232232
.opacity(isSearching && !noteStore.awaitingRootChoice ? 1 : 0)
@@ -241,26 +241,30 @@ struct HomeFolderView: View {
241241

242242
PinButton()
243243

244-
HeaderIconButton(
245-
systemName: "magnifyingglass",
246-
help: l10n["common.search"],
247-
) {
248-
isSearching = true
249-
isSearchFieldFocused = true
250-
}
244+
GlassControlGroup {
245+
HStack(spacing: SurfaceMetrics.controlGroupSpacing) {
246+
HeaderIconButton(
247+
systemName: "magnifyingglass",
248+
help: l10n["common.search"],
249+
) {
250+
isSearching = true
251+
isSearchFieldFocused = true
252+
}
251253

252-
HeaderIconButton(
253-
systemName: "folder.badge.plus",
254-
help: l10n["common.newFolder"],
255-
) {
256-
startCreatingFolder()
257-
}
254+
HeaderIconButton(
255+
systemName: "folder.badge.plus",
256+
help: l10n["common.newFolder"],
257+
) {
258+
startCreatingFolder()
259+
}
258260

259-
HeaderIconButton(
260-
systemName: "square.and.pencil",
261-
help: l10n["common.newNote"],
262-
) {
263-
createRootNote()
261+
HeaderIconButton(
262+
systemName: "square.and.pencil",
263+
help: l10n["common.newNote"],
264+
) {
265+
createRootNote()
266+
}
267+
}
264268
}
265269
}
266270
.opacity(!isSearching && !noteStore.awaitingRootChoice ? 1 : 0)

‎EdgeMark/UI/Navigation/NoteListView.swift‎

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,31 @@ struct NoteListView: View {
9393

9494
PinButton()
9595

96-
HeaderIconButton(
97-
systemName: "magnifyingglass",
98-
help: l10n["common.search"],
99-
) {
100-
noteStore.searchReturnFolder = noteStore.selectedFolder
101-
noteStore.pendingSearchOnHome = true
102-
noteStore.navigateToHome()
103-
}
96+
GlassControlGroup {
97+
HStack(spacing: SurfaceMetrics.controlGroupSpacing) {
98+
HeaderIconButton(
99+
systemName: "magnifyingglass",
100+
help: l10n["common.search"],
101+
) {
102+
noteStore.searchReturnFolder = noteStore.selectedFolder
103+
noteStore.pendingSearchOnHome = true
104+
noteStore.navigateToHome()
105+
}
104106

105-
HeaderIconButton(
106-
systemName: "folder.badge.plus",
107-
help: l10n["common.newFolder"],
108-
) {
109-
startCreatingFolder()
110-
}
107+
HeaderIconButton(
108+
systemName: "folder.badge.plus",
109+
help: l10n["common.newFolder"],
110+
) {
111+
startCreatingFolder()
112+
}
111113

112-
HeaderIconButton(
113-
systemName: "square.and.pencil",
114-
help: l10n["common.newNote"],
115-
) {
116-
createNote()
114+
HeaderIconButton(
115+
systemName: "square.and.pencil",
116+
help: l10n["common.newNote"],
117+
) {
118+
createNote()
119+
}
120+
}
117121
}
118122
}
119123
} content: {

0 commit comments

Comments
 (0)