From 8253ffa3bdd2734e24decfaa65ccf8df7126b532 Mon Sep 17 00:00:00 2001 From: Dennis Schmidt Date: Fri, 2 Jun 2023 18:53:06 +0200 Subject: [PATCH] fix lagging state propagation in WaveformLiveCanvas which caused #71 --- .../DSWaveformImageViews/SwiftUI/WaveformLiveCanvas.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/DSWaveformImageViews/SwiftUI/WaveformLiveCanvas.swift b/Sources/DSWaveformImageViews/SwiftUI/WaveformLiveCanvas.swift index bb7cdce..82fa26a 100644 --- a/Sources/DSWaveformImageViews/SwiftUI/WaveformLiveCanvas.swift +++ b/Sources/DSWaveformImageViews/SwiftUI/WaveformLiveCanvas.swift @@ -10,7 +10,7 @@ public struct WaveformLiveCanvas: View { public let renderer: WaveformRenderer public let shouldDrawSilencePadding: Bool - @StateObject private var waveformDrawer = WaveformImageDrawer() + @StateObject private var waveformDrawer: WaveformImageDrawer public init( samples: [Float], @@ -18,10 +18,14 @@ public struct WaveformLiveCanvas: View { renderer: WaveformRenderer = LinearWaveformRenderer(), shouldDrawSilencePadding: Bool = false ) { + let drawer = WaveformImageDrawer() self.samples = samples self.configuration = configuration self.renderer = renderer self.shouldDrawSilencePadding = shouldDrawSilencePadding + + drawer.shouldDrawSilencePadding = shouldDrawSilencePadding + _waveformDrawer = StateObject(wrappedValue: drawer) } public var body: some View {