Console Bug: SwiftUI encountered an issue when pushing aNavigationLink. Please file a bug.
There is no problem when I don't use the isActive parameter in NavigationLink. However, I have to use the isActive parameter. Because I'm closing the drop-down list accordingly.
Menu Model:
struct Menu: Identifiable {
var id: Int
var pageName: String
var icon: String
var page: Any
var startDelay: Double
var endDelay: Double
// var offsetY: CGFloat
}
let menu = [
Menu(id: 1, pageName: "Profil", icon: "person.crop.circle", page: ProfileView(), startDelay: 0.2, endDelay: 0.6),
Menu(id: 2, pageName: "Sepet", icon: "cart", page: CartView(), startDelay: 0.4, endDelay: 0.4),
Menu(id: 3, pageName: "İstek", icon: "plus.circle", page: ClaimView(), startDelay: 0.6, endDelay: 0.2)
]
MenuView
struct MenuView: View {
@State var isShownMenu: Bool = false
@State var isPresented: Bool = false
var body: some View {
VStack(spacing: 40) {
Button(action: {self.isShownMenu.toggle()}) {
MenuViewButton(page: .constant((Any).self), icon: .constant("rectangle.stack"))
}
VStack(spacing: 40) {
ForEach(menu, id: \.id) { item in
NavigationLink(
destination: AnyView(_fromValue: item.page),
isActive: self.$isPresented,
label: {
MenuViewButton(page: .constant(item.page), icon: .constant(item.icon))
.animation(Animation.easeInOut.delay(self.isShownMenu ? item.startDelay : item.endDelay))
.offset(x: self.isShownMenu ? .zero : UIScreen.main.bounds.width)//, y: item.offsetY)
}
}
.onChange(of: isPresented, perform: { value in
if value == true {
self.isShownMenu = false
}
})
}
}
}