From d35d6099006d128ec78a41cd21886ea2c085d967 Mon Sep 17 00:00:00 2001 From: mahal raskin Date: Wed, 12 Jun 2024 22:19:41 +0200 Subject: [PATCH 1/2] Refresh waveform when a new URL is set, Issue #89 --- .../Visualizations/AudioFileWaveform.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift b/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift index 971afa0..28938de 100644 --- a/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift +++ b/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift @@ -35,7 +35,7 @@ public struct AudioFileWaveform: View { } public var body: some View { - Group { + let group = Group { if viewModel.rmsValues.count > 2 { AudioWaveform(rmsVals: viewModel.rmsValues) .fill(color) @@ -43,8 +43,18 @@ public struct AudioFileWaveform: View { AudioWaveform(rmsVals: viewModel.rmsValues) .stroke(color) } - }.onAppear { - viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow) + } + if #available(iOS 17.0, *) { + group.onChange(of:url) { + viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow) + } + .onAppear { + viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow) + } + } else { + group.onAppear { + viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow) + } } } } From 2a714195b3b56153512186a0d5990065da85e968 Mon Sep 17 00:00:00 2001 From: mahal raskin Date: Wed, 12 Jun 2024 22:21:15 +0200 Subject: [PATCH 2/2] fixed linter to silent hound, just syntax, no semantics --- Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift b/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift index 28938de..95f1c54 100644 --- a/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift +++ b/Sources/AudioKitUI/Visualizations/AudioFileWaveform.swift @@ -45,7 +45,7 @@ public struct AudioFileWaveform: View { } } if #available(iOS 17.0, *) { - group.onChange(of:url) { + group.onChange(of: url) { viewModel.update(url: url, rmsSamplesPerWindow: rmsSamplesPerWindow) } .onAppear {