mac app cylon animation
This commit is contained in:
@@ -557,20 +557,24 @@ private struct TranscriptScroll: View {
|
|||||||
|
|
||||||
private struct Scanner: View {
|
private struct Scanner: View {
|
||||||
let color: Color
|
let color: Color
|
||||||
@ViewState private var phase = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Capsule()
|
TimelineView(.animation) { context in
|
||||||
.fill(LinearGradient(colors: [.clear, color, .clear], startPoint: .leading, endPoint: .trailing))
|
Canvas { gc, _ in
|
||||||
.frame(width: 30, height: 2)
|
let t = context.date.timeIntervalSinceReferenceDate.truncatingRemainder(dividingBy: 2.4) / 1.2
|
||||||
.offset(x: phase ? 54 : 0)
|
let leg = t < 1 ? t : 2 - t
|
||||||
.animation(.easeInOut(duration: 1.2).repeatForever(autoreverses: true), value: phase)
|
let center = 15 + 54 * (1 - cos(.pi * leg)) / 2
|
||||||
.frame(width: 84, height: 2, alignment: .leading)
|
for x in stride(from: 0.0, through: 80, by: 5) {
|
||||||
.onAppear {
|
let alpha = max(0, 1 - abs(x + 1 - center) / 15)
|
||||||
phase = true
|
if alpha > 0 {
|
||||||
|
gc.fill(Path(CGRect(x: x, y: 0, width: 2, height: 2)), with: .color(color.opacity(alpha)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.frame(width: 84, height: 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private struct PendingView: View {
|
private struct PendingView: View {
|
||||||
let pending: PendingSend
|
let pending: PendingSend
|
||||||
|
|||||||
Reference in New Issue
Block a user