So I'm working on a little project that has a ToolBar with 4 ToolBarItems on it. Buton...Text...Text...Button
The 2nd text item displays a database version number that is extracted from a downloaded file and added to @AppStorage and that function to get the data is called from the last button.
I put code into the function to print the outputs and it shows the correct data and updates the @AppStorage variable, but the text field doesn't update until I click outside of the ToolBar, then the text field will update. I was under the impression that updating an @AppStorage variable will update the view but I think I'm missing something.
I'm fairly new to Swiftui so be gentle!
ToolbarItemGroup(placement: ToolbarItemPlacement.topBarTrailing) {
Text(verbatim: "Ver. \(fileDatabase)")
.fontWeight(.bold)
.font(.title2)
.foregroundColor(databaseVersionColor)
Button("", systemImage: "square.stack.3d.up.fill") {
getData()
}.buttonStyle(GrowingButton())
}
The (fileDatabase) field is what gets updated in @AppStorage