diff --git a/Sources/Secretive/Views/ContentView.swift b/Sources/Secretive/Views/ContentView.swift index 8bcbe0a..f84f35c 100644 --- a/Sources/Secretive/Views/ContentView.swift +++ b/Sources/Secretive/Views/ContentView.swift @@ -44,9 +44,14 @@ struct ContentView: View { extension ContentView { - - func toolbarItem(_ view: some View, id: String) -> ToolbarItem { - ToolbarItem(id: id) { view } + @ToolbarContentBuilder + func toolbarItem(_ view: some View, id: String) -> some ToolbarContent { + if #available(macOS 26.0, *) { + ToolbarItem(id: id) { view } + .sharedBackgroundVisibility(.hidden) + } else { + ToolbarItem(id: id) { view } + } } var needsSetup: Bool { diff --git a/Sources/Secretive/Views/ToolbarButtonStyle.swift b/Sources/Secretive/Views/ToolbarButtonStyle.swift index a80cde4..7dd1f65 100644 --- a/Sources/Secretive/Views/ToolbarButtonStyle.swift +++ b/Sources/Secretive/Views/ToolbarButtonStyle.swift @@ -16,22 +16,42 @@ struct ToolbarButtonStyle: ButtonStyle { self.lightColor = lightColor self.darkColor = darkColor } + + @available(macOS 26.0, *) + private var glassTint: Color { + if !hovering { + colorScheme == .light ? lightColor : darkColor + } else { + colorScheme == .light ? lightColor.exposureAdjust(1) : darkColor.exposureAdjust(1) + } + } func makeBody(configuration: Configuration) -> some View { - configuration.label - .padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8)) - .background(colorScheme == .light ? lightColor : darkColor) - .foregroundColor(.white) - .clipShape(RoundedRectangle(cornerRadius: 5)) - .overlay( - RoundedRectangle(cornerRadius: 5) - .stroke(colorScheme == .light ? .black.opacity(0.15) : .white.opacity(0.15), lineWidth: 1) - .background(hovering ? (colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.05)) : Color.clear) - ) - .onHover { hovering in - withAnimation { + if #available(macOS 26.0, *) { + configuration + .label + .foregroundColor(.white) + .padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8)) + .glassEffect(.regular.tint(glassTint), in: .capsule) + .onHover { hovering in self.hovering = hovering } - } + } else { + configuration + .label + .background(colorScheme == .light ? lightColor : darkColor) + .foregroundColor(.white) + .clipShape(RoundedRectangle(cornerRadius: 5)) + .overlay( + RoundedRectangle(cornerRadius: 5) + .stroke(colorScheme == .light ? .black.opacity(0.15) : .white.opacity(0.15), lineWidth: 1) + .background(hovering ? (colorScheme == .light ? .black.opacity(0.1) : .white.opacity(0.05)) : Color.clear) + ) + .onHover { hovering in + withAnimation { + self.hovering = hovering + } + } + } } }