Closed ShivamRawat0l closed 1 year ago
Current solution for me is to
@State var statename = false;
WaveformLiveCanvas(samples: [],configuration: liveConfiguration,
renderer: LinearWaveformRenderer(),
shouldDrawSilencePadding: statename).onAppear{
statename = true;
}
Still this would give error inside a List {} theirfore switched to scrollview. Could have tried LazyVStack but currently scrollview is fine.
Hey @ShivamRawat0l,
I took a quick look at this myself and I can reproduce the behavior you describe.
I cannot yet exactly say why, but it does seem to be a bug in the state handling of WaveformLiveCanvas.
I’ll look into this further, but can’t promise when I may have found a fix for this.
So in the meantime your workaround will have to do. IMHO that looks like a perfectly fine and even simpler approach anyway, no?
Out of curiosity - not sure whether this is related to the library at all - what error are you getting with List?
Hey @ShivamRawat0l,
I took a quick look at this myself and I can reproduce the behavior you describe.
I cannot yet exactly say why, but it does seem to be a bug in the state handling of WaveformLiveCanvas.
I’ll look into this further, but can’t promise when I may have found a fix for this.
So in the meantime your workaround will have to do. IMHO that looks like a perfectly fine and even simpler approach anyway, no?
Out of curiosity - not sure whether this is related to the library at all - what error are you getting with List?
WIth
@State var statename = false;
WaveformLiveCanvas(samples: [],configuration: liveConfiguration,
renderer: LinearWaveformRenderer(),
shouldDrawSilencePadding: statename).onAppear{
statename = true;
}
I am putting statename to true inside onAppear. And in List onAppear and onDisappear are called regularly as we scroll through. So went with ScrollView only for the meantime.
Ah ok, I think I get what you mean.
In any case, I think I've found and fixed the issue.
If I'm completely honest with you, I don't 100% understand why SwiftUI behaves the way it does here. Something about @StateObject
that behaves different to what I'd expect.
Update to 13.0.1 and the issue should be fixed. Please let me know if it does / doesn't.
Ah ok, I think I get what you mean.
In any case, I think I've found and fixed the issue. If I'm completely honest with you, I don't 100% understand why SwiftUI behaves the way it does here. Something about
@StateObject
that behaves different to what I'd expect.Update to 13.0.1 and the issue should be fixed. Please let me know if it does / doesn't.
Wow thanks that was quick. Ill check and update the ticket :)
Working Perfectly.
Thanks for the quick response.
This is the code. Second one is working and giving drawing the silence. But for the first one it is waiting for the data to be fetched from the internet and then it is showing WaveformLiveCanvas. If I give some values in the first samples then it will display it correctly. Just not the silent part.
I am new to swift so might be missing something.
I also tried making the
shouldDrawSilencePadding : state
assign it to state and making the state false at first. Then settingstate = true
wont update it butstate = !state
will do after some clicks don't know why.