Xcode gives the error:
Function opaque return type was inferred as 'Button', which defines the opaque type in terms of itself
on the line below:
@State var showingProfile = false // Could be also Binding or else
var profileButton: some View {
Button(action: { self.showingProfile.toggle() }) { // <- Error on this line
Image(systemName: "person.crop.circle")
.imageScale(.large)
.accessibility(label: Text("User Profile"))
.navigationBarItems(trailing: self.profileButton)
.padding() } } }
do you want to achieve this?
struct ProfileButton: View {
@State var showingProfile = false // Could be also Binding or else
var body: some View {
Button(action: {
self.showingProfile.toggle()
}) {
Text("blubb")
Image(systemName: "person.crop.circle")
.imageScale(.large)
.accessibility(label: Text("User Profile"))
.padding()
}
}
}
struct ContentView: View {
let profileButton = ProfileButton(showingProfile: true)
var body: some View {
NavigationView {
Text("aah")
.navigationBarTitle("Test")
.navigationBarItems(trailing: Image(systemName: "person.crop.circle"))
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With