fix(mac): stop critter animation when paused

This commit is contained in:
Peter Steinberger
2025-12-06 01:29:53 +01:00
parent c545ec727c
commit b508ab240f
2 changed files with 34 additions and 41 deletions

View File

@@ -429,6 +429,11 @@ private struct CritterStatusLabel: View {
private let ticker = Timer.publish(every: 0.35, on: .main, in: .common).autoconnect() private let ticker = Timer.publish(every: 0.35, on: .main, in: .common).autoconnect()
var body: some View { var body: some View {
Group {
if isPaused {
Image(nsImage: CritterIconRenderer.makeIcon(blink: 0))
.frame(width: 18, height: 16)
} else {
Image(nsImage: CritterIconRenderer.makeIcon( Image(nsImage: CritterIconRenderer.makeIcon(
blink: blinkAmount, blink: blinkAmount,
legWiggle: legWiggle, legWiggle: legWiggle,
@@ -438,11 +443,6 @@ private struct CritterStatusLabel: View {
.rotationEffect(.degrees(wiggleAngle), anchor: .center) .rotationEffect(.degrees(wiggleAngle), anchor: .center)
.offset(x: wiggleOffset) .offset(x: wiggleOffset)
.onReceive(ticker) { now in .onReceive(ticker) { now in
guard !isPaused else {
resetMotion()
return
}
if now >= nextBlink { if now >= nextBlink {
blink() blink()
nextBlink = now.addingTimeInterval(Double.random(in: 3.5 ... 8.5)) nextBlink = now.addingTimeInterval(Double.random(in: 3.5 ... 8.5))
@@ -463,14 +463,7 @@ private struct CritterStatusLabel: View {
nextEarWiggle = now.addingTimeInterval(Double.random(in: 7.0 ... 14.0)) nextEarWiggle = now.addingTimeInterval(Double.random(in: 7.0 ... 14.0))
} }
} }
.onChange(of: isPaused) { _, paused in .onChange(of: isPaused) { _, _ in resetMotion() }
if paused {
resetMotion()
} else {
nextBlink = Date().addingTimeInterval(Double.random(in: 1.5 ... 3.5))
nextWiggle = Date().addingTimeInterval(Double.random(in: 4.5 ... 9.5))
nextLegWiggle = Date().addingTimeInterval(Double.random(in: 4.0 ... 8.0))
nextEarWiggle = Date().addingTimeInterval(Double.random(in: 5.5 ... 10.5))
} }
} }
} }

View File

@@ -44,7 +44,7 @@ log "==> Killing existing Clawdis instances"
kill_all_clawdis kill_all_clawdis
# 2) Rebuild into the same path the packager consumes (.build). # 2) Rebuild into the same path the packager consumes (.build).
run_step "clean build cache" bash -lc "rm -rf '${ROOT_DIR}/apps/macos/.build'" run_step "clean build cache" bash -lc "cd '${ROOT_DIR}/apps/macos' && rm -rf .build .build-swift .swiftpm"
run_step "swift build" bash -lc "cd '${ROOT_DIR}/apps/macos' && swift build -q --product Clawdis" run_step "swift build" bash -lc "cd '${ROOT_DIR}/apps/macos' && swift build -q --product Clawdis"
# 3) Package + relaunch the app (script also stops any stragglers). # 3) Package + relaunch the app (script also stops any stragglers).