mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
Add liquid glass to osd
This commit is contained in:
parent
8bd1d51a1a
commit
e553ccf667
5 changed files with 208 additions and 13 deletions
|
|
@ -28,6 +28,8 @@ struct CustomOSDView: View {
|
|||
@Binding var icon: String
|
||||
|
||||
@Default(.osdMaterial) var osdMaterial
|
||||
@Default(.osdLiquidGlassCustomizationMode) var osdLiquidGlassCustomizationMode
|
||||
@Default(.osdLiquidGlassVariant) var osdLiquidGlassVariant
|
||||
@Default(.osdIconColorStyle) var osdIconColorStyle
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
|
|
@ -160,11 +162,23 @@ struct CustomOSDView: View {
|
|||
.fill(.ultraThinMaterial)
|
||||
case .liquid:
|
||||
if #available(macOS 26.0, *) {
|
||||
RoundedRectangle(cornerRadius: 18, style: .continuous)
|
||||
.glassEffect(
|
||||
.clear.interactive(),
|
||||
in: .rect(cornerRadius: 18)
|
||||
)
|
||||
if osdLiquidGlassCustomizationMode == .customLiquid {
|
||||
TimelineView(.periodic(from: .now, by: 1.0 / 30.0)) { context in
|
||||
LiquidGlassBackground(
|
||||
variant: osdLiquidGlassVariant,
|
||||
cornerRadius: 18,
|
||||
trigger: context.date.timeIntervalSinceReferenceDate
|
||||
) {
|
||||
Color.white.opacity(0.04)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 18, style: .continuous)
|
||||
.glassEffect(
|
||||
.clear.interactive(),
|
||||
in: .rect(cornerRadius: 18)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
RoundedRectangle(cornerRadius: 18, style: .continuous)
|
||||
.fill(.ultraThinMaterial)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ struct VerticalHUDView: View {
|
|||
@Default(.verticalHUDHeight) var hudHeight
|
||||
@Default(.verticalHUDWidth) var hudWidth
|
||||
@Default(.verticalHUDUseAccentColor) var useAccentColor
|
||||
@Default(.verticalHUDMaterial) var verticalHUDMaterial
|
||||
@Default(.verticalHUDLiquidGlassCustomizationMode) var verticalHUDLiquidGlassCustomizationMode
|
||||
@Default(.verticalHUDLiquidGlassVariant) var verticalHUDLiquidGlassVariant
|
||||
@Default(.verticalHUDInteractive) var isInteractive
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
|
@ -68,8 +71,8 @@ struct VerticalHUDView: View {
|
|||
// The Actual HUD Pill
|
||||
ZStack {
|
||||
// Background
|
||||
Capsule()
|
||||
.fill(.ultraThinMaterial)
|
||||
verticalBackground
|
||||
.clipShape(Capsule())
|
||||
.overlay {
|
||||
Capsule()
|
||||
.stroke(.white.opacity(0.1), lineWidth: 1)
|
||||
|
|
@ -253,5 +256,42 @@ struct VerticalHUDView: View {
|
|||
}
|
||||
return .secondary
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var verticalBackground: some View {
|
||||
switch verticalHUDMaterial {
|
||||
case .frosted:
|
||||
Capsule().fill(.ultraThinMaterial)
|
||||
case .liquid:
|
||||
if #available(macOS 26.0, *) {
|
||||
if verticalHUDLiquidGlassCustomizationMode == .customLiquid {
|
||||
TimelineView(.periodic(from: .now, by: 1.0 / 30.0)) { context in
|
||||
LiquidGlassBackground(
|
||||
variant: verticalHUDLiquidGlassVariant,
|
||||
cornerRadius: max(currentWidth, hudWidth),
|
||||
trigger: context.date.timeIntervalSinceReferenceDate
|
||||
) {
|
||||
Color.white.opacity(0.04)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Capsule()
|
||||
.fill(.clear)
|
||||
.glassEffect(
|
||||
.clear.interactive(),
|
||||
in: .capsule
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Capsule().fill(.ultraThinMaterial)
|
||||
}
|
||||
case .solidDark:
|
||||
Capsule().fill(Color.black.opacity(0.85))
|
||||
case .solidLight:
|
||||
Capsule().fill(Color.white.opacity(0.85))
|
||||
case .solidAuto:
|
||||
Capsule().fill((colorScheme == .dark ? Color.black : Color.white).opacity(0.85))
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue