mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-08-19 11:40:56 +00:00
Toolbar style (#606)
This commit is contained in:
parent
0e6b218f1f
commit
ed2678a615
@ -45,8 +45,14 @@ struct ContentView: View {
|
|||||||
extension ContentView {
|
extension ContentView {
|
||||||
|
|
||||||
|
|
||||||
func toolbarItem(_ view: some View, id: String) -> ToolbarItem<String, some View> {
|
@ToolbarContentBuilder
|
||||||
ToolbarItem(id: id) { view }
|
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 {
|
var needsSetup: Bool {
|
||||||
|
@ -17,21 +17,41 @@ struct ToolbarButtonStyle: ButtonStyle {
|
|||||||
self.darkColor = darkColor
|
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 {
|
func makeBody(configuration: Configuration) -> some View {
|
||||||
configuration.label
|
if #available(macOS 26.0, *) {
|
||||||
.padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8))
|
configuration
|
||||||
.background(colorScheme == .light ? lightColor : darkColor)
|
.label
|
||||||
.foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 5))
|
.padding(EdgeInsets(top: 6, leading: 8, bottom: 6, trailing: 8))
|
||||||
.overlay(
|
.glassEffect(.regular.tint(glassTint), in: .capsule)
|
||||||
RoundedRectangle(cornerRadius: 5)
|
.onHover { hovering in
|
||||||
.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
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user