Skip to content

Commit 09d66c7

Browse files
committed
feat: add adaptive glass row hover surfaces
1 parent a9b037f commit 09d66c7

3 files changed

Lines changed: 38 additions & 22 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import SwiftUI
2+
3+
/// Shared selection and hover surface for note and folder rows.
4+
/// Hover adopts Liquid Glass when enabled; classic mode keeps the established fills.
5+
struct PanelRowBackground: View {
6+
@Environment(AppSettings.self) private var appSettings
7+
8+
let isHovered: Bool
9+
var isSelected = false
10+
11+
private var shape: RoundedRectangle {
12+
RoundedRectangle(
13+
cornerRadius: SurfaceMetrics.panelCornerRadius,
14+
style: .continuous,
15+
)
16+
}
17+
18+
var body: some View {
19+
if #available(macOS 26.0, *), appSettings.usesLiquidGlass, isHovered {
20+
shape
21+
.fill(isSelected ? Color.accentColor.opacity(0.14) : .clear)
22+
.glassEffect(.regular.interactive(), in: shape)
23+
} else {
24+
shape.fill(classicFill)
25+
}
26+
}
27+
28+
private var classicFill: Color {
29+
if isSelected {
30+
return Color.accentColor.opacity(isHovered ? 0.28 : 0.20)
31+
}
32+
return Color.primary.opacity(isHovered ? 0.06 : 0)
33+
}
34+
}

‎EdgeMark/UI/Navigation/HomeFolderView.swift‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,7 @@ struct FolderRowView: View {
914914
.padding(.horizontal, 8)
915915
.padding(.vertical, 10)
916916
.background {
917-
RoundedRectangle(cornerRadius: 6)
918-
.fill(rowBackground)
917+
PanelRowBackground(isHovered: isHovered, isSelected: isSelected)
919918
}
920919
.padding(.horizontal, 8)
921920
.contentShape(Rectangle())
@@ -925,13 +924,6 @@ struct FolderRowView: View {
925924
}
926925
}
927926
}
928-
929-
private var rowBackground: Color {
930-
if isSelected {
931-
return Color.accentColor.opacity(isHovered ? 0.28 : 0.20)
932-
}
933-
return Color.primary.opacity(isHovered ? 0.06 : 0)
934-
}
935927
}
936928

937929
// MARK: - Note Row View
@@ -979,8 +971,7 @@ struct NoteRowView: View {
979971
.padding(.horizontal, 8)
980972
.padding(.vertical, 10)
981973
.background {
982-
RoundedRectangle(cornerRadius: 6)
983-
.fill(rowBackground)
974+
PanelRowBackground(isHovered: isHovered, isSelected: isSelected)
984975
}
985976
.padding(.horizontal, 8)
986977
.contentShape(Rectangle())
@@ -990,11 +981,4 @@ struct NoteRowView: View {
990981
}
991982
}
992983
}
993-
994-
private var rowBackground: Color {
995-
if isSelected {
996-
return Color.accentColor.opacity(isHovered ? 0.28 : 0.20)
997-
}
998-
return Color.primary.opacity(isHovered ? 0.06 : 0)
999-
}
1000984
}

‎EdgeMark/UI/Navigation/TrashView.swift‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ private struct TrashedNoteRowView: View {
585585
.padding(.horizontal, 8)
586586
.padding(.vertical, 10)
587587
.background {
588-
RoundedRectangle(cornerRadius: 6)
589-
.fill(.primary.opacity(isHovered ? 0.06 : 0))
588+
PanelRowBackground(isHovered: isHovered)
590589
}
591590
.padding(.horizontal, 8)
592591
.contentShape(Rectangle())
@@ -667,8 +666,7 @@ private struct TrashedFolderRowView: View {
667666
.padding(.horizontal, 8)
668667
.padding(.vertical, 10)
669668
.background {
670-
RoundedRectangle(cornerRadius: 6)
671-
.fill(.primary.opacity(isHovered ? 0.06 : 0))
669+
PanelRowBackground(isHovered: isHovered)
672670
}
673671
.padding(.horizontal, 8)
674672
.contentShape(Rectangle())

0 commit comments

Comments
 (0)