I’ve declared a variable of kind Picture? and when view seems, based mostly on the situation this variable might be assigned totally different picture with totally different modifiers. Nevertheless, once I add modifiers after Picture and assign it to a variable, I get "Can not assign worth of kind 'some View' to kind 'Picture'"
error.
struct TestView: View {
@State personal var testIcon: Picture?
var physique: some View {
NavigationView {
VStack {
self.testIcon
Textual content("Hey World")
Spacer()
}.onAppear {
if condition1 {
self.testIcon = Picture(systemName: "hand.wave")
} else if condition2 {
// Seeing error on this line
self.testIcon = Picture(systemName: "calendar.circle").foregroundColor(.blue)
} else {
// Seeing error on this line
self.testIcon = Picture(systemName: "magnifyingglass").foregroundColor(.grey)
}
}
}
}
}
The traces on which I’m seeing error, I attempted including “as? Picture” in the direction of the top. I do not get the error however testIcon is nil when I attempt to do:
self.testIcon = Picture(systemName: "calendar.circle").foregroundColor(.blue) as? Picture
or self.testIcon = Picture(systemName: "magnifyingglass").foregroundColor(.grey) as? Picture
How can I set Picture variable with totally different modifiers?