كيف تنتقل بين الصفحات بدون استخدام NavigationLink ؟

من SwiftUI 4 ابل غيرت طريقة الـ Navigation واضافت NavigationStack

البعض قد يعتقد انه ملزم يضيف NavigationLink بس في الواقع ماهي الزامية

مثال لـ List تحتوي على اريه من عدة الوان
لاحظ الكود كله مافيه NavigationLink

لكن مع ذلك الـNavigation يعمل بدون مشاكل

حتى ميزة السحب تعمل بدون مشاكل

struct ContentView: View {
    private var bgColors: [Color] = [ .indigo, .yellow, .green, .orange, .brown ]
    @State private var path = NavigationPath()
    
    var body: some View {
        NavigationStack(path: $path) {
            List(bgColors, id: \.self) { bgColor in
                    Button {
                            path.append(bgColor)
                    } label: {
                        
                        HStack {
                        Text(bgColor.description)
                        
                        Spacer()
                        
                        Image(systemName: "chevron.forward")
                                .foregroundColor(Color.gray)
                                .font(.system(size: 15))
                        }
                }
                
            }
            .listStyle(.plain)
            .navigationDestination(for: Color.self) { color in
                        color
                            .frame(maxWidth: .infinity, maxHeight: .infinity)
            }
            .navigationTitle("Color")
        }
    }
}

استخدام الـ Path يفتح لك مجالات عديدة بحيث تقدر تعمل View معقدة بسهولة وبدون تعقيد عند الانتقال بين الصفحات