Skip to content

Open source CapCut alternative.

TypeScript

feat(app): show a faint elapsed timer under the spawn label

David Le45604d1a905c
diff --git a/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift b/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift
index 4f3f68c3..66a88f46 100644
--- a/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift
+++ b/apps/Donkey/Sources/DonkeyContracts/UserQuerySpawnContracts.swift
@@ -39,6 +39,7 @@ public struct UserQuerySpawnState: Codable, Equatable, Identifiable, Sendable {
public var phase: UserQuerySpawnPhase
public var notchCueAngleDegrees: Double
public var targetHint: UserQuerySpawnTargetHint?
+ public var createdAt: Date
public var updatedAt: Date
public init(
@@ -50,6 +51,7 @@ public struct UserQuerySpawnState: Codable, Equatable, Identifiable, Sendable {
phase: UserQuerySpawnPhase = .notchCue,
notchCueAngleDegrees: Double = UserQuerySpawnGeometry.defaultExitAngleDegrees,
targetHint: UserQuerySpawnTargetHint? = nil,
+ createdAt: Date = Date(),
updatedAt: Date = Date()
) {
self.id = id
@@ -60,6 +62,7 @@ public struct UserQuerySpawnState: Codable, Equatable, Identifiable, Sendable {
self.phase = phase
self.notchCueAngleDegrees = notchCueAngleDegrees
self.targetHint = targetHint
+ self.createdAt = createdAt
self.updatedAt = updatedAt
}
}
diff --git a/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift b/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift
index 40da93ef..31567512 100644
--- a/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift
+++ b/apps/Donkey/Sources/DonkeyUI/UserQuerySpawnOverlayView.swift
@@ -828,6 +828,31 @@ public struct UserQuerySpawnOverlayView: View {
}
.animation(.easeOut(duration: 0.12), value: showsDismissButton)
}
+ .overlay(alignment: .bottomTrailing) {
+ if !viewModel.isLabelEditing {
+ elapsedTimer(since: state.createdAt)
+ .offset(
+ x: -UserQuerySpawnOverlayViewModel.labelHorizontalPadding,
+ y: 16
+ )
+ }
+ }
+ }
+
+ /// A faint count-up timer hanging below the label bubble. It floats over
+ /// arbitrary screen content, so legibility on both light and dark
+ /// backgrounds comes from white text with a soft dark shadow rather than
+ /// from color-scheme adaptation.
+ private func elapsedTimer(since start: Date) -> some View {
+ TimelineView(.periodic(from: start, by: 1)) { context in
+ Text(UserQueryNotchStatusView.elapsedDescription(from: start, to: context.date))
+ .font(.system(size: 9, weight: .medium).monospacedDigit())
+ .foregroundStyle(Color.white.opacity(0.62))
+ .shadow(color: Color.black.opacity(0.55), radius: 1.5, x: 0, y: 0.5)
+ .lineLimit(1)
+ .fixedSize()
+ }
+ .allowsHitTesting(false)
}
private var showsDismissButton: Bool {