I am getting some strange errors at the navigation link to aboutView (bottom of ContentView):
- aboutView' initializer is inaccessible due to 'private' protection level
- Missing argument for parameter 'useHomeCur' in call
- Expected expression Xcode is also suggesting that I Insert ', useHomeCur: <#Bool#>' in ContentView
I don't get these errors in with any other view. No errors are occurring in aboutView.swift. It acts as if aboutView is a subView of ContentView. It is wanting me to define an aboutView state parameter in ContentView. Why? If I text out the state parameter and option in aboutView things work great.
I have also tried: .navigationBarItems(trailing: NavigationLink( destination: aboutView()) { Text("About"). This coding removes the expected expression error
iOS 14.0 Xcode 12.0.1 Galen
struct ContentView: View {
@State private var activateAbout = false
var body: some View {
NavigationView {
VStack {
... menu navigation links
}
.font(.title)
.navigationBarTitle("blah blah blah", displayMode: .inline)
.background(
// hide programmatically activated link here !!
NavigationLink(destination: aboutView(), isActive: $activateAbout) { EmptyView()
)
.navigationBarItems(trailing: Button( action: {
// not add - only activate it here, otherwise it will not work
self.activateAbout = true
}) {
Text("About")
}
}
}
.onAppear(perform: loadCurrencies)
}
}
}
Here is the aboutView>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
struct aboutView: View {
@EnvironmentObject var userData: UserData
@State private var useHomeCur: Bool
var body: some View {
NavigationView {
Form {
VStack (alignment: .center) {
Text("blah blah blah")
Text("blah blah blah")
}.font(.body)
Toggle(isOn: $useHomeCur) {
Text("Use this fancy feature")
}.padding()
NavigationLink(destination: docView()) {
Text("Documentation")
}
}.navigationBarTitle("About", displayMode: .inline)
}
}
}