-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xcode console always report a warning #2
Comments
So, yes.
Also have to added example for illustration mistakes using /// Incorrect implementation of the list when navigation is focused on each list item
struct FalseListView: View {
var array = ListView.elements
@State
var isDetailsShow = false
var body: some View {
List(array, id: \.self) { item in
Button {
isDetailsShow = true
} label: {
Text(item)
.navigation(isActive: $isDetailsShow) {
DetailsView(text: item)
}
}
}
.padding(0)
.navigationTitle("Elements")
}
} Correct that: /// Сorrect implementation of the list when navigation is focused on the entire screen and not on its individual elements
struct TrueListView: View {
var array = ListView.elements
@State
var detailsItem: String? = nil
var body: some View {
List(array, id: \.self) { item in
Button {
detailsItem = item
} label: {
Text(item)
}
}
.padding(0)
.navigationTitle("Elements")
.navigation(item: $detailsItem) { item in
DetailsView(text: item)
}
}
} For more information you can get example. |
In your example, If put ListView() in TabView, Xcode console still report a warning above.
And I found the warning relates to the following source code, delete by testing
|
Thanks for fully Answer. @main
struct ListDetailsApp: App {
@State private var path: [String] = []
var body: some Scene {
WindowGroup {
NavigationStack(path: $path) {
TabView {
Tab("Received", systemImage: "tray.and.arrow.down.fill") {
EmptyView()
.navigationDestination(for: String.self) { route in
switch route {
case ".View1":
Text("View1")
case ".View2":
Text("View2")
default:
Text("default")
}
}
}
}
}
}
}
} It seems like TabView is also perceived as a "lazy” container, like |
Do not put a navigation destination modifier inside a "lazy” container, like
List
orLazyVStack
. These containers create child views only when needed to render on screen. Add the navigation destination modifier outside these containers so that the navigation stack can always see the destination. There's a misplacednavigationDestination(isPresented:destination:)
modifier presentingOptional<xxxx>
. It will be ignored in a future release.The text was updated successfully, but these errors were encountered: