Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

fix(overlay): shimmer status and flatten visualizer

altic-devb98cef0ae5ca
diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swift
index d6811289..8c9e547b 100644
--- a/Sources/Fluid/Views/BottomOverlayView.swift
+++ b/Sources/Fluid/Views/BottomOverlayView.swift
@@ -393,9 +393,11 @@ struct BottomOverlayView: View {
.lineLimit(1)
.truncationMode(.head)
} else if self.contentState.isProcessing {
- Text(self.processingStatusText)
- .font(.system(size: self.layout.transFontSize, weight: .medium))
- .foregroundStyle(self.modeColor.opacity(0.8))
+ ShimmerText(
+ text: self.processingStatusText,
+ color: self.modeColor,
+ font: .system(size: self.layout.transFontSize, weight: .medium)
+ )
}
}
.frame(maxWidth: self.layout.waveformWidth * 2.2, minHeight: self.hasTranscription || self.contentState.isProcessing ? self.layout.transFontSize * 1.5 : 0)
@@ -521,8 +523,6 @@ struct BottomWaveformView: View {
@ObservedObject private var contentState = NotchContentState.shared
// Initialize with max possible bar count (11 for large) to prevent index-out-of-range before onAppear
@State private var barHeights: [CGFloat] = Array(repeating: 6, count: 11)
- @State private var glowPhase: CGFloat = 0
- @State private var glowTimer: Timer? = nil
@State private var noiseThreshold: CGFloat = .init(SettingsStore.shared.visualizerNoiseThreshold)
private var barCount: Int { self.layout.barCount }
@@ -532,11 +532,11 @@ struct BottomWaveformView: View {
private var maxHeight: CGFloat { self.layout.maxBarHeight }
private var currentGlowIntensity: CGFloat {
- self.contentState.isProcessing ? 0.6 + 0.3 * sin(self.glowPhase * .pi * 2) : 0.5
+ self.contentState.isProcessing ? 0.0 : 0.5
}
private var currentGlowRadius: CGFloat {
- self.contentState.isProcessing ? 5 + 7 * sin(self.glowPhase * .pi * 2) : 4
+ self.contentState.isProcessing ? 0.0 : 4
}
/// Safe accessor for bar heights to prevent index-out-of-range crashes
@@ -563,10 +563,10 @@ struct BottomWaveformView: View {
}
.onChange(of: self.contentState.isProcessing) { _, processing in
if processing {
- self.setStaticProcessingBars()
- self.startGlowAnimation()
+ self.setFlatProcessingBars()
} else {
- self.stopGlowAnimation()
+ // Resume from silence; next audio tick will animate up.
+ self.updateBars(level: 0)
}
}
.onChange(of: self.layout.barCount) { _, newCount in
@@ -578,14 +578,13 @@ struct BottomWaveformView: View {
self.barHeights = Array(repeating: self.minHeight, count: self.barCount)
}
if self.contentState.isProcessing {
- self.setStaticProcessingBars()
- self.startGlowAnimation()
+ self.setFlatProcessingBars()
} else {
self.updateBars(level: 0)
}
}
.onDisappear {
- self.stopGlowAnimation()
+ // No timers to clean up.
}
.onReceive(NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)) { _ in
// Update threshold when user changes sensitivity setting
@@ -596,35 +595,14 @@ struct BottomWaveformView: View {
}
}
- private func startGlowAnimation() {
- self.stopGlowAnimation()
- self.glowPhase = 0
-
- self.glowTimer = Timer.scheduledTimer(withTimeInterval: 1.0 / 30.0, repeats: true) { _ in
- withAnimation(.linear(duration: 1.0 / 30.0)) {
- self.glowPhase += 1.0 / 30.0 / 1.5
- if self.glowPhase >= 1.0 {
- self.glowPhase = 0
- }
- }
- }
- }
-
- private func stopGlowAnimation() {
- self.glowTimer?.invalidate()
- self.glowTimer = nil
- self.glowPhase = 0
- }
-
- private func setStaticProcessingBars() {
+ private func setFlatProcessingBars() {
// Ensure array is properly sized before modifying
guard self.barHeights.count >= self.barCount else { return }
- withAnimation(.easeInOut(duration: 0.3)) {
+ // During AI processing we want the visualizer to settle to silence (flat).
+ withAnimation(.easeOut(duration: 0.18)) {
for i in 0..<self.barCount {
- let centerDistance = abs(CGFloat(i) - CGFloat(self.barCount - 1) / 2)
- let centerFactor = 1.0 - (centerDistance / CGFloat(self.barCount / 2)) * 0.35
- self.barHeights[i] = self.minHeight + (self.maxHeight - self.minHeight) * 0.5 * centerFactor
+ self.barHeights[i] = self.minHeight
}
}
}
diff --git a/Sources/Fluid/Views/NotchContentViews.swift b/Sources/Fluid/Views/NotchContentViews.swift
index 819cadf9..558dbb76 100644
--- a/Sources/Fluid/Views/NotchContentViews.swift
+++ b/Sources/Fluid/Views/NotchContentViews.swift
@@ -201,30 +201,36 @@ extension OverlayMode {
struct ShimmerText: View {
let text: String
let color: Color
+ var font: Font = .system(size: 9, weight: .medium)
- @State private var shimmerPhase: CGFloat = 0
+ /// Seconds per shimmer sweep.
+ /// Lower is faster.
+ private let periodSeconds: Double = 0.85
+ private let bandHalfWidth: CGFloat = 0.32
var body: some View {
- Text(self.text)
- .font(.system(size: 9, weight: .medium))
- .foregroundStyle(
- LinearGradient(
- colors: [
- self.color.opacity(0.4),
- self.color.opacity(0.4),
- self.color.opacity(1.0),
- self.color.opacity(0.4),
- self.color.opacity(0.4),
- ],
- startPoint: UnitPoint(x: self.shimmerPhase - 0.3, y: 0.5),
- endPoint: UnitPoint(x: self.shimmerPhase + 0.3, y: 0.5)
+ TimelineView(.animation(minimumInterval: 1.0 / 30.0)) { timeline in
+ let t = timeline.date.timeIntervalSinceReferenceDate
+ let progress = (t / self.periodSeconds).truncatingRemainder(dividingBy: 1.0)
+ // Sweep from slightly before to slightly after to avoid hard edges.
+ let centerX = CGFloat(-0.25 + progress * 1.5) // -0.25 -> 1.25
+
+ Text(self.text)
+ .font(self.font)
+ .foregroundStyle(
+ LinearGradient(
+ colors: [
+ self.color.opacity(0.35),
+ self.color.opacity(0.35),
+ self.color.opacity(1.0),
+ self.color.opacity(0.35),
+ self.color.opacity(0.35),
+ ],
+ startPoint: UnitPoint(x: centerX - self.bandHalfWidth, y: 0.5),
+ endPoint: UnitPoint(x: centerX + self.bandHalfWidth, y: 0.5)
+ )
)
- )
- .onAppear {
- withAnimation(.linear(duration: 1.2).repeatForever(autoreverses: false)) {
- self.shimmerPhase = 1.3
- }
- }
+ }
}
}
@@ -459,8 +465,6 @@ struct NotchWaveformView: View {
@StateObject private var data: AudioVisualizationData
@ObservedObject private var contentState = NotchContentState.shared
@State private var barHeights: [CGFloat] = Array(repeating: 3, count: 7)
- @State private var glowPhase: CGFloat = 0 // 0 to 1, controls glow intensity
- @State private var glowTimer: Timer? = nil
@State private var noiseThreshold: CGFloat = .init(SettingsStore.shared.visualizerNoiseThreshold)
private let barCount = 7
@@ -469,17 +473,16 @@ struct NotchWaveformView: View {
private let minHeight: CGFloat = 3
private let maxHeight: CGFloat = 20
- // Computed glow values based on phase (sine wave for smooth pulsing)
private var currentGlowIntensity: CGFloat {
- self.contentState.isProcessing ? 0.35 + 0.25 * sin(self.glowPhase * .pi * 2) : 0.35
+ self.contentState.isProcessing ? 0.0 : 0.35
}
private var currentGlowRadius: CGFloat {
- self.contentState.isProcessing ? 1 + 3 * sin(self.glowPhase * .pi * 2) : 1.5
+ self.contentState.isProcessing ? 0.0 : 1.5
}
private var currentOuterGlowRadius: CGFloat {
- self.contentState.isProcessing ? 4 * sin(self.glowPhase * .pi * 2) : 0
+ 0
}
init(audioPublisher: AnyPublisher<CGFloat, Never>, color: Color, isProcessing: Bool = false) {
@@ -505,22 +508,21 @@ struct NotchWaveformView: View {
}
.onChange(of: self.contentState.isProcessing) { _, processing in
if processing {
- self.setStaticProcessingBars()
- self.startGlowAnimation()
+ self.setFlatProcessingBars()
} else {
- self.stopGlowAnimation()
+ // Resume from silence; next audio tick will animate up.
+ self.updateBars(level: 0)
}
}
.onAppear {
if self.contentState.isProcessing {
- self.setStaticProcessingBars()
- self.startGlowAnimation()
+ self.setFlatProcessingBars()
} else {
self.updateBars(level: 0)
}
}
.onDisappear {
- self.stopGlowAnimation()
+ // No timers to clean up.
}
.onReceive(NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)) { _ in
// Update threshold when user changes sensitivity setting
@@ -531,34 +533,11 @@ struct NotchWaveformView: View {
}
}
- private func startGlowAnimation() {
- self.stopGlowAnimation() // Clean up any existing timer
- self.glowPhase = 0
-
- // Timer-based animation for explicit control
- self.glowTimer = Timer.scheduledTimer(withTimeInterval: 1.0 / 30.0, repeats: true) { _ in
- withAnimation(.linear(duration: 1.0 / 30.0)) {
- self.glowPhase += 1.0 / 30.0 / 1.5 // Complete cycle in 1.5 seconds
- if self.glowPhase >= 1.0 {
- self.glowPhase = 0
- }
- }
- }
- }
-
- private func stopGlowAnimation() {
- self.glowTimer?.invalidate()
- self.glowTimer = nil
- self.glowPhase = 0
- }
-
- private func setStaticProcessingBars() {
- // Set bars to a nice static shape (taller in center)
- withAnimation(.easeInOut(duration: 0.3)) {
+ private func setFlatProcessingBars() {
+ // During AI processing we want the visualizer to settle to silence (flat).
+ withAnimation(.easeOut(duration: 0.18)) {
for i in 0..<self.barCount {
- let centerDistance = abs(CGFloat(i) - CGFloat(self.barCount - 1) / 2)
- let centerFactor = 1.0 - (centerDistance / CGFloat(self.barCount / 2)) * 0.4
- self.barHeights[i] = self.minHeight + (self.maxHeight - self.minHeight) * 0.5 * centerFactor
+ self.barHeights[i] = self.minHeight
}
}
}