[JJC-20260618-005-C-2] Refactor: replace 166 Palette.xxx with @Environment(\.themePalette) (ARCH-A2)

This commit is contained in:
2026-06-18 12:02:58 +08:00
parent ccf2ea3f90
commit 38ad66f07d
11 changed files with 212 additions and 168 deletions
+9 -3
View File
@@ -10,15 +10,17 @@ import SwiftUI
import OSGKeyboardShared
struct WaveformView: View {
@Environment(\.themePalette) private var palette: ThemePalette
let level: Double // 0...1, smoothed RMS
let barCount: Int
let color: Color
let color: Color?
let active: Bool // when false, bars collapse to a thin resting line
init(
level: Double,
barCount: Int = 18,
color: Color = Palette.recordRed,
color: Color? = nil,
active: Bool = true
) {
self.level = max(0, min(1, level))
@@ -27,12 +29,16 @@ struct WaveformView: View {
self.active = active
}
private var resolvedColor: Color {
color ?? palette.recordRed
}
var body: some View {
TimelineView(.animation(minimumInterval: 1.0 / 30.0)) { context in
HStack(alignment: .center, spacing: 3) {
ForEach(0..<barCount, id: \.self) { i in
Capsule()
.fill(color)
.fill(resolvedColor)
.frame(width: 2.4, height: height(for: i, time: context.date.timeIntervalSinceReferenceDate))
.opacity(active ? 1.0 : 0.45)
}