mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Update for frame resampling using TimelineView, but locks at 120FPS
This commit is contained in:
parent
a3a80ca3d4
commit
5990fbac06
4 changed files with 25 additions and 9 deletions
|
|
@ -114,8 +114,10 @@ struct ExtensionLockScreenWidgetView: View {
|
|||
|
||||
@ViewBuilder
|
||||
private func liquidGlassBackground(shape: RoundedRectangle) -> some View {
|
||||
LiquidGlassBackground(variant: requestedLiquidGlassVariant, cornerRadius: descriptor.cornerRadius) {
|
||||
Color.black.opacity(0.08)
|
||||
TimelineView(.animation) { context in
|
||||
LiquidGlassBackground(variant: requestedLiquidGlassVariant, cornerRadius: descriptor.cornerRadius, trigger: context.date.timeIntervalSinceReferenceDate) {
|
||||
Color.black.opacity(0.08)
|
||||
}
|
||||
}
|
||||
.overlay {
|
||||
tintOverlay(shape: shape)
|
||||
|
|
|
|||
|
|
@ -781,8 +781,10 @@ struct LockScreenMusicPanel: View {
|
|||
|
||||
@ViewBuilder
|
||||
private var customLiquidPanelBackdrop: some View {
|
||||
LiquidGlassBackground(variant: musicGlassVariant, cornerRadius: panelCornerRadius) {
|
||||
Color.white.opacity(0.04)
|
||||
TimelineView(.animation) { context in
|
||||
LiquidGlassBackground(variant: musicGlassVariant, cornerRadius: panelCornerRadius, trigger: context.date.timeIntervalSinceReferenceDate) {
|
||||
Color.white.opacity(0.04)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.allowsHitTesting(false)
|
||||
|
|
@ -860,8 +862,10 @@ struct LockScreenMusicPanel: View {
|
|||
|
||||
@ViewBuilder
|
||||
private func customLiquidAlbumArtBackground(cornerRadius: CGFloat) -> some View {
|
||||
LiquidGlassBackground(variant: musicGlassVariant, cornerRadius: cornerRadius) {
|
||||
Color.clear
|
||||
TimelineView(.animation) { context in
|
||||
LiquidGlassBackground(variant: musicGlassVariant, cornerRadius: cornerRadius, trigger: context.date.timeIntervalSinceReferenceDate) {
|
||||
Color.clear
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,8 +136,10 @@ struct LockScreenTimerWidget: View {
|
|||
}
|
||||
|
||||
private var customLiquidBackground: some View {
|
||||
LiquidGlassBackground(variant: timerGlassVariant, cornerRadius: Self.cornerRadius) {
|
||||
Color.black.opacity(0.12)
|
||||
TimelineView(.animation) { context in
|
||||
LiquidGlassBackground(variant: timerGlassVariant, cornerRadius: Self.cornerRadius, trigger: context.date.timeIntervalSinceReferenceDate) {
|
||||
Color.black.opacity(0.12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public struct LiquidGlassBackground<Content: View>: NSViewRepresentable {
|
|||
private let content: Content
|
||||
private let cornerRadius: CGFloat
|
||||
private let variant: LiquidGlassVariant
|
||||
|
||||
private let trigger: Double
|
||||
/// Creates a new liquid‑glass container.
|
||||
/// - Parameters:
|
||||
/// - variant: Any ``LiquidGlassVariant`` (0–19). Defaults to `.v11`, which is visually super pleasing
|
||||
|
|
@ -53,10 +53,12 @@ public struct LiquidGlassBackground<Content: View>: NSViewRepresentable {
|
|||
public init(
|
||||
variant: LiquidGlassVariant = .defaultVariant,
|
||||
cornerRadius: CGFloat = 10,
|
||||
trigger: Double = 0,
|
||||
@ViewBuilder content: () -> Content
|
||||
) {
|
||||
self.variant = variant
|
||||
self.cornerRadius = cornerRadius
|
||||
self.trigger = trigger
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
|
|
@ -130,5 +132,11 @@ public struct LiquidGlassBackground<Content: View>: NSViewRepresentable {
|
|||
}
|
||||
nsView.setValue(cornerRadius, forKey: "cornerRadius")
|
||||
callPrivateVariantSetter(on: nsView, value: variant.rawValue)
|
||||
|
||||
// Micro-jitter: imperceptibly adjust opacity so WindowServer re-samples the wallpaper every frame.
|
||||
let jitter = sin(trigger * 100) * 0.000001
|
||||
nsView.alphaValue = 1.0 - CGFloat(abs(jitter))
|
||||
|
||||
nsView.needsDisplay = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue