diff --git a/README.md b/README.md index 6163c15..660028a 100644 --- a/README.md +++ b/README.md @@ -63,26 +63,29 @@ Here's an example on how to present the QR code-scanning view as a sheet and how struct QRCodeScannerExampleView: View { @State private var isPresentingScanner = false @State private var scannedCode: String? + @State private var navigationPath = NavigationPath() var body: some View { - VStack(spacing: 10) { - if let code = scannedCode { - NavigationLink("Next page", destination: NextView(scannedCode: code), isActive: .constant(true)).hidden() - } + NavigationStack(path: $navigationPath) { + VStack(spacing: 10) { + Button("Scan Code") { + isPresentingScanner = true + } - Button("Scan Code") { - isPresentingScanner = true + Text("Scan a QR code to begin") } - - Text("Scan a QR code to begin") - } - .sheet(isPresented: $isPresentingScanner) { - CodeScannerView(codeTypes: [.qr]) { response in - if case let .success(result) = response { - scannedCode = result.string - isPresentingScanner = false + .sheet(isPresented: $isPresentingScanner) { + CodeScannerView(codeTypes: [.qr]) { response in + if case let .success(result) = response { + scannedCode = result.string + isPresentingScanner = false + navigationPath.append(scannedCode) + } } } + .navigationDestination(for: String.self) { code in + NextView(scannedCode: code) + } } } }