Hello David (I think is still only the two of us ;-),
now that I was able to experiment a little more I ran into an issue when using .fileExporter
:
If a .fileExporter
is present, it seems to prevent that changes to @State
variables trigger an UI update.
I´d be happy to dig into this problem and try to fix it. I mean I want to learn how everything works. But I think I´d need a hint, where I should start looking? If you could give me the initial pointer in the right direction, that would be great.
Below is a code-snipped to illustrate/reproduce the issue. I've also created a small sample project over here (in the IssueWithState Folder: IssueWithState
import Adwaita
@main
struct IssueWithState: App {
let app = AdwaitaApp(id: "de.virtualfridge.issueWithState")
@State private var text = "This should not be there."
@State private var openExporter = Signal()
var scene: Scene {
Window(id: "main") { window in
VStack {
Text(Loc.helloWorld)
.padding()
Button("Show FileExporter if there") {
openExporter.signal()
}
Text(text)
.padding()
.onAppear {
// this currently only works if .fileExporter is commented out
text = "It's good now"
}
}
.topToolbar { ToolbarView(app: app, window: window) }
// if the fileExporter is not there, the "text" change in the above .onAppear works just fine
.fileExporter(open: openExporter) { _ in
print("fileExporter finished")
} onClose: {
print("just closed")
}
}
.defaultSize(width: 450, height: 300)
}
}
Cheers, Michael